summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-16 04:39:05 +0000
committerjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-16 04:39:05 +0000
commit986722f73cd178705ff514b632b4eed72143c73b (patch)
treec8d6507689bfaae62ae7358effe9c31ca8f53ad7
parentb72828b12489e2b5bac7a974e59e113d7d1f969f (diff)
downloadchromium_src-986722f73cd178705ff514b632b4eed72143c73b.zip
chromium_src-986722f73cd178705ff514b632b4eed72143c73b.tar.gz
chromium_src-986722f73cd178705ff514b632b4eed72143c73b.tar.bz2
Fix up fullscreen exit bubble messages to suggest Esc instead of F11 where appropriate.
Mac: - Show "<link>Exit full screen</link> (Esc)". Since Mac only shows the bubble in tab fullscreen mode, it never needs to display the Cmd-Shift-F shortcut. Win, Linux: - Show "<link>Exit full screen (Esc)</link>". Will change it to match the mac message in a followup CL; this was easier for now. - Show "Press Esc to exit fullscreen" when mouse is locked. - Show "<link>Exit full screen (F11)</link>" when in browser fullscreen mode. BUG=99869 TEST=manual Review URL: http://codereview.chromium.org/8528052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110256 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd14
-rw-r--r--chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm14
-rw-r--r--chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm10
-rw-r--r--chrome/browser/ui/fullscreen_exit_bubble.cc4
-rw-r--r--chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc34
-rw-r--r--chrome/browser/ui/views/fullscreen_exit_bubble_views.cc65
6 files changed, 84 insertions, 57 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index cf4d722..0c127af 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3617,14 +3617,12 @@ are declared in build/common.gypi.
<!-- Fullscreen mode -->
+ <message name="IDS_EXIT_FULLSCREEN_MODE" desc="Clickable message displayed on entering full screen mode. Clicking on the link exits full screen mode.">
+ Exit full screen
+ </message>
<if expr="not pp_ifdef('chromeos')">
- <message name="IDS_EXIT_FULLSCREEN_MODE" desc="Clickable message displayed on entering fullscreen mode to tell users how to return to normal mode">
- Exit full screen (<ph name="ACCELERATOR">$1<ex>F11</ex></ph>)
- </message>
- </if>
- <if expr="pp_ifdef('chromeos')">
- <message name="IDS_EXIT_FULLSCREEN_MODE" desc="Clickable message displayed on entering fullscreen mode to tell users how to return to normal mode (for Chrome OS, which has a dedicated fullscreen key on the top row in the F3 position)">
- Exit full screen
+ <message name="IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR" desc="Accelerator description shown next to a link showing 'Exit full screen' e.g. 'Exit full screen (Esc)', where 'Exit full screen' is a link.">
+ (<ph name="ACCELERATOR">$1<ex>Esc</ex></ph>)
</message>
</if>
@@ -14410,7 +14408,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
This page is hiding your mouse cursor.
</message>
<message name="IDS_FULLSCREEN_PRESS_ESC_TO_EXIT" desc="Text displayed in the bubble to tell users how to return to normal mode">
- Press Esc to exit.
+ Press <ph name="ACCELERATOR">$1<ex>Esc</ex></ph> to exit.
</message>
<message name="IDS_FULLSCREEN_ALLOW" desc="Text in the bubble button that grants permission for a site to enter fullscreen and/or lock the mouse.">
Allow
diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
index 2a0c98e..e495eff 100644
--- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm
@@ -19,10 +19,12 @@
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
#include "grit/generated_resources.h"
+#include "grit/ui_strings.h"
#include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#include "ui/base/models/accelerator_cocoa.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -163,6 +165,7 @@ const float kHideDuration = 0.7;
// Only button-less bubbles auto-hide.
[self hideSoon];
}
+ // TODO(jeremya): show "Press Esc to exit" instead of a link on mouselock.
// Relayout. A bit jumpy, but functional.
[tweaker_ tweakUI:[self window]];
@@ -234,14 +237,16 @@ const float kHideDuration = 0.7;
exitLabelPlaceholder_ = nil; // Now released.
[exitLabel_.get() setDelegate:self];
- NSString *message = l10n_util::GetNSStringF(IDS_EXIT_FULLSCREEN_MODE,
- base::SysNSStringToUTF16([[self class] keyCommandString]));
+ NSString* exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE);
+ NSString* acceleratorText = [@" " stringByAppendingString:
+ l10n_util::GetNSStringF(IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
+ l10n_util::GetStringUTF16(IDS_APP_ESC_KEY))];
NSFont* font = [NSFont systemFontOfSize:
[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
[(HyperlinkTextView*)exitLabel_.get()
- setMessageAndLink:@""
- withLink:message
+ setMessageAndLink:acceleratorText
+ withLink:exitLinkText
atOffset:0
font:font
messageColor:[NSColor blackColor]
@@ -259,6 +264,7 @@ const float kHideDuration = 0.7;
[layoutManager ensureLayoutForTextContainer:textContainer];
NSRect textFrame = [layoutManager usedRectForTextContainer:textContainer];
+ textFrame.size.width = ceil(NSWidth(textFrame));
labelFrame.origin.x += NSWidth(labelFrame) - NSWidth(textFrame);
labelFrame.size = textFrame.size;
[exitLabel_ setFrame:labelFrame];
diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
index 9070011..054f079 100644
--- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
@@ -109,16 +109,6 @@ TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) {
EXPECT_TRUE([controller_ exitLabel]);
}
-TEST_F(FullscreenExitBubbleControllerTest, LabelContainsShortcut) {
- NSString* shortcut = [FullscreenExitBubbleController keyCommandString];
- EXPECT_GT([shortcut length], 0U);
-
- NSString* message = [[[controller_ exitLabel] textStorage] string];
-
- NSRange range = [message rangeOfString:shortcut];
- EXPECT_NE(NSNotFound, range.location);
-}
-
TEST_F(FullscreenExitBubbleControllerTest, ShortcutText) {
ui::AcceleratorCocoa cmd_F(@"F", NSCommandKeyMask);
ui::AcceleratorCocoa cmd_shift_f(@"f", NSCommandKeyMask|NSShiftKeyMask);
diff --git a/chrome/browser/ui/fullscreen_exit_bubble.cc b/chrome/browser/ui/fullscreen_exit_bubble.cc
index e32fca4..fd33364 100644
--- a/chrome/browser/ui/fullscreen_exit_bubble.cc
+++ b/chrome/browser/ui/fullscreen_exit_bubble.cc
@@ -8,6 +8,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
#include "grit/generated_resources.h"
+#include "grit/ui_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/rect.h"
@@ -124,5 +125,6 @@ string16 FullscreenExitBubble::GetAllowButtonText() const {
}
string16 FullscreenExitBubble::GetInstructionText() const {
- return l10n_util::GetStringUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT);
+ return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
+ l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
}
diff --git a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
index e77fc96..81404e8 100644
--- a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
@@ -56,7 +56,22 @@ void FullscreenExitBubbleGtk::UpdateContent(
UTF16ToUTF8(GetCurrentDenyButtonText()).c_str());
gtk_widget_show(deny_button_);
} else {
+ bool link_visible = true;
+ string16 accelerator;
if (bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION) {
+ accelerator = l10n_util::GetStringUTF16(IDS_APP_F11_KEY);
+ } else if (bubble_type == FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION) {
+ accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY);
+ } else {
+ link_visible = false;
+ }
+ if (link_visible) {
+ std::string exit_link_text(
+ l10n_util::GetStringUTF8(IDS_EXIT_FULLSCREEN_MODE) + " " +
+ l10n_util::GetStringFUTF8(IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
+ accelerator));
+ gtk_chrome_link_button_set_label(GTK_CHROME_LINK_BUTTON(link_),
+ exit_link_text.c_str());
gtk_widget_show(link_);
gtk_widget_hide(instruction_label_);
} else {
@@ -73,16 +88,6 @@ void FullscreenExitBubbleGtk::UpdateContent(
}
void FullscreenExitBubbleGtk::InitWidgets() {
- // The exit bubble is a gtk_chrome_link_button inside a gtk event box and gtk
- // alignment (these provide the background color). This is then made rounded
- // and put into a slide widget.
-
- // The Windows code actually looks up the accelerator key in the accelerator
- // table and then converts the key to a string (in a switch statement). This
- // doesn't seem to be implemented for Gtk, so we just use F11 directly.
- std::string exit_text_utf8(l10n_util::GetStringFUTF8(
- IDS_EXIT_FULLSCREEN_MODE, l10n_util::GetStringUTF16(IDS_APP_F11_KEY)));
-
hbox_ = gtk_hbox_new(false, ui::kControlSpacing);
message_label_ = gtk_label_new(GetMessage(url_).c_str());
@@ -100,18 +105,15 @@ void FullscreenExitBubbleGtk::InitWidgets() {
gtk_widget_set_no_show_all(deny_button_, FALSE);
gtk_box_pack_start(GTK_BOX(hbox_), deny_button_, FALSE, FALSE, 0);
- link_ = gtk_chrome_link_button_new(exit_text_utf8.c_str());
+ link_ = gtk_chrome_link_button_new("");
gtk_widget_set_can_focus(link_, FALSE);
gtk_widget_set_no_show_all(link_, FALSE);
gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(link_),
FALSE);
gtk_box_pack_start(GTK_BOX(hbox_), link_, FALSE, FALSE, 0);
- instruction_label_ = gtk_chrome_link_button_new(
- UTF16ToUTF8(GetInstructionText()).c_str());
+ instruction_label_ = gtk_label_new(UTF16ToUTF8(GetInstructionText()).c_str());
gtk_widget_set_no_show_all(instruction_label_, FALSE);
- gtk_chrome_link_button_set_use_gtk_theme(
- GTK_CHROME_LINK_BUTTON(instruction_label_), FALSE);
gtk_box_pack_start(GTK_BOX(hbox_), instruction_label_, FALSE, FALSE, 0);
GtkWidget* bubble = gtk_util::CreateGtkBorderBin(
@@ -137,8 +139,6 @@ void FullscreenExitBubbleGtk::InitWidgets() {
signals_.Connect(container_, "set-floating-position",
G_CALLBACK(OnSetFloatingPositionThunk), this);
signals_.Connect(link_, "clicked", G_CALLBACK(OnLinkClickedThunk), this);
- signals_.Connect(instruction_label_, "clicked",
- G_CALLBACK(OnLinkClickedThunk), this);
signals_.Connect(allow_button_, "clicked",
G_CALLBACK(&OnAllowClickedThunk), this);
signals_.Connect(deny_button_, "clicked",
diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
index 1fe6391..d1006c0 100644
--- a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
+++ b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
@@ -9,6 +9,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/views/bubble/bubble.h"
#include "grit/generated_resources.h"
+#include "grit/ui_strings.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/l10n/l10n_util.h"
@@ -57,10 +58,13 @@ class FullscreenExitBubbleViews::FullscreenExitView
// Clickable hint text for exiting fullscreen mode.
views::Link link_;
+ // Instruction for exiting mouse lock.
+ views::Label mouse_lock_exit_instruction_;
+ // Informational label: 'www.foo.com has gone fullscreen'.
views::Label message_label_;
views::NativeTextButton* accept_button_;
views::NativeTextButton* deny_button_;
- string16 browser_fullscreen_exit_text_;
+ const string16 browser_fullscreen_exit_accelerator_;
};
FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
@@ -70,15 +74,8 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
FullscreenExitBubbleType bubble_type)
: bubble_(bubble),
accept_button_(NULL),
- deny_button_(NULL) {
-#if !defined(OS_CHROMEOS)
- browser_fullscreen_exit_text_ =
- l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE, accelerator);
-#else
- browser_fullscreen_exit_text_ =
- l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE);
-#endif
-
+ deny_button_(NULL),
+ browser_fullscreen_exit_accelerator_(accelerator) {
views::BubbleBorder* bubble_border =
new views::BubbleBorder(views::BubbleBorder::NONE);
bubble_border->set_background_color(Bubble::kBackgroundColor);
@@ -90,9 +87,18 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::MediumFont));
+ mouse_lock_exit_instruction_.set_parent_owned(false);
+ mouse_lock_exit_instruction_.SetText(bubble_->GetInstructionText());
+ mouse_lock_exit_instruction_.SetFont(
+ ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
+
link_.set_parent_owned(false);
link_.set_collapse_when_hidden(false);
link_.set_focusable(false);
+#if defined(OS_CHROMEOS)
+ // On CrOS, the link text doesn't change, since it doesn't show the shortcut.
+ link_.SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE));
+#endif
link_.set_listener(bubble);
link_.SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::MediumFont));
@@ -102,7 +108,9 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
link_.SetBackgroundColor(background()->get_color());
message_label_.SetBackgroundColor(background()->get_color());
+ mouse_lock_exit_instruction_.SetBackgroundColor(background()->get_color());
AddChildView(&message_label_);
+ AddChildView(&mouse_lock_exit_instruction_);
AddChildView(&link_);
accept_button_ = new views::NativeTextButton(
@@ -132,7 +140,9 @@ gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() {
gfx::Size message_size(message_label_.GetPreferredSize());
gfx::Size button_instruction_area;
- if (link_.IsVisible()) {
+ if (mouse_lock_exit_instruction_.IsVisible()) {
+ button_instruction_area = mouse_lock_exit_instruction_.GetPreferredSize();
+ } else if (link_.IsVisible()) {
button_instruction_area = link_.GetPreferredSize();
} else {
gfx::Size accept_size(accept_button_->GetPreferredSize());
@@ -159,16 +169,32 @@ void FullscreenExitBubbleViews::FullscreenExitView::UpdateContent(
message_label_.SetText(bubble_->GetCurrentMessageText());
if (fullscreen_bubble::ShowButtonsForType(bubble_type)) {
link_.SetVisible(false);
+ mouse_lock_exit_instruction_.SetVisible(false);
accept_button_->SetVisible(true);
deny_button_->SetText(bubble_->GetCurrentDenyButtonText());
deny_button_->SetVisible(true);
deny_button_->ClearMaxTextSize();
} else {
- if (bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION)
- link_.SetText(browser_fullscreen_exit_text_);
- else
- link_.SetText(bubble_->GetInstructionText());
- link_.SetVisible(true);
+ bool link_visible = true;
+ string16 accelerator;
+ if (bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION) {
+ accelerator = browser_fullscreen_exit_accelerator_;
+ } else if (bubble_type == FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION) {
+ accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY);
+ } else {
+ link_visible = false;
+ }
+#if !defined(OS_CHROMEOS)
+ if (link_visible) {
+ link_.SetText(
+ l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) +
+ UTF8ToUTF16(" ") +
+ l10n_util::GetStringFUTF16(IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
+ accelerator));
+ }
+#endif
+ link_.SetVisible(link_visible);
+ mouse_lock_exit_instruction_.SetVisible(!link_visible);
accept_button_->SetVisible(false);
deny_button_->SetVisible(false);
}
@@ -186,7 +212,12 @@ void FullscreenExitBubbleViews::FullscreenExitView::Layout() {
message_size.width(), message_size.height());
x += message_size.width() + kMiddlePaddingPx;
- if (link_.IsVisible()) {
+ if (mouse_lock_exit_instruction_.IsVisible()) {
+ gfx::Size instruction_size(mouse_lock_exit_instruction_.GetPreferredSize());
+ mouse_lock_exit_instruction_.SetBounds(
+ x, insets.top() + (inner_height - instruction_size.height()) / 2,
+ instruction_size.width(), instruction_size.height());
+ } else if (link_.IsVisible()) {
gfx::Size link_size(link_.GetPreferredSize());
link_.SetBounds(x, insets.top() + (inner_height - link_size.height()) / 2,
link_size.width(), link_size.height());