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

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

Issue 22867009: Swap main menu with app-specific menu when app window focused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 7 years, 4 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 "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/shell_window_registry.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "chrome/browser/sync/profile_sync_service.h" 46 #include "chrome/browser/sync/profile_sync_service.h"
47 #include "chrome/browser/sync/sync_ui_util.h" 47 #include "chrome/browser/sync/sync_ui_util.h"
48 #include "chrome/browser/ui/browser.h" 48 #include "chrome/browser/ui/browser.h"
49 #include "chrome/browser/ui/browser_command_controller.h" 49 #include "chrome/browser/ui/browser_command_controller.h"
50 #include "chrome/browser/ui/browser_commands.h" 50 #include "chrome/browser/ui/browser_commands.h"
51 #include "chrome/browser/ui/browser_finder.h" 51 #include "chrome/browser/ui/browser_finder.h"
52 #include "chrome/browser/ui/browser_iterator.h" 52 #include "chrome/browser/ui/browser_iterator.h"
53 #include "chrome/browser/ui/browser_mac.h" 53 #include "chrome/browser/ui/browser_mac.h"
54 #include "chrome/browser/ui/browser_window.h" 54 #include "chrome/browser/ui/browser_window.h"
55 #include "chrome/browser/ui/chrome_pages.h" 55 #include "chrome/browser/ui/chrome_pages.h"
56 #import "chrome/browser/ui/cocoa/apps/app_menu_controller_mac.h"
56 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 57 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
57 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 58 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
58 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 59 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
59 #import "chrome/browser/ui/cocoa/confirm_quit.h" 60 #import "chrome/browser/ui/cocoa/confirm_quit.h"
60 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" 61 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
61 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" 62 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h"
62 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" 63 #import "chrome/browser/ui/cocoa/history_menu_bridge.h"
63 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 64 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
64 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" 65 #import "chrome/browser/ui/cocoa/profile_menu_controller.h"
65 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 66 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 CHECK_EQ(0u, chrome::GetTotalBrowserCount()); 426 CHECK_EQ(0u, chrome::GetTotalBrowserCount());
426 427
427 // Tell BrowserList not to keep the browser process alive. Once all the 428 // Tell BrowserList not to keep the browser process alive. Once all the
428 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). 429 // browsers get dealloc'd, it will stop the RunLoop and fall back into main().
429 chrome::EndKeepAlive(); 430 chrome::EndKeepAlive();
430 431
431 // Reset all pref watching, as this object outlives the prefs system. 432 // Reset all pref watching, as this object outlives the prefs system.
432 profilePrefRegistrar_.reset(); 433 profilePrefRegistrar_.reset();
433 localPrefRegistrar_.RemoveAll(); 434 localPrefRegistrar_.RemoveAll();
434 435
435 [self unregisterEventHandlers]; 436 [self unregisterEventHandlers];
Robert Sesek 2013/08/22 16:22:45 nit: blank line after
jackhou1 2013/08/23 02:36:41 Done.
437 appMenuController_.reset();
436 } 438 }
437 439
438 - (void)didEndMainMessageLoop { 440 - (void)didEndMainMessageLoop {
439 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile], 441 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile],
440 chrome::HOST_DESKTOP_TYPE_NATIVE)); 442 chrome::HOST_DESKTOP_TYPE_NATIVE));
441 if (!chrome::GetBrowserCount([self lastProfile], 443 if (!chrome::GetBrowserCount([self lastProfile],
442 chrome::HOST_DESKTOP_TYPE_NATIVE)) { 444 chrome::HOST_DESKTOP_TYPE_NATIVE)) {
443 // As we're shutting down, we need to nuke the TabRestoreService, which 445 // As we're shutting down, we need to nuke the TabRestoreService, which
444 // will start the shutdown of the NavigationControllers and allow for 446 // will start the shutdown of the NavigationControllers and allow for
445 // proper shutdown. If we don't do this, Chrome won't shut down cleanly, 447 // proper shutdown. If we don't do this, Chrome won't shut down cleanly,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 646
645 // This is called after profiles have been loaded and preferences registered. 647 // This is called after profiles have been loaded and preferences registered.
646 // It is safe to access the default profile here. 648 // It is safe to access the default profile here.
647 - (void)applicationDidFinishLaunching:(NSNotification*)notify { 649 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
648 // Notify BrowserList to keep the application running so it doesn't go away 650 // Notify BrowserList to keep the application running so it doesn't go away
649 // when all the browser windows get closed. 651 // when all the browser windows get closed.
650 chrome::StartKeepAlive(); 652 chrome::StartKeepAlive();
651 653
652 [self setUpdateCheckInterval]; 654 [self setUpdateCheckInterval];
653 655
656 // Start managing the menu for app windows. This needs to be done here because
657 // main menu item titles are not yet initialized in awakeFromNib.
658 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppShims))
659 appMenuController_.reset([[AppMenuController alloc] init]);
660
654 // Build up the encoding menu, the order of the items differs based on the 661 // Build up the encoding menu, the order of the items differs based on the
655 // current locale (see http://crbug.com/7647 for details). 662 // current locale (see http://crbug.com/7647 for details).
656 // We need a valid g_browser_process to get the profile which is why we can't 663 // We need a valid g_browser_process to get the profile which is why we can't
657 // call this from awakeFromNib. 664 // call this from awakeFromNib.
658 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; 665 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu];
659 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; 666 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU];
660 NSMenu* encodingMenu = [encodingMenuItem submenu]; 667 NSMenu* encodingMenu = [encodingMenuItem submenu];
661 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], 668 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
662 encodingMenu); 669 encodingMenu);
663 670
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1427
1421 //--------------------------------------------------------------------------- 1428 //---------------------------------------------------------------------------
1422 1429
1423 namespace app_controller_mac { 1430 namespace app_controller_mac {
1424 1431
1425 bool IsOpeningNewWindow() { 1432 bool IsOpeningNewWindow() {
1426 return g_is_opening_new_window; 1433 return g_is_opening_new_window;
1427 } 1434 }
1428 1435
1429 } // namespace app_controller_mac 1436 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698