Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 5 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 return SigninManagerFactory::GetForProfile(profile)-> | 70 return SigninManagerFactory::GetForProfile(profile)-> |
| 71 GetAuthenticatedAccountId(); | 71 GetAuthenticatedAccountId(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 class DesktopNotificationDelegate : public NotificationDelegate { | 74 class DesktopNotificationDelegate : public NotificationDelegate { |
| 75 public: | 75 public: |
| 76 // |button_click_callback| is called when the button in the notification is | 76 // |button_click_callback| is called when the button in the notification is |
| 77 // clicked. | 77 // clicked. |
| 78 DesktopNotificationDelegate(const std::string& id, | 78 DesktopNotificationDelegate(const std::string& id, |
| 79 const base::Closure& button_click_callback) | 79 const base::Closure& button_click_callback) |
| 80 : id_(id), button_click_callback_(button_click_callback) { | 80 : id_(id), button_click_callback_(button_click_callback) { |
|
bartfab (slow)
2014/08/25 13:00:45
As discussed in another code review: The style gui
davidyu
2014/08/28 09:21:14
Done.
| |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual ~DesktopNotificationDelegate() { | 83 virtual ~DesktopNotificationDelegate() { |
| 84 } | 84 } |
| 85 | 85 |
| 86 // NotificationDelegate: | 86 // NotificationDelegate: |
| 87 virtual std::string id() const OVERRIDE { | 87 virtual std::string id() const OVERRIDE { |
| 88 return id_; | 88 return id_; |
| 89 } | 89 } |
| 90 virtual content::WebContents* GetWebContents() const OVERRIDE { | 90 virtual content::WebContents* GetWebContents() const OVERRIDE { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 102 virtual void Click() OVERRIDE { | 102 virtual void Click() OVERRIDE { |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 std::string id_; | 106 std::string id_; |
| 107 base::Closure button_click_callback_; | 107 base::Closure button_click_callback_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationDelegate); | 109 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationDelegate); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // The string of Status enum. | |
| 113 const char* kStatusString[] = { | |
| 114 "STATUS_UNKNOWN", | |
| 115 "STATUS_ENROLLED", | |
| 116 "STATUS_ENROLLING", | |
| 117 "STATUS_UNENROLLED", | |
| 118 "STATUS_UNENROLLING", | |
| 119 }; | |
| 120 | |
| 121 COMPILE_ASSERT( | |
| 122 arraysize(kStatusString) == policy::ConsumerManagementService::STATUS_LAST, | |
| 123 "invalid kStatusString array size."); | |
| 124 | |
|
bartfab (slow)
2014/08/25 13:00:45
Nit: Remove extraneous blank line.
davidyu
2014/08/28 09:21:14
Done.
| |
| 125 | |
| 112 } // namespace | 126 } // namespace |
| 113 | 127 |
| 128 namespace em = enterprise_management; | |
| 129 | |
| 114 namespace policy { | 130 namespace policy { |
| 115 | 131 |
| 116 ConsumerManagementService::ConsumerManagementService( | 132 ConsumerManagementService::ConsumerManagementService( |
| 117 chromeos::CryptohomeClient* client) | 133 chromeos::CryptohomeClient* client, |
| 134 chromeos::DeviceSettingsService* device_settings_service) | |
| 118 : Consumer("consumer_management_service"), | 135 : Consumer("consumer_management_service"), |
| 119 client_(client), | 136 client_(client), |
| 137 device_settings_service_(device_settings_service), | |
| 120 enrolling_profile_(NULL), | 138 enrolling_profile_(NULL), |
| 121 weak_ptr_factory_(this) { | 139 weak_ptr_factory_(this) { |
| 122 registrar_.Add(this, | 140 registrar_.Add(this, |
| 123 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 141 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 124 content::NotificationService::AllSources()); | 142 content::NotificationService::AllSources()); |
| 143 // A NULL value may be passed in tests. | |
| 144 if (device_settings_service_) | |
| 145 device_settings_service_->AddObserver(this); | |
| 125 } | 146 } |
| 126 | 147 |
| 127 ConsumerManagementService::~ConsumerManagementService() { | 148 ConsumerManagementService::~ConsumerManagementService() { |
| 128 registrar_.Remove(this, | |
| 129 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 130 content::NotificationService::AllSources()); | |
| 131 if (enrolling_profile_) { | 149 if (enrolling_profile_) { |
| 132 ProfileOAuth2TokenServiceFactory::GetForProfile(enrolling_profile_)-> | 150 ProfileOAuth2TokenServiceFactory::GetForProfile(enrolling_profile_)-> |
| 133 RemoveObserver(this); | 151 RemoveObserver(this); |
| 134 } | 152 } |
| 153 if (device_settings_service_) | |
| 154 device_settings_service_->RemoveObserver(this); | |
| 155 registrar_.Remove(this, | |
| 156 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 157 content::NotificationService::AllSources()); | |
| 135 } | 158 } |
| 136 | 159 |
| 137 // static | 160 // static |
| 138 void ConsumerManagementService::RegisterPrefs(PrefRegistrySimple* registry) { | 161 void ConsumerManagementService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 139 registry->RegisterIntegerPref( | 162 registry->RegisterIntegerPref( |
| 140 prefs::kConsumerManagementEnrollmentState, ENROLLMENT_NONE); | 163 prefs::kConsumerManagementEnrollmentStage, ENROLLMENT_STAGE_NONE); |
| 141 } | 164 } |
| 142 | 165 |
| 143 ConsumerManagementService::ConsumerEnrollmentState | 166 void ConsumerManagementService::AddObserver(Observer* observer) { |
| 144 ConsumerManagementService::GetEnrollmentState() const { | 167 observers_.AddObserver(observer); |
| 145 const PrefService* prefs = g_browser_process->local_state(); | |
| 146 int state = prefs->GetInteger(prefs::kConsumerManagementEnrollmentState); | |
| 147 if (state < 0 || state >= ENROLLMENT_LAST) { | |
| 148 LOG(ERROR) << "Unknown enrollment state: " << state; | |
| 149 state = 0; | |
| 150 } | |
| 151 return static_cast<ConsumerEnrollmentState>(state); | |
| 152 } | 168 } |
| 153 | 169 |
| 154 void ConsumerManagementService::SetEnrollmentState( | 170 void ConsumerManagementService::RemoveObserver(Observer* observer) { |
| 155 ConsumerEnrollmentState state) { | 171 observers_.RemoveObserver(observer); |
| 172 } | |
| 173 | |
| 174 ConsumerManagementService::Status | |
| 175 ConsumerManagementService::GetStatus() const { | |
| 176 if (!device_settings_service_) | |
| 177 return STATUS_UNKNOWN; | |
| 178 | |
| 179 const enterprise_management::PolicyData* policy_data = | |
| 180 device_settings_service_->policy_data(); | |
| 181 if (!policy_data) | |
| 182 return STATUS_UNKNOWN; | |
| 183 | |
| 184 if (policy_data->management_mode() == em::PolicyData::CONSUMER_MANAGED) { | |
| 185 // TODO(davidyu): Check if unenrollment is in progress. | |
| 186 // http://crbug.com/353050. | |
| 187 return STATUS_ENROLLED; | |
| 188 } | |
| 189 | |
| 190 EnrollmentStage stage = GetEnrollmentStage(); | |
| 191 if (stage > ENROLLMENT_STAGE_NONE && stage < ENROLLMENT_STAGE_SUCCESS) | |
| 192 return STATUS_ENROLLING; | |
| 193 | |
| 194 return STATUS_UNENROLLED; | |
| 195 } | |
| 196 | |
| 197 std::string ConsumerManagementService::GetStatusString() const { | |
| 198 return kStatusString[GetStatus()]; | |
| 199 } | |
| 200 | |
| 201 ConsumerManagementService::EnrollmentStage | |
| 202 ConsumerManagementService::GetEnrollmentStage() const { | |
| 203 const PrefService* prefs = g_browser_process->local_state(); | |
| 204 int stage = prefs->GetInteger(prefs::kConsumerManagementEnrollmentStage); | |
| 205 if (stage < 0 || stage >= ENROLLMENT_STAGE_LAST) { | |
| 206 LOG(ERROR) << "Unknown enrollment stage: " << stage; | |
| 207 stage = 0; | |
| 208 } | |
| 209 return static_cast<EnrollmentStage>(stage); | |
| 210 } | |
| 211 | |
| 212 void ConsumerManagementService::SetEnrollmentStage(EnrollmentStage stage) { | |
| 156 PrefService* prefs = g_browser_process->local_state(); | 213 PrefService* prefs = g_browser_process->local_state(); |
| 157 prefs->SetInteger(prefs::kConsumerManagementEnrollmentState, state); | 214 prefs->SetInteger(prefs::kConsumerManagementEnrollmentStage, stage); |
| 215 | |
| 216 NotifyStatusChanged(); | |
| 158 } | 217 } |
| 159 | 218 |
| 160 void ConsumerManagementService::GetOwner(const GetOwnerCallback& callback) { | 219 void ConsumerManagementService::GetOwner(const GetOwnerCallback& callback) { |
| 161 cryptohome::GetBootAttributeRequest request; | 220 cryptohome::GetBootAttributeRequest request; |
| 162 request.set_name(kAttributeOwnerId); | 221 request.set_name(kAttributeOwnerId); |
| 163 client_->GetBootAttribute( | 222 client_->GetBootAttribute( |
| 164 request, | 223 request, |
| 165 base::Bind(&ConsumerManagementService::OnGetBootAttributeDone, | 224 base::Bind(&ConsumerManagementService::OnGetBootAttributeDone, |
| 166 weak_ptr_factory_.GetWeakPtr(), | 225 weak_ptr_factory_.GetWeakPtr(), |
| 167 callback)); | 226 callback)); |
| 168 } | 227 } |
| 169 | 228 |
| 170 void ConsumerManagementService::SetOwner(const std::string& user_id, | 229 void ConsumerManagementService::SetOwner(const std::string& user_id, |
| 171 const SetOwnerCallback& callback) { | 230 const SetOwnerCallback& callback) { |
| 172 cryptohome::SetBootAttributeRequest request; | 231 cryptohome::SetBootAttributeRequest request; |
| 173 request.set_name(kAttributeOwnerId); | 232 request.set_name(kAttributeOwnerId); |
| 174 request.set_value(user_id.data(), user_id.size()); | 233 request.set_value(user_id.data(), user_id.size()); |
| 175 client_->SetBootAttribute( | 234 client_->SetBootAttribute( |
| 176 request, | 235 request, |
| 177 base::Bind(&ConsumerManagementService::OnSetBootAttributeDone, | 236 base::Bind(&ConsumerManagementService::OnSetBootAttributeDone, |
| 178 weak_ptr_factory_.GetWeakPtr(), | 237 weak_ptr_factory_.GetWeakPtr(), |
| 179 callback)); | 238 callback)); |
| 180 } | 239 } |
| 181 | 240 |
| 241 void ConsumerManagementService::OwnershipStatusChanged() { | |
| 242 } | |
| 243 | |
| 244 void ConsumerManagementService::DeviceSettingsUpdated() { | |
| 245 NotifyStatusChanged(); | |
| 246 } | |
| 247 | |
| 182 void ConsumerManagementService::Observe( | 248 void ConsumerManagementService::Observe( |
| 183 int type, | 249 int type, |
| 184 const content::NotificationSource& source, | 250 const content::NotificationSource& source, |
| 185 const content::NotificationDetails& details) { | 251 const content::NotificationDetails& details) { |
| 186 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { | 252 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { |
| 187 NOTREACHED() << "Unexpected notification " << type; | 253 NOTREACHED() << "Unexpected notification " << type; |
| 188 return; | 254 return; |
| 189 } | 255 } |
| 190 | 256 |
| 191 Profile* profile = content::Details<Profile>(details).ptr(); | 257 Profile* profile = content::Details<Profile>(details).ptr(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 214 OnOwnerAccessTokenAvailable(access_token); | 280 OnOwnerAccessTokenAvailable(access_token); |
| 215 } | 281 } |
| 216 | 282 |
| 217 void ConsumerManagementService::OnGetTokenFailure( | 283 void ConsumerManagementService::OnGetTokenFailure( |
| 218 const OAuth2TokenService::Request* request, | 284 const OAuth2TokenService::Request* request, |
| 219 const GoogleServiceAuthError& error) { | 285 const GoogleServiceAuthError& error) { |
| 220 DCHECK_EQ(token_request_, request); | 286 DCHECK_EQ(token_request_, request); |
| 221 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); | 287 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); |
| 222 | 288 |
| 223 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); | 289 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); |
| 224 EndEnrollment(ENROLLMENT_GET_TOKEN_FAILED); | 290 EndEnrollment(ENROLLMENT_STAGE_GET_TOKEN_FAILED); |
| 225 } | 291 } |
| 226 | 292 |
| 227 void ConsumerManagementService::OnGetBootAttributeDone( | 293 void ConsumerManagementService::OnGetBootAttributeDone( |
| 228 const GetOwnerCallback& callback, | 294 const GetOwnerCallback& callback, |
| 229 chromeos::DBusMethodCallStatus call_status, | 295 chromeos::DBusMethodCallStatus call_status, |
| 230 bool dbus_success, | 296 bool dbus_success, |
| 231 const cryptohome::BaseReply& reply) { | 297 const cryptohome::BaseReply& reply) { |
| 232 if (!dbus_success || reply.error() != 0) { | 298 if (!dbus_success || reply.error() != 0) { |
| 233 LOG(ERROR) << "Failed to get the owner info from boot lockbox."; | 299 LOG(ERROR) << "Failed to get the owner info from boot lockbox."; |
| 234 callback.Run(""); | 300 callback.Run(""); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 if (!dbus_success || reply.error() != 0) { | 332 if (!dbus_success || reply.error() != 0) { |
| 267 LOG(ERROR) << "Failed to flush and sign boot lockbox."; | 333 LOG(ERROR) << "Failed to flush and sign boot lockbox."; |
| 268 callback.Run(false); | 334 callback.Run(false); |
| 269 return; | 335 return; |
| 270 } | 336 } |
| 271 | 337 |
| 272 callback.Run(true); | 338 callback.Run(true); |
| 273 } | 339 } |
| 274 | 340 |
| 275 void ConsumerManagementService::OnOwnerSignin(Profile* profile) { | 341 void ConsumerManagementService::OnOwnerSignin(Profile* profile) { |
| 276 const ConsumerEnrollmentState state = GetEnrollmentState(); | 342 const EnrollmentStage stage = GetEnrollmentStage(); |
| 277 switch (state) { | 343 switch (stage) { |
| 278 case ENROLLMENT_NONE: | 344 case ENROLLMENT_STAGE_NONE: |
| 279 // Do nothing. | 345 // Do nothing. |
| 280 return; | 346 return; |
| 281 | 347 |
| 282 case ENROLLMENT_OWNER_STORED: | 348 case ENROLLMENT_STAGE_OWNER_STORED: |
| 283 // Continue the enrollment process after the owner signs in. | 349 // Continue the enrollment process after the owner signs in. |
| 284 ContinueEnrollmentProcess(profile); | 350 ContinueEnrollmentProcess(profile); |
| 285 return; | 351 return; |
| 286 | 352 |
| 287 case ENROLLMENT_SUCCESS: | 353 case ENROLLMENT_STAGE_SUCCESS: |
| 288 case ENROLLMENT_CANCELED: | 354 case ENROLLMENT_STAGE_CANCELED: |
| 289 case ENROLLMENT_BOOT_LOCKBOX_FAILED: | 355 case ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED: |
| 290 case ENROLLMENT_DM_SERVER_FAILED: | 356 case ENROLLMENT_STAGE_DM_SERVER_FAILED: |
| 291 case ENROLLMENT_GET_TOKEN_FAILED: | 357 case ENROLLMENT_STAGE_GET_TOKEN_FAILED: |
| 292 ShowDesktopNotificationAndResetState(state, profile); | 358 ShowDesktopNotificationAndResetStage(stage, profile); |
| 293 return; | 359 return; |
| 294 | 360 |
| 295 case ENROLLMENT_REQUESTED: | 361 case ENROLLMENT_STAGE_REQUESTED: |
| 296 case ENROLLMENT_LAST: | 362 case ENROLLMENT_STAGE_LAST: |
| 297 NOTREACHED() << "Unexpected enrollment state " << state; | 363 NOTREACHED() << "Unexpected enrollment stage " << stage; |
| 298 return; | 364 return; |
| 299 } | 365 } |
| 300 } | 366 } |
| 301 | 367 |
| 302 void ConsumerManagementService::ContinueEnrollmentProcess(Profile* profile) { | 368 void ConsumerManagementService::ContinueEnrollmentProcess(Profile* profile) { |
| 303 enrolling_profile_ = profile; | 369 enrolling_profile_ = profile; |
| 304 | 370 |
| 305 // First, we need to ensure that the refresh token is available. | 371 // First, we need to ensure that the refresh token is available. |
| 306 const std::string& account_id = GetAccountIdFromProfile(profile); | 372 const std::string& account_id = GetAccountIdFromProfile(profile); |
| 307 ProfileOAuth2TokenService* token_service = | 373 ProfileOAuth2TokenService* token_service = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 } | 415 } |
| 350 | 416 |
| 351 void ConsumerManagementService::OnEnrollmentCompleted(EnrollmentStatus status) { | 417 void ConsumerManagementService::OnEnrollmentCompleted(EnrollmentStatus status) { |
| 352 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { | 418 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { |
| 353 LOG(ERROR) << "Failed to enroll the device." | 419 LOG(ERROR) << "Failed to enroll the device." |
| 354 << " status=" << status.status() | 420 << " status=" << status.status() |
| 355 << " client_status=" << status.client_status() | 421 << " client_status=" << status.client_status() |
| 356 << " http_status=" << status.http_status() | 422 << " http_status=" << status.http_status() |
| 357 << " store_status=" << status.store_status() | 423 << " store_status=" << status.store_status() |
| 358 << " validation_status=" << status.validation_status(); | 424 << " validation_status=" << status.validation_status(); |
| 359 EndEnrollment(ENROLLMENT_DM_SERVER_FAILED); | 425 EndEnrollment(ENROLLMENT_STAGE_DM_SERVER_FAILED); |
| 360 return; | 426 return; |
| 361 } | 427 } |
| 362 | 428 |
| 363 EndEnrollment(ENROLLMENT_SUCCESS); | 429 EndEnrollment(ENROLLMENT_STAGE_SUCCESS); |
| 364 } | 430 } |
| 365 | 431 |
| 366 void ConsumerManagementService::EndEnrollment(ConsumerEnrollmentState state) { | 432 void ConsumerManagementService::EndEnrollment(EnrollmentStage stage) { |
| 367 Profile* profile = enrolling_profile_; | 433 Profile* profile = enrolling_profile_; |
| 368 enrolling_profile_ = NULL; | 434 enrolling_profile_ = NULL; |
| 369 | 435 |
| 370 SetEnrollmentState(state); | 436 SetEnrollmentStage(stage); |
| 371 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) | 437 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) |
| 372 ShowDesktopNotificationAndResetState(state, profile); | 438 ShowDesktopNotificationAndResetStage(stage, profile); |
| 373 } | 439 } |
| 374 | 440 |
| 375 void ConsumerManagementService::ShowDesktopNotificationAndResetState( | 441 void ConsumerManagementService::ShowDesktopNotificationAndResetStage( |
| 376 ConsumerEnrollmentState state, Profile* profile) { | 442 EnrollmentStage stage, Profile* profile) { |
| 377 base::string16 title; | 443 base::string16 title; |
| 378 base::string16 body; | 444 base::string16 body; |
| 379 base::string16 button_label; | 445 base::string16 button_label; |
| 380 base::Closure button_click_callback; | 446 base::Closure button_click_callback; |
| 381 | 447 |
| 382 if (state == ENROLLMENT_SUCCESS) { | 448 if (stage == ENROLLMENT_STAGE_SUCCESS) { |
| 383 title = l10n_util::GetStringUTF16( | 449 title = l10n_util::GetStringUTF16( |
| 384 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_TITLE); | 450 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_TITLE); |
| 385 body = l10n_util::GetStringUTF16( | 451 body = l10n_util::GetStringUTF16( |
| 386 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_BODY); | 452 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_BODY); |
| 387 button_label = l10n_util::GetStringUTF16( | 453 button_label = l10n_util::GetStringUTF16( |
| 388 IDS_CONSUMER_MANAGEMENT_NOTIFICATION_MODIFY_SETTINGS_BUTTON); | 454 IDS_CONSUMER_MANAGEMENT_NOTIFICATION_MODIFY_SETTINGS_BUTTON); |
| 389 button_click_callback = base::Bind( | 455 button_click_callback = base::Bind( |
| 390 &ConsumerManagementService::OpenSettingsPage, | 456 &ConsumerManagementService::OpenSettingsPage, |
| 391 weak_ptr_factory_.GetWeakPtr(), | 457 weak_ptr_factory_.GetWeakPtr(), |
| 392 profile); | 458 profile); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 416 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 482 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 417 kEnrollmentNotificationId), | 483 kEnrollmentNotificationId), |
| 418 base::string16(), // display_source | 484 base::string16(), // display_source |
| 419 base::UTF8ToUTF16(kEnrollmentNotificationId), | 485 base::UTF8ToUTF16(kEnrollmentNotificationId), |
| 420 optional_field, | 486 optional_field, |
| 421 new DesktopNotificationDelegate(kEnrollmentNotificationId, | 487 new DesktopNotificationDelegate(kEnrollmentNotificationId, |
| 422 button_click_callback)); | 488 button_click_callback)); |
| 423 notification.SetSystemPriority(); | 489 notification.SetSystemPriority(); |
| 424 g_browser_process->notification_ui_manager()->Add(notification, profile); | 490 g_browser_process->notification_ui_manager()->Add(notification, profile); |
| 425 | 491 |
| 426 SetEnrollmentState(ENROLLMENT_NONE); | 492 SetEnrollmentStage(ENROLLMENT_STAGE_NONE); |
| 427 } | 493 } |
| 428 | 494 |
| 429 void ConsumerManagementService::OpenSettingsPage(Profile* profile) const { | 495 void ConsumerManagementService::OpenSettingsPage(Profile* profile) const { |
| 430 const GURL url(chrome::kChromeUISettingsURL); | 496 const GURL url(chrome::kChromeUISettingsURL); |
| 431 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); | 497 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); |
| 432 params.disposition = NEW_FOREGROUND_TAB; | 498 params.disposition = NEW_FOREGROUND_TAB; |
| 433 chrome::Navigate(¶ms); | 499 chrome::Navigate(¶ms); |
| 434 } | 500 } |
| 435 | 501 |
| 436 void ConsumerManagementService::TryEnrollmentAgain(Profile* profile) const { | 502 void ConsumerManagementService::TryEnrollmentAgain(Profile* profile) const { |
| 437 const GURL base_url(chrome::kChromeUISettingsURL); | 503 const GURL base_url(chrome::kChromeUISettingsURL); |
| 438 const GURL url = base_url.Resolve(kConsumerManagementOverlay); | 504 const GURL url = base_url.Resolve(kConsumerManagementOverlay); |
| 439 | 505 |
| 440 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); | 506 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); |
| 441 params.disposition = NEW_FOREGROUND_TAB; | 507 params.disposition = NEW_FOREGROUND_TAB; |
| 442 chrome::Navigate(¶ms); | 508 chrome::Navigate(¶ms); |
| 443 } | 509 } |
| 444 | 510 |
| 511 void ConsumerManagementService::NotifyStatusChanged() { | |
| 512 FOR_EACH_OBSERVER(Observer, observers_, OnConsumerManagementStatusChanged()); | |
| 513 } | |
| 514 | |
| 445 } // namespace policy | 515 } // namespace policy |
| OLD | NEW |