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

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

Issue 12114034: Swap BrowserList::const_iterator for the multi-desktop aware BrowserIterator in many scenarios. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/managed_mode.h" 5 #include "chrome/browser/managed_mode/managed_mode.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/public/pref_change_registrar.h" 8 #include "base/prefs/public/pref_change_registrar.h"
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/managed_mode/managed_mode_site_list.h" 11 #include "chrome/browser/managed_mode/managed_mode_site_list.h"
12 #include "chrome/browser/policy/url_blacklist_manager.h" 12 #include "chrome/browser/policy/url_blacklist_manager.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_iterator.h"
16 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/user_metrics.h" 24 #include "content/public/browser/user_metrics.h"
24 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
25 26
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return; 100 return;
100 } 101 }
101 102
102 if (!PlatformConfirmEnter()) { 103 if (!PlatformConfirmEnter()) {
103 callback.Run(false); 104 callback.Run(false);
104 return; 105 return;
105 } 106 }
106 // Close all other profiles. 107 // Close all other profiles.
107 // At this point, we shouldn't be waiting for other browsers to close (yet). 108 // At this point, we shouldn't be waiting for other browsers to close (yet).
108 DCHECK_EQ(0u, browsers_to_close_.size()); 109 DCHECK_EQ(0u, browsers_to_close_.size());
109 for (BrowserList::const_iterator i = BrowserList::begin(); 110 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
110 i != BrowserList::end(); ++i) { 111 if (it->profile()->GetOriginalProfile() != original_profile)
111 if ((*i)->profile()->GetOriginalProfile() != original_profile) 112 browsers_to_close_.insert(*it);
112 browsers_to_close_.insert(*i);
113 } 113 }
114 114
115 if (browsers_to_close_.empty()) { 115 if (browsers_to_close_.empty()) {
116 SetInManagedMode(original_profile); 116 SetInManagedMode(original_profile);
117 callback.Run(true); 117 callback.Run(true);
118 return; 118 return;
119 } 119 }
120 // Remember the profile we're trying to manage while we wait for other 120 // Remember the profile we're trying to manage while we wait for other
121 // browsers to close. 121 // browsers to close.
122 managed_profile_ = original_profile; 122 managed_profile_ = original_profile;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 managed_profile_ = newly_managed_profile; 230 managed_profile_ = newly_managed_profile;
231 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode, 231 g_browser_process->local_state()->SetBoolean(prefs::kInManagedMode,
232 !!newly_managed_profile); 232 !!newly_managed_profile);
233 233
234 // This causes the avatar and the profile menu to get updated. 234 // This causes the avatar and the profile menu to get updated.
235 content::NotificationService::current()->Notify( 235 content::NotificationService::current()->Notify(
236 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 236 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
237 content::NotificationService::AllBrowserContextsAndSources(), 237 content::NotificationService::AllBrowserContextsAndSources(),
238 content::NotificationService::NoDetails()); 238 content::NotificationService::NoDetails());
239 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | chrome/browser/performance_monitor/performance_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698