Reset the device policy machinery upon retrying enrollment.

BUG=chromium-os:18208
TEST=See bug description


Review URL: http://codereview.chromium.org/7676005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97615 0039d316-1c4b-4281-b951-d872f2087c98
void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
    const std::string& token,
    policy::BrowserPolicyConnector::TokenType token_type) {
  policy::BrowserPolicyConnector* connector =
      g_browser_process->browser_policy_connector();
  if (!connector->device_cloud_policy_subsystem()) {
    NOTREACHED() << "Cloud policy subsystem not initialized.";
    UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
                              policy::kMetricEnrollmentOtherFailed,
                              policy::kMetricEnrollmentSize);
    if (is_showing_)
      actor_->ShowFatalEnrollmentError();
    return;
  }

  connector->ScheduleServiceInitialization(0);
  registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
      connector->device_cloud_policy_subsystem(), this));
 
  connector->RegisterForDevicePolicy(user_, token, token_type);
 }

void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
    const std::string& token,
    policy::BrowserPolicyConnector::TokenType token_type) {
  policy::BrowserPolicyConnector* connector =
      g_browser_process->browser_policy_connector();
  if (!connector->device_cloud_policy_subsystem()) {
    NOTREACHED() << "Cloud policy subsystem not initialized.";
    UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
                              policy::kMetricEnrollmentOtherFailed,
                              policy::kMetricEnrollmentSize);
    if (is_showing_)
      actor_->ShowFatalEnrollmentError();
    return;
  }

  connector->ScheduleServiceInitialization(0);
  registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
      connector->device_cloud_policy_subsystem(), this));
 
  connector->SetDeviceCredentials(user_, token, token_type);
 }
