diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-16 21:10:32 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-16 21:10:32 +0000 |
commit | 39032befa48cb47661abfd9ebfa7077eb3647780 (patch) | |
tree | eb419d9a87a50d6ca48b06f1847612b0d371a4a0 /chrome | |
parent | 584703629a429f10bb78af55c335404547a02f46 (diff) | |
download | chromium_src-39032befa48cb47661abfd9ebfa7077eb3647780.zip chromium_src-39032befa48cb47661abfd9ebfa7077eb3647780.tar.gz chromium_src-39032befa48cb47661abfd9ebfa7077eb3647780.tar.bz2 |
Reland: Add mic icon in omnibox to trigger voice search.
This appears only when the underlying page uses the setVoiceSearchSupported() JS
API to indicate it supports voice search.
Originally landed as r211740, backed out in r211753 due to test failure. The
only change from the original is one line each in star-view.cc and
script_bubble_icon_view.cc to call the superclass GetAccessibleState() impl.
BUG=251386
TEST=With instant extended on, browser to a search result page; should see mic icon that, when clicked, activates voice search
Review URL: https://codereview.chromium.org/19388004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
13 files changed, 178 insertions, 83 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index e8aca6c..16d2d0d 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7983,6 +7983,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_TOOLTIP_ACTION_BOX_BUTTON" desc="The tooltip for action box button"> Actions </message> + <message name="IDS_TOOLTIP_MIC_SEARCH" desc="The tooltip for search-by-voice button"> + Voice search + </message> <message name="IDS_TOOLTIP_ZOOM" desc="The tooltip for zoom icon"> Zoom: <ph name="VALUE">$1<ex>100</ex></ph>% </message> @@ -8038,9 +8041,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_ACCNAME_LOCATION" desc="The accessible name for the editable-text portion of the omnibox."> Address and search bar </message> - <message name="IDS_ACCNAME_STAR" desc="The accessible name for the bookmark button."> - Bookmark - </message> <message name="IDS_ACCNAME_ZOOM" desc="The accessible name for the zoom button."> Zoom </message> diff --git a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm index 3cf0dc9..6fcafbc 100644 --- a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm +++ b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm @@ -70,7 +70,8 @@ class ViewIDTest : public InProcessBrowserTest { if (i == VIEW_ID_STAR_BUTTON || i == VIEW_ID_CONTENTS_SPLIT || i == VIEW_ID_FEEDBACK_BUTTON || - i == VIEW_ID_SCRIPT_BUBBLE) { + i == VIEW_ID_SCRIPT_BUBBLE || + i == VIEW_ID_MIC_SEARCH_BUTTON) { continue; } diff --git a/chrome/browser/ui/gtk/view_id_util_browsertest.cc b/chrome/browser/ui/gtk/view_id_util_browsertest.cc index b3f1b03..9e71fcd 100644 --- a/chrome/browser/ui/gtk/view_id_util_browsertest.cc +++ b/chrome/browser/ui/gtk/view_id_util_browsertest.cc @@ -44,7 +44,8 @@ IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) { i == VIEW_ID_BOOKMARK_BAR_ELEMENT || i == VIEW_ID_TAB || i == VIEW_ID_FEEDBACK_BUTTON || - i == VIEW_ID_SCRIPT_BUBBLE) { + i == VIEW_ID_SCRIPT_BUBBLE || + i == VIEW_ID_MIC_SEARCH_BUTTON) { continue; } diff --git a/chrome/browser/ui/view_ids.h b/chrome/browser/ui/view_ids.h index 35dda47..5d792c9 100644 --- a/chrome/browser/ui/view_ids.h +++ b/chrome/browser/ui/view_ids.h @@ -76,7 +76,10 @@ enum ViewID { VIEW_ID_ZOOM_BUTTON, #endif - // Used in chrome/browser/ui/gtk/view_id_util_browsertests.cc + // The omnibox icon to do voice-based search. + VIEW_ID_MIC_SEARCH_BUTTON, + + // Used in chrome/browser/ui/gtk/view_id_util_browsertest.cc // If you add new ids, make sure the above test passes. VIEW_ID_PREDEFINED_COUNT, diff --git a/chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc b/chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc index 1094b7e..ca7270c 100644 --- a/chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc +++ b/chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc @@ -136,35 +136,34 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, // Retrieve accessibility object for non client view and verify accessibility // info. -// http://crbug.com/104132 +// TODO(pkasting): Disabled pending resolution of whether this should be +// ROLE_SYSTEM_CLIENT or ROLE_SYSTEM_WINDOW. IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, DISABLED_TestNonClientViewAccObj) { - views::View* non_client_view = - GetBrowserView()->GetWidget()->non_client_view(); - - TestViewAccessibilityObject(non_client_view, + TestViewAccessibilityObject( + GetBrowserView()->GetWidget()->non_client_view(), UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), ROLE_SYSTEM_WINDOW); } -// Retrieve accessibility object for browser root view and verify -// accessibility info. -// http://crbug.com/104132 +// Retrieve accessibility object for browser root view and verify accessibility +// info. +// TODO(pkasting): Disabled pending resolution of whether this should be +// ROLE_SYSTEM_WINDOW or ROLE_SYSTEM_APPLICATION, as well as what the name +// should be. IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, DISABLED_TestBrowserRootViewAccObj) { - views::View* browser_root_view = GetBrowserView()->frame()->GetRootView(); - TestViewAccessibilityObject( - browser_root_view, + GetBrowserView()->frame()->GetRootView(), UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), ROLE_SYSTEM_APPLICATION); } // Retrieve accessibility object for browser view and verify accessibility info. -// http://crbug.com/104132 +// TODO(pkasting): Disabled pending resolution of whether this object should +// have an accessible name. IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, DISABLED_TestBrowserViewAccObj) { - // Verify root view MSAA name and role. TestViewAccessibilityObject( GetBrowserView(), UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), @@ -172,10 +171,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, } // Retrieve accessibility object for toolbar view and verify accessibility info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestToolbarViewAccObj) { - // Verify toolbar MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestToolbarViewAccObj) { TestViewAccessibilityObject( GetToolbarView(), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR)), @@ -183,10 +179,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, } // Retrieve accessibility object for Back button and verify accessibility info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestBackButtonAccObj) { - // Verify Back button MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestBackButtonAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_BACK_BUTTON), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)), @@ -195,10 +188,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, // Retrieve accessibility object for Forward button and verify accessibility // info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestForwardButtonAccObj) { - // Verify Forward button MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestForwardButtonAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_FORWARD_BUTTON), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)), @@ -207,10 +197,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, // Retrieve accessibility object for Reload button and verify accessibility // info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestReloadButtonAccObj) { - // Verify Reload button MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestReloadButtonAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_RELOAD_BUTTON), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)), @@ -218,10 +205,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, } // Retrieve accessibility object for Home button and verify accessibility info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestHomeButtonAccObj) { - // Verify Home button MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestHomeButtonAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_HOME_BUTTON), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_HOME)), @@ -229,31 +213,35 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, } // Retrieve accessibility object for Star button and verify accessibility info. -// http://crbug.com/104132 -IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestStarButtonAccObj) { - // Verify Star button MSAA name and role. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestStarButtonAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_STAR_BUTTON), - UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_STAR)), + UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_STAR)), ROLE_SYSTEM_PUSHBUTTON); } -// Retrieve accessibility object for App menu button and verify accessibility +// Retrieve accessibility object for Mic search button and verify accessibility // info. -// http://crbug.com/104132 IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestAppMenuAccObj) { - // Verify App menu button MSAA name and role. + TestMicSearchButtonViewAccObj) { + TestViewAccessibilityObject( + GetToolbarView()->GetViewByID(VIEW_ID_MIC_SEARCH_BUTTON), + UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)), + ROLE_SYSTEM_PUSHBUTTON); +} + +// Retrieve accessibility object for App menu button and verify accessibility +// info. +IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestAppMenuAccObj) { TestViewAccessibilityObject( GetToolbarView()->GetViewByID(VIEW_ID_APP_MENU), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)), ROLE_SYSTEM_BUTTONMENU); } -// http://crbug.com/104132 +// Retrieve accessibility object for bookmark bar and verify accessibility info. IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, - DISABLED_TestBookmarkBarViewAccObj) { + TestBookmarkBarViewAccObj) { TestViewAccessibilityObject( GetBookmarkBarView(), UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS)), diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 1caa380c..eaa8e7c 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -45,6 +45,7 @@ #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" #include "chrome/browser/ui/views/location_bar/location_icon_view.h" +#include "chrome/browser/ui/views/location_bar/mic_search_view.h" #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" @@ -180,6 +181,7 @@ LocationBarView::LocationBarView(Browser* browser, selected_keyword_view_(NULL), suggested_text_view_(NULL), keyword_hint_view_(NULL), + mic_search_view_(NULL), zoom_view_(NULL), autofill_credit_card_view_(NULL), open_pdf_in_reader_view_(NULL), @@ -212,11 +214,16 @@ LocationBarView::LocationBarView(Browser* browser, base::Bind(&LocationBarView::Update, base::Unretained(this), static_cast<content::WebContents*>(NULL))); + + if (browser_) + browser_->search_model()->AddObserver(this); } LocationBarView::~LocationBarView() { if (template_url_service_) template_url_service_->RemoveObserver(this); + if (browser_) + browser_->search_model()->RemoveObserver(this); } void LocationBarView::Init() { @@ -304,6 +311,10 @@ void LocationBarView::Init() { background_color); AddChildView(keyword_hint_view_); + mic_search_view_ = new MicSearchView(this); + mic_search_view_->SetVisible(false); + AddChildView(mic_search_view_); + for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { ContentSettingImageView* content_blocked_view = new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, @@ -328,17 +339,12 @@ void LocationBarView::Init() { script_bubble_icon_view_->SetVisible(false); AddChildView(script_bubble_icon_view_); - // The star icon is hidden in popups. - if (browser_defaults::bookmarks_enabled && !is_popup_mode_) { - star_view_ = new StarView(command_updater_); - star_view_->SetVisible(true); - AddChildView(star_view_); - } + star_view_ = new StarView(command_updater_); + star_view_->SetVisible(false); + AddChildView(star_view_); + if (extensions::FeatureSwitch::action_box()->IsEnabled() && !is_popup_mode_ && browser_) { - if (star_view_) - star_view_->SetVisible(false); - action_box_button_view_ = new ActionBoxButtonView( browser_, gfx::Point(GetHorizontalEdgeThickness(), vertical_edge_thickness())); @@ -462,6 +468,9 @@ void LocationBarView::SetAnimationOffset(int offset) { } void LocationBarView::Update(const WebContents* tab_for_state_restoring) { + mic_search_view_->SetVisible( + !model_->GetInputInProgress() && browser_ && + browser_->search_model()->voice_search_supported()); RefreshContentSettingViews(); autofill_credit_card_view_->Update(); ZoomBubbleView::CloseBubble(); @@ -471,8 +480,9 @@ void LocationBarView::Update(const WebContents* tab_for_state_restoring) { open_pdf_in_reader_view_->Update( model_->GetInputInProgress() ? NULL : GetWebContents()); - bool star_enabled = star_view_ && !model_->GetInputInProgress() && - edit_bookmarks_enabled_.GetValue(); + bool star_enabled = + browser_defaults::bookmarks_enabled && !is_popup_mode_ && star_view_ && + !model_->GetInputInProgress() && edit_bookmarks_enabled_.GetValue(); command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, @@ -578,14 +588,12 @@ views::View* LocationBarView::GetPageActionView(ExtensionAction *page_action) { } void LocationBarView::SetStarToggled(bool on) { - if (star_view_) - star_view_->SetToggled(on); - - if (action_box_button_view_) { - if (star_view_ && (star_view_->visible() != on)) { - star_view_->SetVisible(on); - Layout(); - } + if (!star_view_) + return; + star_view_->SetToggled(on); + if (action_box_button_view_ && (star_view_->visible() != on)) { + star_view_->SetVisible(on); + Layout(); } } @@ -783,6 +791,10 @@ void LocationBarView::Layout() { location_height, 0, autofill_credit_card_view_); } + if (mic_search_view_->visible()) { + trailing_decorations.AddDecoration(vertical_edge_thickness(), + location_height, 0, mic_search_view_); + } // Because IMEs may eat the tab key, we don't show "press tab to search" while // IME composition is in progress. if (!keyword.empty() && is_keyword_hint && @@ -1325,6 +1337,12 @@ void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { popup->UpdatePopupAppearance(); } +void LocationBarView::ButtonPressed(views::Button* sender, + const ui::Event& event) { + DCHECK_EQ(mic_search_view_, sender); + command_updater_->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); +} + void LocationBarView::WriteDragDataForView(views::View* sender, const gfx::Point& press_pt, OSExchangeData* data) { @@ -1509,6 +1527,16 @@ void LocationBarView::Observe(int type, } } +void LocationBarView::ModelChanged(const SearchModel::State& old_state, + const SearchModel::State& new_state) { + const bool visible = + !model_->GetInputInProgress() && new_state.voice_search_supported; + if (mic_search_view_->visible() != visible) { + mic_search_view_->SetVisible(visible); + Layout(); + } +} + int LocationBarView::GetInternalHeight(bool use_preferred_size) { int total_height = use_preferred_size ? GetPreferredSize().height() : height(); diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index 93a6fab..2296e8c 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -14,6 +14,7 @@ #include "chrome/browser/search_engines/template_url_service_observer.h" #include "chrome/browser/ui/omnibox/location_bar.h" #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" +#include "chrome/browser/ui/search/search_model_observer.h" #include "chrome/browser/ui/toolbar/toolbar_model.h" #include "chrome/browser/ui/views/dropdown_bar_host.h" #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" @@ -22,6 +23,7 @@ #include "content/public/browser/notification_registrar.h" #include "ui/gfx/font.h" #include "ui/gfx/rect.h" +#include "ui/views/controls/button/button.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/drag_controller.h" @@ -40,6 +42,7 @@ class GURL; class InstantController; class KeywordHintView; class LocationIconView; +class MicSearchView; class OpenPDFInReaderView; class PageActionWithBadgeView; class PageActionImageView; @@ -67,11 +70,13 @@ class Widget; class LocationBarView : public LocationBar, public LocationBarTesting, public views::View, + public views::ButtonListener, public views::DragController, public OmniboxEditController, public DropdownBarHostDelegate, public TemplateURLServiceObserver, - public content::NotificationObserver { + public content::NotificationObserver, + public SearchModelObserver { public: // The location bar view's class name. static const char kViewClassName[]; @@ -269,6 +274,10 @@ class LocationBarView : public LocationBar, virtual bool HasFocus() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + // views::ButtonListener: + virtual void ButtonPressed(views::Button* sender, + const ui::Event& event) OVERRIDE; + // views::DragController: virtual void WriteDragDataForView(View* sender, const gfx::Point& press_pt, @@ -315,6 +324,10 @@ class LocationBarView : public LocationBar, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; + // SearchModelObserver: + virtual void ModelChanged(const SearchModel::State& old_state, + const SearchModel::State& new_state) OVERRIDE; + // Returns the height of the control without the top and bottom // edges(i.e. the height of the edit control inside). If // |use_preferred_size| is true this will be the preferred height, @@ -465,6 +478,9 @@ class LocationBarView : public LocationBar, // Shown if the selected url has a corresponding keyword. KeywordHintView* keyword_hint_view_; + // The voice search icon. + MicSearchView* mic_search_view_; + // The content setting views. ContentSettingViews content_setting_views_; diff --git a/chrome/browser/ui/views/location_bar/mic_search_view.cc b/chrome/browser/ui/views/location_bar/mic_search_view.cc new file mode 100644 index 0000000..31f67d6 --- /dev/null +++ b/chrome/browser/ui/views/location_bar/mic_search_view.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/views/location_bar/mic_search_view.h" + +#include "chrome/browser/ui/view_ids.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" +#include "ui/base/accessibility/accessible_view_state.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" + +MicSearchView::MicSearchView(views::ButtonListener* button_listener) + : views::ImageButton(button_listener) { + set_id(VIEW_ID_MIC_SEARCH_BUTTON); + set_accessibility_focusable(true); + SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); + SetImage(STATE_NORMAL, + ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( + IDR_OMNIBOX_MIC_SEARCH)); + SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); + TouchableLocationBarView::Init(this); +} + +MicSearchView::~MicSearchView() { +} + +int MicSearchView::GetBuiltInHorizontalPadding() const { + return GetBuiltInHorizontalPaddingImpl(); +} diff --git a/chrome/browser/ui/views/location_bar/mic_search_view.h b/chrome/browser/ui/views/location_bar/mic_search_view.h new file mode 100644 index 0000000..30159a7 --- /dev/null +++ b/chrome/browser/ui/views/location_bar/mic_search_view.h @@ -0,0 +1,26 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_MIC_SEARCH_VIEW_H_ +#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_MIC_SEARCH_VIEW_H_ + +#include "chrome/browser/ui/views/location_bar/touchable_location_bar_view.h" +#include "ui/views/controls/button/image_button.h" + +class CommandUpdater; + +class MicSearchView : public views::ImageButton, + public TouchableLocationBarView { + public: + explicit MicSearchView(views::ButtonListener* button_listener); + virtual ~MicSearchView(); + + // TouchableLocationBarView: + virtual int GetBuiltInHorizontalPadding() const OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(MicSearchView); +}; + +#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_MIC_SEARCH_VIEW_H_ diff --git a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc index 0420b9c..92a8411 100644 --- a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc @@ -61,7 +61,7 @@ void ScriptBubbleIconView::Layout() { } void ScriptBubbleIconView::GetAccessibleState(ui::AccessibleViewState* state) { - state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_STAR); + ImageView::GetAccessibleState(state); state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; } diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc index d732432..d07328e 100644 --- a/chrome/browser/ui/views/location_bar/star_view.cc +++ b/chrome/browser/ui/views/location_bar/star_view.cc @@ -30,6 +30,10 @@ StarView::StarView(CommandUpdater* command_updater) StarView::~StarView() { } +int StarView::GetBuiltInHorizontalPadding() const { + return GetBuiltInHorizontalPaddingImpl(); +} + void StarView::SetToggled(bool on) { SetTooltipText(l10n_util::GetStringUTF16( on ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR)); @@ -37,12 +41,8 @@ void StarView::SetToggled(bool on) { on ? IDR_STAR_LIT : IDR_STAR)); } -int StarView::GetBuiltInHorizontalPadding() const { - return GetBuiltInHorizontalPaddingImpl(); -} - void StarView::GetAccessibleState(ui::AccessibleViewState* state) { - state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_STAR); + ImageView::GetAccessibleState(state); state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; } diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h index 6035d4c..bac32f0 100644 --- a/chrome/browser/ui/views/location_bar/star_view.h +++ b/chrome/browser/ui/views/location_bar/star_view.h @@ -10,20 +10,19 @@ class CommandUpdater; -class StarView : public views::ImageView, - public TouchableLocationBarView { +class StarView : public views::ImageView, public TouchableLocationBarView { public: explicit StarView(CommandUpdater* command_updater); virtual ~StarView(); + // TouchableLocationBarView: + virtual int GetBuiltInHorizontalPadding() const OVERRIDE; + // Toggles the star on or off. void SetToggled(bool on); - // TouchableLocationBarView. - virtual int GetBuiltInHorizontalPadding() const OVERRIDE; - private: - // views::ImageView overrides: + // views::ImageView: virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual bool GetTooltipText(const gfx::Point& p, string16* tooltip) const OVERRIDE; @@ -42,7 +41,7 @@ class StarView : public views::ImageView, // prevent the bubble from reshowing. bool suppress_mouse_released_action_; - DISALLOW_IMPLICIT_CONSTRUCTORS(StarView); + DISALLOW_COPY_AND_ASSIGN(StarView); }; #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_STAR_VIEW_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 305e34e..3da4c3e 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1799,6 +1799,8 @@ 'browser/ui/views/location_bar/location_bar_view.h', 'browser/ui/views/location_bar/location_icon_view.cc', 'browser/ui/views/location_bar/location_icon_view.h', + 'browser/ui/views/location_bar/mic_search_view.cc', + 'browser/ui/views/location_bar/mic_search_view.h', 'browser/ui/views/location_bar/open_pdf_in_reader_view.cc', 'browser/ui/views/location_bar/open_pdf_in_reader_view.h', 'browser/ui/views/location_bar/page_action_image_view.cc', |