| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_process_platform_part.h" | 17 #include "chrome/browser/browser_process_platform_part.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 23 #include "chrome/browser/notifications/notification.h" | 23 #include "chrome/browser/notifications/notification.h" |
| 24 #include "chrome/browser/notifications/notification_delegate.h" |
| 24 #include "chrome/browser/notifications/notification_ui_manager.h" | 25 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "chromeos/dbus/cryptohome/rpc.pb.h" | 32 #include "chromeos/dbus/cryptohome/rpc.pb.h" |
| 32 #include "chromeos/dbus/cryptohome_client.h" | 33 #include "chromeos/dbus/cryptohome_client.h" |
| 33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 123 |
| 123 void DesktopNotificationDelegate::Error() { | 124 void DesktopNotificationDelegate::Error() { |
| 124 } | 125 } |
| 125 | 126 |
| 126 void DesktopNotificationDelegate::Close(bool by_user) { | 127 void DesktopNotificationDelegate::Close(bool by_user) { |
| 127 } | 128 } |
| 128 | 129 |
| 129 void DesktopNotificationDelegate::Click() { | 130 void DesktopNotificationDelegate::Click() { |
| 130 } | 131 } |
| 131 | 132 |
| 133 // The string of Status enum. |
| 134 const char* kStatusString[] = { |
| 135 "StatusUnknown", |
| 136 "StatusEnrolled", |
| 137 "StatusEnrolling", |
| 138 "StatusUnenrolled", |
| 139 "StatusUnenrolling", |
| 140 }; |
| 141 |
| 142 COMPILE_ASSERT( |
| 143 arraysize(kStatusString) == policy::ConsumerManagementService::STATUS_LAST, |
| 144 "invalid kStatusString array size."); |
| 145 |
| 132 } // namespace | 146 } // namespace |
| 133 | 147 |
| 148 namespace em = enterprise_management; |
| 149 |
| 134 namespace policy { | 150 namespace policy { |
| 135 | 151 |
| 136 ConsumerManagementService::ConsumerManagementService( | 152 ConsumerManagementService::ConsumerManagementService( |
| 137 chromeos::CryptohomeClient* client) | 153 chromeos::CryptohomeClient* client, |
| 154 chromeos::DeviceSettingsService* device_settings_service) |
| 138 : Consumer("consumer_management_service"), | 155 : Consumer("consumer_management_service"), |
| 139 client_(client), | 156 client_(client), |
| 157 device_settings_service_(device_settings_service), |
| 140 enrolling_profile_(NULL), | 158 enrolling_profile_(NULL), |
| 141 weak_ptr_factory_(this) { | 159 weak_ptr_factory_(this) { |
| 142 registrar_.Add(this, | 160 registrar_.Add(this, |
| 143 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 161 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 144 content::NotificationService::AllSources()); | 162 content::NotificationService::AllSources()); |
| 163 // A NULL value may be passed in tests. |
| 164 if (device_settings_service_) |
| 165 device_settings_service_->AddObserver(this); |
| 145 } | 166 } |
| 146 | 167 |
| 147 ConsumerManagementService::~ConsumerManagementService() { | 168 ConsumerManagementService::~ConsumerManagementService() { |
| 148 registrar_.Remove(this, | |
| 149 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
| 150 content::NotificationService::AllSources()); | |
| 151 if (enrolling_profile_) { | 169 if (enrolling_profile_) { |
| 152 ProfileOAuth2TokenServiceFactory::GetForProfile(enrolling_profile_)-> | 170 ProfileOAuth2TokenServiceFactory::GetForProfile(enrolling_profile_)-> |
| 153 RemoveObserver(this); | 171 RemoveObserver(this); |
| 154 } | 172 } |
| 173 if (device_settings_service_) |
| 174 device_settings_service_->RemoveObserver(this); |
| 175 registrar_.Remove(this, |
| 176 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 177 content::NotificationService::AllSources()); |
| 155 } | 178 } |
| 156 | 179 |
| 157 // static | 180 // static |
| 158 void ConsumerManagementService::RegisterPrefs(PrefRegistrySimple* registry) { | 181 void ConsumerManagementService::RegisterPrefs(PrefRegistrySimple* registry) { |
| 159 registry->RegisterIntegerPref( | 182 registry->RegisterIntegerPref( |
| 160 prefs::kConsumerManagementEnrollmentState, ENROLLMENT_NONE); | 183 prefs::kConsumerManagementEnrollmentStage, ENROLLMENT_STAGE_NONE); |
| 161 } | 184 } |
| 162 | 185 |
| 163 ConsumerManagementService::ConsumerEnrollmentState | 186 void ConsumerManagementService::AddObserver(Observer* observer) { |
| 164 ConsumerManagementService::GetEnrollmentState() const { | 187 observers_.AddObserver(observer); |
| 165 const PrefService* prefs = g_browser_process->local_state(); | |
| 166 int state = prefs->GetInteger(prefs::kConsumerManagementEnrollmentState); | |
| 167 if (state < 0 || state >= ENROLLMENT_LAST) { | |
| 168 LOG(ERROR) << "Unknown enrollment state: " << state; | |
| 169 state = 0; | |
| 170 } | |
| 171 return static_cast<ConsumerEnrollmentState>(state); | |
| 172 } | 188 } |
| 173 | 189 |
| 174 void ConsumerManagementService::SetEnrollmentState( | 190 void ConsumerManagementService::RemoveObserver(Observer* observer) { |
| 175 ConsumerEnrollmentState state) { | 191 observers_.RemoveObserver(observer); |
| 192 } |
| 193 |
| 194 ConsumerManagementService::Status |
| 195 ConsumerManagementService::GetStatus() const { |
| 196 if (!device_settings_service_) |
| 197 return STATUS_UNKNOWN; |
| 198 |
| 199 const enterprise_management::PolicyData* policy_data = |
| 200 device_settings_service_->policy_data(); |
| 201 if (!policy_data) |
| 202 return STATUS_UNKNOWN; |
| 203 |
| 204 if (policy_data->management_mode() == em::PolicyData::CONSUMER_MANAGED) { |
| 205 // TODO(davidyu): Check if unenrollment is in progress. |
| 206 // http://crbug.com/353050. |
| 207 return STATUS_ENROLLED; |
| 208 } |
| 209 |
| 210 EnrollmentStage stage = GetEnrollmentStage(); |
| 211 if (stage > ENROLLMENT_STAGE_NONE && stage < ENROLLMENT_STAGE_SUCCESS) |
| 212 return STATUS_ENROLLING; |
| 213 |
| 214 return STATUS_UNENROLLED; |
| 215 } |
| 216 |
| 217 std::string ConsumerManagementService::GetStatusString() const { |
| 218 return kStatusString[GetStatus()]; |
| 219 } |
| 220 |
| 221 ConsumerManagementService::EnrollmentStage |
| 222 ConsumerManagementService::GetEnrollmentStage() const { |
| 223 const PrefService* prefs = g_browser_process->local_state(); |
| 224 int stage = prefs->GetInteger(prefs::kConsumerManagementEnrollmentStage); |
| 225 if (stage < 0 || stage >= ENROLLMENT_STAGE_LAST) { |
| 226 LOG(ERROR) << "Unknown enrollment stage: " << stage; |
| 227 stage = 0; |
| 228 } |
| 229 return static_cast<EnrollmentStage>(stage); |
| 230 } |
| 231 |
| 232 void ConsumerManagementService::SetEnrollmentStage(EnrollmentStage stage) { |
| 176 PrefService* prefs = g_browser_process->local_state(); | 233 PrefService* prefs = g_browser_process->local_state(); |
| 177 prefs->SetInteger(prefs::kConsumerManagementEnrollmentState, state); | 234 prefs->SetInteger(prefs::kConsumerManagementEnrollmentStage, stage); |
| 235 |
| 236 NotifyStatusChanged(); |
| 178 } | 237 } |
| 179 | 238 |
| 180 void ConsumerManagementService::GetOwner(const GetOwnerCallback& callback) { | 239 void ConsumerManagementService::GetOwner(const GetOwnerCallback& callback) { |
| 181 cryptohome::GetBootAttributeRequest request; | 240 cryptohome::GetBootAttributeRequest request; |
| 182 request.set_name(kAttributeOwnerId); | 241 request.set_name(kAttributeOwnerId); |
| 183 client_->GetBootAttribute( | 242 client_->GetBootAttribute( |
| 184 request, | 243 request, |
| 185 base::Bind(&ConsumerManagementService::OnGetBootAttributeDone, | 244 base::Bind(&ConsumerManagementService::OnGetBootAttributeDone, |
| 186 weak_ptr_factory_.GetWeakPtr(), | 245 weak_ptr_factory_.GetWeakPtr(), |
| 187 callback)); | 246 callback)); |
| 188 } | 247 } |
| 189 | 248 |
| 190 void ConsumerManagementService::SetOwner(const std::string& user_id, | 249 void ConsumerManagementService::SetOwner(const std::string& user_id, |
| 191 const SetOwnerCallback& callback) { | 250 const SetOwnerCallback& callback) { |
| 192 cryptohome::SetBootAttributeRequest request; | 251 cryptohome::SetBootAttributeRequest request; |
| 193 request.set_name(kAttributeOwnerId); | 252 request.set_name(kAttributeOwnerId); |
| 194 request.set_value(user_id.data(), user_id.size()); | 253 request.set_value(user_id.data(), user_id.size()); |
| 195 client_->SetBootAttribute( | 254 client_->SetBootAttribute( |
| 196 request, | 255 request, |
| 197 base::Bind(&ConsumerManagementService::OnSetBootAttributeDone, | 256 base::Bind(&ConsumerManagementService::OnSetBootAttributeDone, |
| 198 weak_ptr_factory_.GetWeakPtr(), | 257 weak_ptr_factory_.GetWeakPtr(), |
| 199 callback)); | 258 callback)); |
| 200 } | 259 } |
| 201 | 260 |
| 261 void ConsumerManagementService::OwnershipStatusChanged() { |
| 262 } |
| 263 |
| 264 void ConsumerManagementService::DeviceSettingsUpdated() { |
| 265 NotifyStatusChanged(); |
| 266 } |
| 267 |
| 202 void ConsumerManagementService::Observe( | 268 void ConsumerManagementService::Observe( |
| 203 int type, | 269 int type, |
| 204 const content::NotificationSource& source, | 270 const content::NotificationSource& source, |
| 205 const content::NotificationDetails& details) { | 271 const content::NotificationDetails& details) { |
| 206 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { | 272 if (type != chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED) { |
| 207 NOTREACHED() << "Unexpected notification " << type; | 273 NOTREACHED() << "Unexpected notification " << type; |
| 208 return; | 274 return; |
| 209 } | 275 } |
| 210 | 276 |
| 211 Profile* profile = content::Details<Profile>(details).ptr(); | 277 Profile* profile = content::Details<Profile>(details).ptr(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 234 OnOwnerAccessTokenAvailable(access_token); | 300 OnOwnerAccessTokenAvailable(access_token); |
| 235 } | 301 } |
| 236 | 302 |
| 237 void ConsumerManagementService::OnGetTokenFailure( | 303 void ConsumerManagementService::OnGetTokenFailure( |
| 238 const OAuth2TokenService::Request* request, | 304 const OAuth2TokenService::Request* request, |
| 239 const GoogleServiceAuthError& error) { | 305 const GoogleServiceAuthError& error) { |
| 240 DCHECK_EQ(token_request_, request); | 306 DCHECK_EQ(token_request_, request); |
| 241 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); | 307 base::MessageLoop::current()->DeleteSoon(FROM_HERE, token_request_.release()); |
| 242 | 308 |
| 243 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); | 309 LOG(ERROR) << "Failed to get the access token: " << error.ToString(); |
| 244 EndEnrollment(ENROLLMENT_GET_TOKEN_FAILED); | 310 EndEnrollment(ENROLLMENT_STAGE_GET_TOKEN_FAILED); |
| 245 } | 311 } |
| 246 | 312 |
| 247 void ConsumerManagementService::OnGetBootAttributeDone( | 313 void ConsumerManagementService::OnGetBootAttributeDone( |
| 248 const GetOwnerCallback& callback, | 314 const GetOwnerCallback& callback, |
| 249 chromeos::DBusMethodCallStatus call_status, | 315 chromeos::DBusMethodCallStatus call_status, |
| 250 bool dbus_success, | 316 bool dbus_success, |
| 251 const cryptohome::BaseReply& reply) { | 317 const cryptohome::BaseReply& reply) { |
| 252 if (!dbus_success || reply.error() != 0) { | 318 if (!dbus_success || reply.error() != 0) { |
| 253 LOG(ERROR) << "Failed to get the owner info from boot lockbox."; | 319 LOG(ERROR) << "Failed to get the owner info from boot lockbox."; |
| 254 callback.Run(""); | 320 callback.Run(""); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 if (!dbus_success || reply.error() != 0) { | 352 if (!dbus_success || reply.error() != 0) { |
| 287 LOG(ERROR) << "Failed to flush and sign boot lockbox."; | 353 LOG(ERROR) << "Failed to flush and sign boot lockbox."; |
| 288 callback.Run(false); | 354 callback.Run(false); |
| 289 return; | 355 return; |
| 290 } | 356 } |
| 291 | 357 |
| 292 callback.Run(true); | 358 callback.Run(true); |
| 293 } | 359 } |
| 294 | 360 |
| 295 void ConsumerManagementService::OnOwnerSignin(Profile* profile) { | 361 void ConsumerManagementService::OnOwnerSignin(Profile* profile) { |
| 296 const ConsumerEnrollmentState state = GetEnrollmentState(); | 362 const EnrollmentStage stage = GetEnrollmentStage(); |
| 297 switch (state) { | 363 switch (stage) { |
| 298 case ENROLLMENT_NONE: | 364 case ENROLLMENT_STAGE_NONE: |
| 299 // Do nothing. | 365 // Do nothing. |
| 300 return; | 366 return; |
| 301 | 367 |
| 302 case ENROLLMENT_OWNER_STORED: | 368 case ENROLLMENT_STAGE_OWNER_STORED: |
| 303 // Continue the enrollment process after the owner signs in. | 369 // Continue the enrollment process after the owner signs in. |
| 304 ContinueEnrollmentProcess(profile); | 370 ContinueEnrollmentProcess(profile); |
| 305 return; | 371 return; |
| 306 | 372 |
| 307 case ENROLLMENT_SUCCESS: | 373 case ENROLLMENT_STAGE_SUCCESS: |
| 308 case ENROLLMENT_CANCELED: | 374 case ENROLLMENT_STAGE_CANCELED: |
| 309 case ENROLLMENT_BOOT_LOCKBOX_FAILED: | 375 case ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED: |
| 310 case ENROLLMENT_DM_SERVER_FAILED: | 376 case ENROLLMENT_STAGE_DM_SERVER_FAILED: |
| 311 case ENROLLMENT_GET_TOKEN_FAILED: | 377 case ENROLLMENT_STAGE_GET_TOKEN_FAILED: |
| 312 ShowDesktopNotificationAndResetState(state, profile); | 378 ShowDesktopNotificationAndResetStage(stage, profile); |
| 313 return; | 379 return; |
| 314 | 380 |
| 315 case ENROLLMENT_REQUESTED: | 381 case ENROLLMENT_STAGE_REQUESTED: |
| 316 case ENROLLMENT_LAST: | 382 case ENROLLMENT_STAGE_LAST: |
| 317 NOTREACHED() << "Unexpected enrollment state " << state; | 383 NOTREACHED() << "Unexpected enrollment stage " << stage; |
| 318 return; | 384 return; |
| 319 } | 385 } |
| 320 } | 386 } |
| 321 | 387 |
| 322 void ConsumerManagementService::ContinueEnrollmentProcess(Profile* profile) { | 388 void ConsumerManagementService::ContinueEnrollmentProcess(Profile* profile) { |
| 323 enrolling_profile_ = profile; | 389 enrolling_profile_ = profile; |
| 324 | 390 |
| 325 // First, we need to ensure that the refresh token is available. | 391 // First, we need to ensure that the refresh token is available. |
| 326 const std::string& account_id = GetAccountIdFromProfile(profile); | 392 const std::string& account_id = GetAccountIdFromProfile(profile); |
| 327 ProfileOAuth2TokenService* token_service = | 393 ProfileOAuth2TokenService* token_service = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 435 } |
| 370 | 436 |
| 371 void ConsumerManagementService::OnEnrollmentCompleted(EnrollmentStatus status) { | 437 void ConsumerManagementService::OnEnrollmentCompleted(EnrollmentStatus status) { |
| 372 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { | 438 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { |
| 373 LOG(ERROR) << "Failed to enroll the device." | 439 LOG(ERROR) << "Failed to enroll the device." |
| 374 << " status=" << status.status() | 440 << " status=" << status.status() |
| 375 << " client_status=" << status.client_status() | 441 << " client_status=" << status.client_status() |
| 376 << " http_status=" << status.http_status() | 442 << " http_status=" << status.http_status() |
| 377 << " store_status=" << status.store_status() | 443 << " store_status=" << status.store_status() |
| 378 << " validation_status=" << status.validation_status(); | 444 << " validation_status=" << status.validation_status(); |
| 379 EndEnrollment(ENROLLMENT_DM_SERVER_FAILED); | 445 EndEnrollment(ENROLLMENT_STAGE_DM_SERVER_FAILED); |
| 380 return; | 446 return; |
| 381 } | 447 } |
| 382 | 448 |
| 383 EndEnrollment(ENROLLMENT_SUCCESS); | 449 EndEnrollment(ENROLLMENT_STAGE_SUCCESS); |
| 384 } | 450 } |
| 385 | 451 |
| 386 void ConsumerManagementService::EndEnrollment(ConsumerEnrollmentState state) { | 452 void ConsumerManagementService::EndEnrollment(EnrollmentStage stage) { |
| 387 Profile* profile = enrolling_profile_; | 453 Profile* profile = enrolling_profile_; |
| 388 enrolling_profile_ = NULL; | 454 enrolling_profile_ = NULL; |
| 389 | 455 |
| 390 SetEnrollmentState(state); | 456 SetEnrollmentStage(stage); |
| 391 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) | 457 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) |
| 392 ShowDesktopNotificationAndResetState(state, profile); | 458 ShowDesktopNotificationAndResetStage(stage, profile); |
| 393 } | 459 } |
| 394 | 460 |
| 395 void ConsumerManagementService::ShowDesktopNotificationAndResetState( | 461 void ConsumerManagementService::ShowDesktopNotificationAndResetStage( |
| 396 ConsumerEnrollmentState state, Profile* profile) { | 462 EnrollmentStage stage, Profile* profile) { |
| 397 base::string16 title; | 463 base::string16 title; |
| 398 base::string16 body; | 464 base::string16 body; |
| 399 base::string16 button_label; | 465 base::string16 button_label; |
| 400 base::Closure button_click_callback; | 466 base::Closure button_click_callback; |
| 401 | 467 |
| 402 if (state == ENROLLMENT_SUCCESS) { | 468 if (stage == ENROLLMENT_STAGE_SUCCESS) { |
| 403 title = l10n_util::GetStringUTF16( | 469 title = l10n_util::GetStringUTF16( |
| 404 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_TITLE); | 470 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_TITLE); |
| 405 body = l10n_util::GetStringUTF16( | 471 body = l10n_util::GetStringUTF16( |
| 406 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_BODY); | 472 IDS_CONSUMER_MANAGEMENT_ENROLLMENT_NOTIFICATION_BODY); |
| 407 button_label = l10n_util::GetStringUTF16( | 473 button_label = l10n_util::GetStringUTF16( |
| 408 IDS_CONSUMER_MANAGEMENT_NOTIFICATION_MODIFY_SETTINGS_BUTTON); | 474 IDS_CONSUMER_MANAGEMENT_NOTIFICATION_MODIFY_SETTINGS_BUTTON); |
| 409 button_click_callback = base::Bind( | 475 button_click_callback = base::Bind( |
| 410 &ConsumerManagementService::OpenSettingsPage, | 476 &ConsumerManagementService::OpenSettingsPage, |
| 411 weak_ptr_factory_.GetWeakPtr(), | 477 weak_ptr_factory_.GetWeakPtr(), |
| 412 profile); | 478 profile); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 436 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 502 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 437 kEnrollmentNotificationId), | 503 kEnrollmentNotificationId), |
| 438 base::string16(), // display_source | 504 base::string16(), // display_source |
| 439 base::UTF8ToUTF16(kEnrollmentNotificationId), | 505 base::UTF8ToUTF16(kEnrollmentNotificationId), |
| 440 optional_field, | 506 optional_field, |
| 441 new DesktopNotificationDelegate(kEnrollmentNotificationId, | 507 new DesktopNotificationDelegate(kEnrollmentNotificationId, |
| 442 button_click_callback)); | 508 button_click_callback)); |
| 443 notification.SetSystemPriority(); | 509 notification.SetSystemPriority(); |
| 444 g_browser_process->notification_ui_manager()->Add(notification, profile); | 510 g_browser_process->notification_ui_manager()->Add(notification, profile); |
| 445 | 511 |
| 446 SetEnrollmentState(ENROLLMENT_NONE); | 512 SetEnrollmentStage(ENROLLMENT_STAGE_NONE); |
| 447 } | 513 } |
| 448 | 514 |
| 449 void ConsumerManagementService::OpenSettingsPage(Profile* profile) const { | 515 void ConsumerManagementService::OpenSettingsPage(Profile* profile) const { |
| 450 const GURL url(chrome::kChromeUISettingsURL); | 516 const GURL url(chrome::kChromeUISettingsURL); |
| 451 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); | 517 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); |
| 452 params.disposition = NEW_FOREGROUND_TAB; | 518 params.disposition = NEW_FOREGROUND_TAB; |
| 453 chrome::Navigate(¶ms); | 519 chrome::Navigate(¶ms); |
| 454 } | 520 } |
| 455 | 521 |
| 456 void ConsumerManagementService::TryEnrollmentAgain(Profile* profile) const { | 522 void ConsumerManagementService::TryEnrollmentAgain(Profile* profile) const { |
| 457 const GURL base_url(chrome::kChromeUISettingsURL); | 523 const GURL base_url(chrome::kChromeUISettingsURL); |
| 458 const GURL url = base_url.Resolve(kConsumerManagementOverlay); | 524 const GURL url = base_url.Resolve(kConsumerManagementOverlay); |
| 459 | 525 |
| 460 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); | 526 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK); |
| 461 params.disposition = NEW_FOREGROUND_TAB; | 527 params.disposition = NEW_FOREGROUND_TAB; |
| 462 chrome::Navigate(¶ms); | 528 chrome::Navigate(¶ms); |
| 463 } | 529 } |
| 464 | 530 |
| 531 void ConsumerManagementService::NotifyStatusChanged() { |
| 532 FOR_EACH_OBSERVER(Observer, observers_, OnConsumerManagementStatusChanged()); |
| 533 } |
| 534 |
| 465 } // namespace policy | 535 } // namespace policy |
| OLD | NEW |