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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 12212120: Replace most BrowserList::empty() and BrowserList::size() calls by multi-desktop aware calls. (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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/sessions/session_service_factory.h" 35 #include "chrome/browser/sessions/session_service_factory.h"
36 #include "chrome/browser/sessions/tab_restore_service.h" 36 #include "chrome/browser/sessions/tab_restore_service.h"
37 #include "chrome/browser/sessions/tab_restore_service_factory.h" 37 #include "chrome/browser/sessions/tab_restore_service_factory.h"
38 #include "chrome/browser/sync/profile_sync_service.h" 38 #include "chrome/browser/sync/profile_sync_service.h"
39 #include "chrome/browser/sync/sync_ui_util.h" 39 #include "chrome/browser/sync/sync_ui_util.h"
40 #include "chrome/browser/ui/browser.h" 40 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_command_controller.h" 41 #include "chrome/browser/ui/browser_command_controller.h"
42 #include "chrome/browser/ui/browser_commands.h" 42 #include "chrome/browser/ui/browser_commands.h"
43 #include "chrome/browser/ui/browser_finder.h" 43 #include "chrome/browser/ui/browser_finder.h"
44 #include "chrome/browser/ui/browser_iterator.h" 44 #include "chrome/browser/ui/browser_iterator.h"
45 #include "chrome/browser/ui/browser_list.h"
46 #include "chrome/browser/ui/browser_mac.h" 45 #include "chrome/browser/ui/browser_mac.h"
47 #include "chrome/browser/ui/browser_window.h" 46 #include "chrome/browser/ui/browser_window.h"
48 #include "chrome/browser/ui/chrome_pages.h" 47 #include "chrome/browser/ui/chrome_pages.h"
49 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 48 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
50 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 49 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
51 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 50 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
52 #import "chrome/browser/ui/cocoa/confirm_quit.h" 51 #import "chrome/browser/ui/cocoa/confirm_quit.h"
53 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" 52 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
54 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" 53 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h"
55 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" 54 #import "chrome/browser/ui/cocoa/history_menu_bridge.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave 295 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave
297 // them in, but I'm not sure about UX; we'd also want to disable other things 296 // them in, but I'm not sure about UX; we'd also want to disable other things
298 // though.) http://crbug.com/40861 297 // though.) http://crbug.com/40861
299 298
300 // Check if the user really wants to quit by employing the confirm-to-quit 299 // Check if the user really wants to quit by employing the confirm-to-quit
301 // mechanism. 300 // mechanism.
302 if (!browser_shutdown::IsTryingToQuit() && 301 if (!browser_shutdown::IsTryingToQuit() &&
303 [self applicationShouldTerminate:app] != NSTerminateNow) 302 [self applicationShouldTerminate:app] != NSTerminateNow)
304 return NO; 303 return NO;
305 304
306 size_t num_browsers = BrowserList::size(); 305 size_t num_browsers = chrome::GetTotalBrowserCount();
307 306
308 // Initiate a shutdown (via browser::CloseAllBrowsers()) if we aren't 307 // Initiate a shutdown (via browser::CloseAllBrowsers()) if we aren't
309 // already shutting down. 308 // already shutting down.
310 if (!browser_shutdown::IsTryingToQuit()) { 309 if (!browser_shutdown::IsTryingToQuit()) {
311 content::NotificationService::current()->Notify( 310 content::NotificationService::current()->Notify(
312 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, 311 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
313 content::NotificationService::AllSources(), 312 content::NotificationService::AllSources(),
314 content::NotificationService::NoDetails()); 313 content::NotificationService::NoDetails());
315 browser::CloseAllBrowsers(); 314 browser::CloseAllBrowsers();
316 } 315 }
(...skipping 28 matching lines...) Expand all
345 if (![ConfirmQuitPanelController eventTriggersFeature:[app currentEvent]]) 344 if (![ConfirmQuitPanelController eventTriggersFeature:[app currentEvent]])
346 return NSTerminateNow; 345 return NSTerminateNow;
347 346
348 return [[ConfirmQuitPanelController sharedController] 347 return [[ConfirmQuitPanelController sharedController]
349 runModalLoopForApplication:app]; 348 runModalLoopForApplication:app];
350 } 349 }
351 350
352 // Called when the app is shutting down. Clean-up as appropriate. 351 // Called when the app is shutting down. Clean-up as appropriate.
353 - (void)applicationWillTerminate:(NSNotification*)aNotification { 352 - (void)applicationWillTerminate:(NSNotification*)aNotification {
354 // There better be no browser windows left at this point. 353 // There better be no browser windows left at this point.
355 CHECK_EQ(0u, BrowserList::size()); 354 CHECK_EQ(0u, chrome::GetTotalBrowserCount());
356 355
357 // Tell BrowserList not to keep the browser process alive. Once all the 356 // Tell BrowserList not to keep the browser process alive. Once all the
358 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). 357 // browsers get dealloc'd, it will stop the RunLoop and fall back into main().
359 chrome::EndKeepAlive(); 358 chrome::EndKeepAlive();
360 359
361 [self unregisterEventHandlers]; 360 [self unregisterEventHandlers];
362 } 361 }
363 362
364 - (void)didEndMainMessageLoop { 363 - (void)didEndMainMessageLoop {
365 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile])); 364 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile]));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 afterDelay:0.0]; 474 afterDelay:0.0];
476 } 475 }
477 476
478 // If the window changed to a new BrowserWindowController, update the profile. 477 // If the window changed to a new BrowserWindowController, update the profile.
479 id windowController = [[notify object] windowController]; 478 id windowController = [[notify object] windowController];
480 if ([notify name] == NSWindowDidBecomeMainNotification && 479 if ([notify name] == NSWindowDidBecomeMainNotification &&
481 [windowController isKindOfClass:[BrowserWindowController class]]) { 480 [windowController isKindOfClass:[BrowserWindowController class]]) {
482 // If the profile is incognito, use the original profile. 481 // If the profile is incognito, use the original profile.
483 Profile* newProfile = [windowController profile]->GetOriginalProfile(); 482 Profile* newProfile = [windowController profile]->GetOriginalProfile();
484 [self windowChangedToProfile:newProfile]; 483 [self windowChangedToProfile:newProfile];
485 } else if (BrowserList::empty()) { 484 } else if (chrome::GetTotalBrowserCount() == 0) {
486 [self windowChangedToProfile: 485 [self windowChangedToProfile:
487 g_browser_process->profile_manager()->GetLastUsedProfile()]; 486 g_browser_process->profile_manager()->GetLastUsedProfile()];
488 } 487 }
489 } 488 }
490 489
491 // Called on Lion and later when a popover (e.g. dictionary) is shown. 490 // Called on Lion and later when a popover (e.g. dictionary) is shown.
492 - (void)popoverDidShow:(NSNotification*)notify { 491 - (void)popoverDidShow:(NSNotification*)notify {
493 hasPopover_ = YES; 492 hasPopover_ = YES;
494 [self fixCloseMenuItemKeyEquivalents]; 493 [self fixCloseMenuItemKeyEquivalents];
495 } 494 }
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1346
1348 //--------------------------------------------------------------------------- 1347 //---------------------------------------------------------------------------
1349 1348
1350 namespace app_controller_mac { 1349 namespace app_controller_mac {
1351 1350
1352 bool IsOpeningNewWindow() { 1351 bool IsOpeningNewWindow() {
1353 return g_is_opening_new_window; 1352 return g_is_opening_new_window;
1354 } 1353 }
1355 1354
1356 } // namespace app_controller_mac 1355 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_commands_unittest.cc » ('j') | chrome/browser/ui/cocoa/applescript/window_applescript.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698