diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 15:42:55 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 15:42:55 +0000 |
commit | 4bca7a27e869803a35c71b242519427469b292f6 (patch) | |
tree | 25aed81af687c8666ea45da347dfda8104374ae5 | |
parent | 05a7d775f0205e93e752beec3982b2be592a5050 (diff) | |
download | chromium_src-4bca7a27e869803a35c71b242519427469b292f6.zip chromium_src-4bca7a27e869803a35c71b242519427469b292f6.tar.gz chromium_src-4bca7a27e869803a35c71b242519427469b292f6.tar.bz2 |
Mac: toggle between "Enter/Exit Full Screen" in menus.
BUG=24390
TEST=When *not* fullscreen, menu items (under View in main menu and in app menu) should be "Enter Full Screen"; when fullscreen, they should be "Exit Full Screen"; menu items should still work; keyboard shortcuts should still work.
Review URL: http://codereview.chromium.org/1011002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41726 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 7 | ||||
-rw-r--r-- | chrome/app/nibs/MainMenu.xib | 2 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 10 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.mm | 15 |
5 files changed, 32 insertions, 4 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 2ce438d..fb52c7d 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6651,8 +6651,11 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_RELOAD_IGNORING_CACHE_MENU_MAC" desc="The Mac menu item to force reload the current page (ignoring cache) in the view menu."> Force Reload This Page </message> - <message name="IDS_FULLSCREEN_MAC" desc="The Mac menu item to go into fullscreen mode in the view menu."> - Full Screen + <message name="IDS_ENTER_FULLSCREEN_MAC" desc="The Mac menu item to go into fullscreen mode in the view menu and also in the app menu."> + Enter Full Screen + </message> + <message name="IDS_EXIT_FULLSCREEN_MAC" desc="The Mac menu item to leave fullscreen mode in the view menu and also in the app menu."> + Exit Full Screen </message> <message name="IDS_TEXT_BIGGER_MAC" desc="The Mac menu item to zoom in on the page in the view menu."> Zoom In diff --git a/chrome/app/nibs/MainMenu.xib b/chrome/app/nibs/MainMenu.xib index 712c45b..a088c1b 100644 --- a/chrome/app/nibs/MainMenu.xib +++ b/chrome/app/nibs/MainMenu.xib @@ -729,7 +729,7 @@ </object> <object class="NSMenuItem" id="530225222"> <reference key="NSMenu" ref="466310130"/> - <string key="NSTitle">^IDS_FULLSCREEN_MAC</string> + <string key="NSTitle">^IDS_ENTER_FULLSCREEN_MAC</string> <string key="NSKeyEquiv">F</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index d4cf1309..80ec716 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -21,7 +21,9 @@ class StatusBubble; class TabContents; class TabContentsContainer; class TemplateURL; +#if !defined(OS_MACOSX) class ToolbarView; +#endif struct NativeWebKeyboardEvent; namespace gfx { diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 61fad98..6986885 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -51,6 +51,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -864,9 +865,16 @@ // command updater doesn't know. enable &= browser_->CanRestoreTab(); break; - case IDC_FULLSCREEN: + case IDC_FULLSCREEN: { enable &= [self supportsFullscreen]; + if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { + NSString* menuTitle = l10n_util::GetNSString( + [self isFullscreen] ? IDS_EXIT_FULLSCREEN_MAC : + IDS_ENTER_FULLSCREEN_MAC); + [static_cast<NSMenuItem*>(item) setTitle:menuTitle]; + } break; + } case IDC_SYNC_BOOKMARKS: enable &= ProfileSyncService::IsSyncEnabled(); sync_ui_util::UpdateSyncItem(item, enable, browser_->profile()); diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index 6ea0d2b..cb62cef 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -14,6 +14,7 @@ #include "chrome/browser/app_menu_model.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/browser.h" +#include "chrome/browser/browser_window.h" #include "chrome/browser/bubble_positioner.h" #import "chrome/browser/cocoa/autocomplete_text_field.h" #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" @@ -128,6 +129,20 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { virtual void ExecuteCommand(int command_id) { browser_->ExecuteCommand(command_id); } + virtual bool IsLabelForCommandIdDynamic(int command_id) const { + // On Mac, switch between "Enter Full Screen" and "Exit Full Screen". + return (command_id == IDC_FULLSCREEN); + } + virtual string16 GetLabelForCommandId(int command_id) const { + if (command_id == IDC_FULLSCREEN) { + int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter. + // Note: On startup, |window()| may be NULL. + if (browser_->window() && browser_->window()->IsFullscreen()) + string_id = IDS_EXIT_FULLSCREEN_MAC; + return l10n_util::GetStringUTF16(string_id); + } + return menus::SimpleMenuModel::Delegate::GetLabelForCommandId(command_id); + } private: Browser* browser_; |