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 /chrome/browser | |
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
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/accessibility/invert_bubble_views.cc | 82 | ||||
-rw-r--r-- | chrome/browser/accessibility/invert_bubble_views.h | 7 |
2 files changed, 64 insertions, 25 deletions
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); |