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

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: Factor out initialization code. 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"
tapted 2013/08/19 00:35:57 as you raised, this would be better under chrome/b
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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
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];
437 [appMenuController_ unregisterEventHandlers];
438 appMenuController_.reset();
436 } 439 }
437 440
438 - (void)didEndMainMessageLoop { 441 - (void)didEndMainMessageLoop {
439 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile], 442 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile],
440 chrome::HOST_DESKTOP_TYPE_NATIVE)); 443 chrome::HOST_DESKTOP_TYPE_NATIVE));
441 if (!chrome::GetBrowserCount([self lastProfile], 444 if (!chrome::GetBrowserCount([self lastProfile],
442 chrome::HOST_DESKTOP_TYPE_NATIVE)) { 445 chrome::HOST_DESKTOP_TYPE_NATIVE)) {
443 // As we're shutting down, we need to nuke the TabRestoreService, which 446 // As we're shutting down, we need to nuke the TabRestoreService, which
444 // will start the shutdown of the NavigationControllers and allow for 447 // 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, 448 // 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 647
645 // This is called after profiles have been loaded and preferences registered. 648 // This is called after profiles have been loaded and preferences registered.
646 // It is safe to access the default profile here. 649 // It is safe to access the default profile here.
647 - (void)applicationDidFinishLaunching:(NSNotification*)notify { 650 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
648 // Notify BrowserList to keep the application running so it doesn't go away 651 // Notify BrowserList to keep the application running so it doesn't go away
649 // when all the browser windows get closed. 652 // when all the browser windows get closed.
650 chrome::StartKeepAlive(); 653 chrome::StartKeepAlive();
651 654
652 [self setUpdateCheckInterval]; 655 [self setUpdateCheckInterval];
653 656
657 // Start managing the menu for app windows. This needs to be done here because
658 // main menu item titles are not yet initialized in awakeFromNib.
659 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppShims))
tapted 2013/08/19 00:35:57 Still a bit nervous about regressions - many who w
jackhou1 2013/08/19 03:47:58 Agreed.
660 appMenuController_.reset([[AppMenuController alloc] init]);
661
654 // Build up the encoding menu, the order of the items differs based on the 662 // Build up the encoding menu, the order of the items differs based on the
655 // current locale (see http://crbug.com/7647 for details). 663 // 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 664 // We need a valid g_browser_process to get the profile which is why we can't
657 // call this from awakeFromNib. 665 // call this from awakeFromNib.
658 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; 666 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu];
659 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; 667 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU];
660 NSMenu* encodingMenu = [encodingMenuItem submenu]; 668 NSMenu* encodingMenu = [encodingMenuItem submenu];
661 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], 669 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
662 encodingMenu); 670 encodingMenu);
663 671
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1428
1421 //--------------------------------------------------------------------------- 1429 //---------------------------------------------------------------------------
1422 1430
1423 namespace app_controller_mac { 1431 namespace app_controller_mac {
1424 1432
1425 bool IsOpeningNewWindow() { 1433 bool IsOpeningNewWindow() {
1426 return g_is_opening_new_window; 1434 return g_is_opening_new_window;
1427 } 1435 }
1428 1436
1429 } // namespace app_controller_mac 1437 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/ui/cocoa/apps/app_menu_controller_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698