diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-06 09:48:34 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-06 09:48:34 +0000 |
commit | 4dde4c672d45c4c01e5e78f8527bcdc1c7ba561d (patch) | |
tree | 0220d1694ffa2a1fc4a4084725d75ed9f5dc8f50 | |
parent | 00e4ebaa46ee1647cb3bc6f13d8f45a0dc805e97 (diff) | |
download | chromium_src-4dde4c672d45c4c01e5e78f8527bcdc1c7ba561d.zip chromium_src-4dde4c672d45c4c01e5e78f8527bcdc1c7ba561d.tar.gz chromium_src-4dde4c672d45c4c01e5e78f8527bcdc1c7ba561d.tar.bz2 |
New Windows high-contrast mode bubble.
When Windows high-contrast mode is on, pop up new bubble with links to a
high-contrast extension, a search for dark themes, a link to Learn More,
and a Close link to close the bubble. Only shows the first time, as before.
The pref is renamed because the previous behavior was reverted, and users
who got the previous bubble on dev/beta should see this one now.
BUG=112944
TEST=manual testing on Windows: Alt+Shift+PrtScr
TBR=ben
Review URL: http://codereview.chromium.org/10332016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135591 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 16 | ||||
-rw-r--r-- | chrome/browser/accessibility/invert_bubble_views.cc | 82 | ||||
-rw-r--r-- | chrome/browser/accessibility/invert_bubble_views.h | 7 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 6 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_impl.cc | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.cc | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.h | 9 | ||||
-rw-r--r-- | ui/gfx/sys_color_change_listener.cc | 15 |
8 files changed, 89 insertions, 62 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f51e28c..3ca48f7 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -16118,10 +16118,18 @@ Battery full </message> </if> - <!-- Inverting for high-constrast mode. --> - <message name="IDS_INVERT_NOTIFICATION" - desc="Text that explains that Chrome has inverted (i.e. reversed black and white) all web pages because the user is using Windows High-Constrast mode with an inverted color scheme."> - Web pages are displayed inverted because you have High Constrast mode enabled and you're using a light-on-dark color scheme. + <!-- High-constrast mode. --> + <message name="IDS_HIGH_CONTRAST_NOTIFICATION" + desc="Text that explains that the user is using Windows High-Constrast mode, so they may be interested in a high-contrast extension or a dark theme. Note to translators: this is the name of a feature in Windows, so please try to find the correct name of that feature in your region."> + You have High Constrast mode enabled. Would you like to install our High Contrast extension and a dark theme? + </message> + <message name="IDS_HIGH_CONTRAST_EXT" + desc="The title of a link that will open the Chrome Web Store with a High Contrast extension the user can install."> + High Contrast Extension + </message> + <message name="IDS_DARK_THEME" + desc="The title of a link that will open the Chrome Web Store with a dark theme the user might want to install, if they prefer light text on a dark background."> + Dark Theme </message> <message name="IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_NAME" desc="Name of about:flag option to turn on ClientOAuth sign in"> diff --git a/chrome/browser/accessibility/invert_bubble_views.cc b/chrome/browser/accessibility/invert_bubble_views.cc index b313d26..4c3f298 100644 --- a/chrome/browser/accessibility/invert_bubble_views.cc +++ b/chrome/browser/accessibility/invert_bubble_views.cc @@ -15,7 +15,6 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/sys_color_change_listener.h" #include "ui/views/bubble/bubble_delegate.h" -#include "ui/views/controls/button/button.h" #include "ui/views/controls/label.h" #include "ui/views/controls/link.h" #include "ui/views/controls/link_listener.h" @@ -23,6 +22,8 @@ #include "ui/views/layout/layout_constants.h" namespace { +const char kHighContrastExtensionUrl[] = "https://chrome.google.com/webstore/detail/djcfdncoelnlbldjfhinnjlhdjlikmph"; +const char kDarkThemeSearchUrl[] = "https://chrome.google.com/webstore/search-themes/dark"; const char kLearnMoreUrl[] = "https://groups.google.com/a/googleproductforums.com/d/topic/chrome/Xrco2HsXS-8/discussion"; const int kBubbleWidth = 500; } // namespace @@ -33,48 +34,81 @@ class InvertBubbleView : public views::BubbleDelegateView, InvertBubbleView(Profile* profile, views::View* anchor_view); virtual ~InvertBubbleView(); - // views::BubbleDelegateView overrides: - virtual gfx::Rect GetAnchorRect() OVERRIDE; - protected: // views::BubbleDelegateView overrides: virtual void Init() OVERRIDE; + // views::BubbleDelegateView overrides: + virtual gfx::Rect GetAnchorRect() OVERRIDE; + // views::LinkListener overrides: virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; + void OpenLink(const std::string& url, int event_flags); + Profile* profile_; + views::Link* high_contrast_; + views::Link* dark_theme_; + views::Link* learn_more_; + views::Link* close_; DISALLOW_COPY_AND_ASSIGN(InvertBubbleView); }; +InvertBubbleView::InvertBubbleView(Profile* profile, views::View* anchor_view) + : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), + profile_(profile) { +} + +InvertBubbleView::~InvertBubbleView() { +} + void InvertBubbleView::Init() { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); const gfx::Font& original_font = rb.GetFont(ResourceBundle::MediumFont); views::Label* title = new views::Label( - l10n_util::GetStringUTF16(IDS_INVERT_NOTIFICATION)); + l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_NOTIFICATION)); title->SetFont(original_font.DeriveFont(2, gfx::Font::BOLD)); title->SetMultiLine(true); title->SizeToFit(kBubbleWidth); - views::Link* learn_more = - new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); - learn_more->SetFont(original_font); - learn_more->set_listener(this); + learn_more_ = new views::Link(l10n_util::GetStringUTF16(IDS_LEARN_MORE)); + learn_more_->SetFont(original_font); + learn_more_->set_listener(this); + + high_contrast_ = + new views::Link(l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_EXT)); + high_contrast_->SetFont(original_font); + high_contrast_->set_listener(this); + + dark_theme_ = + new views::Link(l10n_util::GetStringUTF16(IDS_DARK_THEME)); + dark_theme_->SetFont(original_font); + dark_theme_->set_listener(this); + + close_ = new views::Link(l10n_util::GetStringUTF16(IDS_CLOSE)); + close_->SetFont(original_font); + close_->set_listener(this); views::GridLayout* layout = views::GridLayout::CreatePanel(this); SetLayoutManager(layout); views::ColumnSet* columns = layout->AddColumnSet(0); - columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, - views::GridLayout::USE_PREF, 0, 0); + for (int i = 0; i < 4; i++) { + columns->AddColumn(views::GridLayout::LEADING, + views::GridLayout::LEADING, 0, + views::GridLayout::USE_PREF, 0, 0); + } layout->StartRow(0, 0); - layout->AddView(title); + layout->AddView(title, 4, 1); layout->StartRowWithPadding(0, 0, 0, views::kRelatedControlSmallVerticalSpacing); - layout->AddView(learn_more); + layout->AddView(high_contrast_); + layout->AddView(dark_theme_); + layout->AddView(learn_more_); + layout->AddView(close_); // Switching to high-contrast mode has a nasty habit of causing Chrome // top-level windows to lose focus, so closing the bubble on deactivate @@ -93,26 +127,30 @@ gfx::Rect InvertBubbleView::GetAnchorRect() { return rect; } -InvertBubbleView::InvertBubbleView(Profile* profile, views::View* anchor_view) - : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), - profile_(profile) { -} - -InvertBubbleView::~InvertBubbleView() { +void InvertBubbleView::LinkClicked(views::Link* source, int event_flags) { + if (source == high_contrast_) + OpenLink(kHighContrastExtensionUrl, event_flags); + else if (source == dark_theme_) + OpenLink(kDarkThemeSearchUrl, event_flags); + else if (source == learn_more_) + OpenLink(kLearnMoreUrl, event_flags); + else if (source == close_) + GetWidget()->Close(); + else + NOTREACHED(); } -void InvertBubbleView::LinkClicked(views::Link* source, int event_flags) { +void InvertBubbleView::OpenLink(const std::string& url, int event_flags) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); if (browser) { WindowOpenDisposition disposition = event_utils::DispositionFromEventFlags(event_flags); content::OpenURLParams params( - GURL(kLearnMoreUrl), content::Referrer(), + GURL(url), content::Referrer(), disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK, false); browser->OpenURL(params); } - GetWidget()->Close(); } // static diff --git a/chrome/browser/accessibility/invert_bubble_views.h b/chrome/browser/accessibility/invert_bubble_views.h index d38740c..334970b 100644 --- a/chrome/browser/accessibility/invert_bubble_views.h +++ b/chrome/browser/accessibility/invert_bubble_views.h @@ -16,9 +16,10 @@ class InvertBubble { public: static void RegisterUserPrefs(PrefService* prefs); - // Show a bubble telling the user that web contents are inverted because - // they're using Windows high-constrast mode and their color scheme is - // light-on-dark. Only shows the first time we encounter this condition + // Show a bubble telling the user that they're using Windows + // high-constrast mode with a light-on-dark scheme, so they may be + // interested in a high-contrast Chrome extension and a dark theme. + // Only shows the first time we encounter this condition // for a particular profile. static void MaybeShowInvertBubble(Profile* profile, views::View* anchor_view); diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 7b77cc0..84f0ab7 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -959,9 +959,9 @@ const char kPasswordsUseLocalProfileId[] = const char kProfileAvatarIndex[] = "profile.avatar_index"; const char kProfileName[] = "profile.name"; -// Indicates if we've already shown a notification that web contents are -// inverted because high-contrast mode is on. -const char kInvertNotificationShown[] = "invert_notification_shown"; +// Indicates if we've already shown a notification that high contrast +// mode is on, recommending high-contrast extensions and themes. +const char kInvertNotificationShown[] = "invert_notification_version_2_shown"; // *************** LOCAL STATE *************** // These are attached to the machine/installation diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 860398a..2e38aa2 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -64,7 +64,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFactory.h" #endif #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/sys_color_change_listener.h" #include "webkit/fileapi/isolated_context.h" #include "webkit/glue/webaccessibility.h" #include "webkit/glue/webdropdata.h" @@ -279,10 +278,8 @@ bool RenderViewHostImpl::CreateRenderView(const string16& frame_name, // Let our delegate know that we created a RenderView. delegate_->RenderViewCreated(this); - // Invert the color scheme if the operating system's color scheme is - // inverted or if a flag is set. - if (gfx::IsInvertedColorScheme() || - CommandLine::ForCurrentProcess()->HasSwitch( + // Invert the color scheme if a flag is set. + if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kInvertWebContent)) Send(new ViewMsg_InvertWebContent(GetRoutingID(), true)); diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index e4796c8..5cd8d27 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -332,8 +332,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) pointer_down_context_(false), focus_on_editable_field_(false), received_focus_change_after_pointer_down_(false), - touch_events_enabled_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(sys_color_change_listener_(this)) { + touch_events_enabled_(false) { render_widget_host_->SetView(this); registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, @@ -1343,12 +1342,6 @@ void RenderWidgetHostViewWin::OnThemeChanged() { render_widget_host_->GetRoutingID())); } -void RenderWidgetHostViewWin::OnSysColorChange() { - render_widget_host_->Send(new ViewMsg_InvertWebContent( - render_widget_host_->GetRoutingID(), - gfx::IsInvertedColorScheme())); -} - LRESULT RenderWidgetHostViewWin::OnNotify(int w_param, NMHDR* header) { if (tooltip_hwnd_ == NULL) return 0; diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 2ce5357..eb70601 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -27,7 +27,6 @@ #include "ui/base/win/ime_input.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/point.h" -#include "ui/gfx/sys_color_change_listener.h" #include "ui/surface/accelerated_surface_win.h" #include "webkit/glue/webcursor.h" @@ -93,8 +92,7 @@ class RenderWidgetHostViewWin RenderWidgetHostHWNDTraits>, public content::RenderWidgetHostViewBase, public content::NotificationObserver, - public BrowserAccessibilityDelegate, - public gfx::SysColorChangeListener { + public BrowserAccessibilityDelegate { public: virtual ~RenderWidgetHostViewWin(); @@ -245,9 +243,6 @@ class RenderWidgetHostViewWin virtual void AccessibilitySetTextSelection( int acc_obj_id, int start_offset, int end_offset) OVERRIDE; - // Implementation of SysColorChangeListener: - virtual void OnSysColorChange() OVERRIDE; - protected: friend class content::RenderWidgetHostView; @@ -575,8 +570,6 @@ class RenderWidgetHostViewWin // Are touch events currently enabled? bool touch_events_enabled_; - gfx::ScopedSysColorChangeListener sys_color_change_listener_; - DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin); }; diff --git a/ui/gfx/sys_color_change_listener.cc b/ui/gfx/sys_color_change_listener.cc index 8a6f43b..7a9fc84 100644 --- a/ui/gfx/sys_color_change_listener.cc +++ b/ui/gfx/sys_color_change_listener.cc @@ -25,19 +25,16 @@ bool g_is_inverted_color_scheme_initialized = false; void UpdateInvertedColorScheme() { #if defined(OS_WIN) - int foreground = color_utils::GetLuminanceForColor( + int foreground_luminance = color_utils::GetLuminanceForColor( color_utils::GetSysSkColor(COLOR_WINDOWTEXT)); - int background = color_utils::GetLuminanceForColor( + int background_luminance = color_utils::GetLuminanceForColor( color_utils::GetSysSkColor(COLOR_WINDOW)); HIGHCONTRAST high_contrast = {0}; high_contrast.cbSize = sizeof(HIGHCONTRAST); - - // TODO(dmazzoni): this is temporarily disabled until the color inverting - // can be made optional or the need is addressed some other way. - // http://crbug.com/112944 - //g_is_inverted_color_scheme = - // SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &high_contrast, 0) && - // ((high_contrast.dwFlags & HCF_HIGHCONTRASTON) != 0); + g_is_inverted_color_scheme = + SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &high_contrast, 0) && + ((high_contrast.dwFlags & HCF_HIGHCONTRASTON) != 0) && + foreground_luminance > background_luminance; g_is_inverted_color_scheme_initialized = true; #endif } |