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

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: Fix gypi Created 7 years, 3 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_shim_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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 429
429 // Tell BrowserList not to keep the browser process alive. Once all the 430 // Tell BrowserList not to keep the browser process alive. Once all the
430 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). 431 // browsers get dealloc'd, it will stop the RunLoop and fall back into main().
431 chrome::EndKeepAlive(); 432 chrome::EndKeepAlive();
432 433
433 // Reset all pref watching, as this object outlives the prefs system. 434 // Reset all pref watching, as this object outlives the prefs system.
434 profilePrefRegistrar_.reset(); 435 profilePrefRegistrar_.reset();
435 localPrefRegistrar_.RemoveAll(); 436 localPrefRegistrar_.RemoveAll();
436 437
437 [self unregisterEventHandlers]; 438 [self unregisterEventHandlers];
439
440 appShimMenuController_.reset();
438 } 441 }
439 442
440 - (void)didEndMainMessageLoop { 443 - (void)didEndMainMessageLoop {
441 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile], 444 DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile],
442 chrome::HOST_DESKTOP_TYPE_NATIVE)); 445 chrome::HOST_DESKTOP_TYPE_NATIVE));
443 if (!chrome::GetBrowserCount([self lastProfile], 446 if (!chrome::GetBrowserCount([self lastProfile],
444 chrome::HOST_DESKTOP_TYPE_NATIVE)) { 447 chrome::HOST_DESKTOP_TYPE_NATIVE)) {
445 // As we're shutting down, we need to nuke the TabRestoreService, which 448 // As we're shutting down, we need to nuke the TabRestoreService, which
446 // will start the shutdown of the NavigationControllers and allow for 449 // will start the shutdown of the NavigationControllers and allow for
447 // proper shutdown. If we don't do this, Chrome won't shut down cleanly, 450 // 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
646 649
647 // This is called after profiles have been loaded and preferences registered. 650 // This is called after profiles have been loaded and preferences registered.
648 // It is safe to access the default profile here. 651 // It is safe to access the default profile here.
649 - (void)applicationDidFinishLaunching:(NSNotification*)notify { 652 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
650 // Notify BrowserList to keep the application running so it doesn't go away 653 // Notify BrowserList to keep the application running so it doesn't go away
651 // when all the browser windows get closed. 654 // when all the browser windows get closed.
652 chrome::StartKeepAlive(); 655 chrome::StartKeepAlive();
653 656
654 [self setUpdateCheckInterval]; 657 [self setUpdateCheckInterval];
655 658
659 // Start managing the menu for app windows. This needs to be done here because
660 // main menu item titles are not yet initialized in awakeFromNib.
661 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppShims))
662 appShimMenuController_.reset([[AppShimMenuController alloc] init]);
663
656 // Build up the encoding menu, the order of the items differs based on the 664 // Build up the encoding menu, the order of the items differs based on the
657 // current locale (see http://crbug.com/7647 for details). 665 // current locale (see http://crbug.com/7647 for details).
658 // We need a valid g_browser_process to get the profile which is why we can't 666 // We need a valid g_browser_process to get the profile which is why we can't
659 // call this from awakeFromNib. 667 // call this from awakeFromNib.
660 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu]; 668 NSMenu* viewMenu = [[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] submenu];
661 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU]; 669 NSMenuItem* encodingMenuItem = [viewMenu itemWithTag:IDC_ENCODING_MENU];
662 NSMenu* encodingMenu = [encodingMenuItem submenu]; 670 NSMenu* encodingMenu = [encodingMenuItem submenu];
663 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile], 671 EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
664 encodingMenu); 672 encodingMenu);
665 673
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 1431
1424 //--------------------------------------------------------------------------- 1432 //---------------------------------------------------------------------------
1425 1433
1426 namespace app_controller_mac { 1434 namespace app_controller_mac {
1427 1435
1428 bool IsOpeningNewWindow() { 1436 bool IsOpeningNewWindow() {
1429 return g_is_opening_new_window; 1437 return g_is_opening_new_window;
1430 } 1438 }
1431 1439
1432 } // namespace app_controller_mac 1440 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698