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/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // static | 35 // static |
36 bool ManagedMode::IsInManagedMode() { | 36 bool ManagedMode::IsInManagedMode() { |
37 return GetInstance()->IsInManagedModeImpl(); | 37 return GetInstance()->IsInManagedModeImpl(); |
38 } | 38 } |
39 | 39 |
40 bool ManagedMode::IsInManagedModeImpl() { | 40 bool ManagedMode::IsInManagedModeImpl() { |
41 // |g_browser_process| can be NULL during startup. | 41 // |g_browser_process| can be NULL during startup. |
42 if (!g_browser_process) | 42 if (!g_browser_process) |
43 return false; | 43 return false; |
| 44 // Local State can be NULL during unit tests. |
| 45 if (!g_browser_process->local_state()) |
| 46 return false; |
44 return g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode); | 47 return g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode); |
45 } | 48 } |
46 | 49 |
47 // static | 50 // static |
48 void ManagedMode::EnterManagedMode(Profile* profile, | 51 void ManagedMode::EnterManagedMode(Profile* profile, |
49 const EnterCallback& callback) { | 52 const EnterCallback& callback) { |
50 GetInstance()->EnterManagedModeImpl(profile, callback); | 53 GetInstance()->EnterManagedModeImpl(profile, callback); |
51 } | 54 } |
52 | 55 |
53 void ManagedMode::EnterManagedModeImpl(Profile* profile, | 56 void ManagedMode::EnterManagedModeImpl(Profile* profile, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void ManagedMode::SetInManagedMode(bool in_managed_mode) { | 199 void ManagedMode::SetInManagedMode(bool in_managed_mode) { |
197 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, | 200 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, |
198 in_managed_mode); | 201 in_managed_mode); |
199 // This causes the avatar and the profile menu to get updated. | 202 // This causes the avatar and the profile menu to get updated. |
200 content::NotificationService::current()->Notify( | 203 content::NotificationService::current()->Notify( |
201 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 204 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
202 content::NotificationService::AllBrowserContextsAndSources(), | 205 content::NotificationService::AllBrowserContextsAndSources(), |
203 content::NotificationService::NoDetails()); | 206 content::NotificationService::NoDetails()); |
204 } | 207 } |
205 | 208 |
OLD | NEW |