Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/managed_mode.cc

Issue 10388239: Make NetworkProfileBubble not use BrowserList::GetLastActive() as much. Instead pass it a profile a… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 SetInManagedMode(true); 90 SetInManagedMode(true);
91 managed_profile_ = NULL; 91 managed_profile_ = NULL;
92 callback.Run(true); 92 callback.Run(true);
93 return; 93 return;
94 } 94 }
95 callbacks_.push_back(callback); 95 callbacks_.push_back(callback);
96 registrar_.Add(this, content::NOTIFICATION_APP_EXITING, 96 registrar_.Add(this, content::NOTIFICATION_APP_EXITING,
97 content::NotificationService::AllSources()); 97 content::NotificationService::AllSources());
98 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, 98 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
99 content::NotificationService::AllSources()); 99 content::NotificationService::AllSources());
100 for (std::set<const Browser*>::const_iterator i = browsers_to_close_.begin(); 100 for (std::set<Browser*>::const_iterator i = browsers_to_close_.begin();
101 i != browsers_to_close_.end(); ++i) { 101 i != browsers_to_close_.end(); ++i) {
102 (*i)->window()->Close(); 102 (*i)->window()->Close();
103 } 103 }
104 } 104 }
105 105
106 // static 106 // static
107 void ManagedMode::LeaveManagedMode() { 107 void ManagedMode::LeaveManagedMode() {
108 GetInstance()->LeaveManagedModeImpl(); 108 GetInstance()->LeaveManagedModeImpl();
109 } 109 }
110 110
111 void ManagedMode::LeaveManagedModeImpl() { 111 void ManagedMode::LeaveManagedModeImpl() {
112 bool confirmed = PlatformConfirmLeave(); 112 bool confirmed = PlatformConfirmLeave();
113 if (confirmed) 113 if (confirmed)
114 SetInManagedMode(false); 114 SetInManagedMode(false);
115 } 115 }
116 116
117 void ManagedMode::OnBrowserAdded(const Browser* browser) { 117 void ManagedMode::OnBrowserAdded(Browser* browser) {
118 // Return early if we don't have any queued callbacks. 118 // Return early if we don't have any queued callbacks.
119 if (callbacks_.empty()) 119 if (callbacks_.empty())
120 return; 120 return;
121 121
122 if (browser->profile()->GetOriginalProfile() != managed_profile_) 122 if (browser->profile()->GetOriginalProfile() != managed_profile_)
123 FinalizeEnter(false); 123 FinalizeEnter(false);
124 } 124 }
125 125
126 void ManagedMode::OnBrowserRemoved(const Browser* browser) { 126 void ManagedMode::OnBrowserRemoved(Browser* browser) {
127 // Return early if we don't have any queued callbacks. 127 // Return early if we don't have any queued callbacks.
128 if (callbacks_.empty()) 128 if (callbacks_.empty())
129 return; 129 return;
130 130
131 if (browser->profile()->GetOriginalProfile() == managed_profile_) { 131 if (browser->profile()->GetOriginalProfile() == managed_profile_) {
132 // Ignore closing browser windows that are in managed mode. 132 // Ignore closing browser windows that are in managed mode.
133 return; 133 return;
134 } 134 }
135 size_t count = browsers_to_close_.erase(browser); 135 size_t count = browsers_to_close_.erase(browser);
136 DCHECK_EQ(1u, count); 136 DCHECK_EQ(1u, count);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void ManagedMode::SetInManagedMode(bool in_managed_mode) { 200 void ManagedMode::SetInManagedMode(bool in_managed_mode) {
201 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, 201 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode,
202 in_managed_mode); 202 in_managed_mode);
203 // This causes the avatar and the profile menu to get updated. 203 // This causes the avatar and the profile menu to get updated.
204 content::NotificationService::current()->Notify( 204 content::NotificationService::current()->Notify(
205 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 205 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
206 content::NotificationService::AllBrowserContextsAndSources(), 206 content::NotificationService::AllBrowserContextsAndSources(),
207 content::NotificationService::NoDetails()); 207 content::NotificationService::NoDetails());
208 } 208 }
209 209
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698