OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/managed_mode.h" | 5 #include "chrome/browser/managed_mode.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // TODO(bauerb): Show platform-specific confirmation dialog. | 243 // TODO(bauerb): Show platform-specific confirmation dialog. |
244 return true; | 244 return true; |
245 } | 245 } |
246 | 246 |
247 void ManagedMode::SetInManagedMode(Profile* newly_managed_profile) { | 247 void ManagedMode::SetInManagedMode(Profile* newly_managed_profile) { |
248 // Register the ManagementPolicy::Provider before changing the pref when | 248 // Register the ManagementPolicy::Provider before changing the pref when |
249 // setting it, and unregister it after changing the pref when clearing it, | 249 // setting it, and unregister it after changing the pref when clearing it, |
250 // so pref observers see the correct ManagedMode state. | 250 // so pref observers see the correct ManagedMode state. |
251 if (newly_managed_profile) { | 251 if (newly_managed_profile) { |
252 DCHECK(!managed_profile_ || managed_profile_ == newly_managed_profile); | 252 DCHECK(!managed_profile_ || managed_profile_ == newly_managed_profile); |
253 ExtensionSystem::Get( | 253 extensions::ExtensionSystem::Get( |
254 newly_managed_profile)->management_policy()->RegisterProvider(this); | 254 newly_managed_profile)->management_policy()->RegisterProvider(this); |
255 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, true); | 255 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, true); |
256 } else { | 256 } else { |
257 ExtensionSystem::Get( | 257 extensions::ExtensionSystem::Get( |
258 managed_profile_)->management_policy()->UnregisterProvider(this); | 258 managed_profile_)->management_policy()->UnregisterProvider(this); |
259 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, false); | 259 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, false); |
260 } | 260 } |
261 managed_profile_ = newly_managed_profile; | 261 managed_profile_ = newly_managed_profile; |
262 | 262 |
263 // This causes the avatar and the profile menu to get updated. | 263 // This causes the avatar and the profile menu to get updated. |
264 content::NotificationService::current()->Notify( | 264 content::NotificationService::current()->Notify( |
265 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 265 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
266 content::NotificationService::AllBrowserContextsAndSources(), | 266 content::NotificationService::AllBrowserContextsAndSources(), |
267 content::NotificationService::NoDetails()); | 267 content::NotificationService::NoDetails()); |
268 } | 268 } |
OLD | NEW |