diff options
author | groby <groby@chromium.org> | 2015-02-13 14:02:27 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-13 22:02:48 +0000 |
commit | dcf300ae062ae29c02bba5b0559d006b24814867 (patch) | |
tree | d3be9f201ea9bc3f6924eaa9f7bf50298e144848 | |
parent | c62490491303cf2650bc3b44c2a4c630ed615831 (diff) | |
download | chromium_src-dcf300ae062ae29c02bba5b0559d006b24814867.zip chromium_src-dcf300ae062ae29c02bba5b0559d006b24814867.tar.gz chromium_src-dcf300ae062ae29c02bba5b0559d006b24814867.tar.bz2 |
Remove SearchButton.
As our old friend OriginChip, so the SearchButton too has to bid adieu.
She served well, and we shall miss her.
BUG=424751
Review URL: https://codereview.chromium.org/749693005
Cr-Commit-Position: refs/heads/master@{#316302}
18 files changed, 16 insertions, 435 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 24038ed..4693f54 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6699,21 +6699,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_ENABLE_ENHANCED_BOOKMARKS_DESCRIPTION" desc="Description of about:flags option to enable Enhanced Bookmarks extension."> Provides an off switch for enhanced bookmarks experiment </message> - <message name="IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_NAME" desc="Name of about:flags option to enable the search button in omnibox experiment."> - Enable search button in Omnibox - </message> - <message name="IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_DESCRIPTION" desc="Description of about:flags option to enable the search button in omnibox experiment."> - Places a search button in the Omnibox. - </message> - <message name="IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLE_FOR_STR" desc="Option in a drop-down menu to enable the display of the search button in the omnibox on search result pages."> - Enabled on search result pages - </message> - <message name="IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLE_FOR_STR_OR_IIP" desc="Option in a drop-down menu to enable the display of the search button in the omnibox on search result pages or whenever input is in progress."> - Enabled on search result pages or when input in progress - </message> - <message name="IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLED" desc="Option in a drop-down menu to enable the display of the search button at all times (on all pages)."> - Enabled on all pages - </message> <message name="IDS_FLAGS_ENABLE_PERMISSIONS_BUBBLES_NAME" desc="Title for the flag to enable showing permissions requests in bubbles."> Use Bubbles for Permission Requests </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 52bf390..9010c1c 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -324,23 +324,6 @@ const Experiment::Choice kMemoryPressureThresholdChoices[] = { }; #endif -// We're using independent flags here (as opposed to a common flag with -// different values) to be able to enable/disable the entire experience -// associated with this feature server-side from the FieldTrial (the complete -// experience includes other flag changes as well). It is not currently possible -// to do that with "flag=value" flags. -const Experiment::Choice kSearchButtonInOmniboxChoices[] = { - { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, - { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, - switches::kDisableSearchButtonInOmnibox, ""}, - { IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLE_FOR_STR, - switches::kEnableSearchButtonInOmniboxForStr, ""}, - { IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLE_FOR_STR_OR_IIP, - switches::kEnableSearchButtonInOmniboxForStrOrIip, ""}, - { IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_ENABLED, - switches::kEnableSearchButtonInOmniboxAlways, ""} -}; - const Experiment::Choice kExtensionContentVerificationChoices[] = { { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_BOOTSTRAP, @@ -1692,13 +1675,6 @@ const Experiment kExperiments[] = { MULTI_VALUE_TYPE(kNumRasterThreadsChoices) }, { - "search-button-in-omnibox", - IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_NAME, - IDS_FLAGS_SEARCH_BUTTON_IN_OMNIBOX_DESCRIPTION, - kOsCrOS | kOsMac | kOsWin | kOsLinux, - MULTI_VALUE_TYPE(kSearchButtonInOmniboxChoices) - }, - { "ignore-autocomplete-off-autofill", IDS_FLAGS_IGNORE_AUTOCOMPLETE_OFF_AUTOFILL_NAME, IDS_FLAGS_IGNORE_AUTOCOMPLETE_OFF_AUTOFILL_DESCRIPTION, diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc index 28c7a7b..21254bc 100644 --- a/chrome/browser/search/search.cc +++ b/chrome/browser/search/search.cc @@ -65,7 +65,6 @@ const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; const char kAltInstantURLPath[] = "search"; const char kAltInstantURLQueryParams[] = "&qbp=1"; -const char kDisplaySearchButtonFlagName[] = "display_search_button"; #if !defined(OS_IOS) && !defined(OS_ANDROID) const char kEnableQueryExtractionFlagName[] = "query_extraction"; #endif @@ -581,27 +580,6 @@ GURL GetLocalInstantURL(Profile* profile) { return GURL(chrome::kChromeSearchLocalNtpUrl); } -DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { - const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); - if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) - return DISPLAY_SEARCH_BUTTON_NEVER; - if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) - return DISPLAY_SEARCH_BUTTON_FOR_STR; - if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) - return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; - if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) - return DISPLAY_SEARCH_BUTTON_ALWAYS; - - FieldTrialFlags flags; - if (!GetFieldTrialInfo(&flags)) - return DISPLAY_SEARCH_BUTTON_NEVER; - uint64 value = - GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags); - return (value < DISPLAY_SEARCH_BUTTON_NUM_VALUES) ? - static_cast<DisplaySearchButtonConditions>(value) : - DISPLAY_SEARCH_BUTTON_NEVER; -} - bool ShouldShowGoogleLocalNTP() { FieldTrialFlags flags; return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( diff --git a/chrome/browser/search/search.h b/chrome/browser/search/search.h index a106f20..1605f6d 100644 --- a/chrome/browser/search/search.h +++ b/chrome/browser/search/search.h @@ -47,14 +47,6 @@ enum OptInState { INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT, }; -enum DisplaySearchButtonConditions { - DISPLAY_SEARCH_BUTTON_NEVER, - DISPLAY_SEARCH_BUTTON_FOR_STR, // STR = Search Term Replacement - DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP, // IIP = Input In Progress - DISPLAY_SEARCH_BUTTON_ALWAYS, - DISPLAY_SEARCH_BUTTON_NUM_VALUES, -}; - // Use this value for "start margin" to prevent the "es_sm" parameter from // being used. extern const int kDisableStartMargin; @@ -178,12 +170,6 @@ bool ShouldReuseInstantSearchBasePage(); // TODO(kmadhusu): Remove this function and update the call sites. GURL GetLocalInstantURL(Profile* profile); -// Returns when we should show a search button in the omnibox. This may be any -// of several values, some of which depend on whether the underlying state of -// the page would normally be to perform search term replacement; see also -// ToolbarModel::WouldPerformSearchTermReplacement(). -DisplaySearchButtonConditions GetDisplaySearchButtonConditions(); - // Returns true if the local new tab page should show a Google logo and search // box for users whose default search provider is Google, or false if not. bool ShouldShowGoogleLocalNTP(); diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc index a8710dc..0307b3c 100644 --- a/chrome/browser/search/search_unittest.cc +++ b/chrome/browser/search/search_unittest.cc @@ -876,74 +876,4 @@ TEST_F(IsQueryExtractionEnabledTest, EnabledViaCommandLine) { EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); } -typedef SearchTest DisplaySearchButtonTest; - -TEST_F(DisplaySearchButtonTest, NotSet) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, Never) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:0")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, CommandLineNever) { - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kDisableSearchButtonInOmnibox); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); - - // Command-line disable should override the field trial. - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:1")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, ForSearchTermReplacement) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:1")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, CommandLineForSearchTermReplacement) { - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableSearchButtonInOmniboxForStr); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, ForSearchTermReplacementOrInputInProgress) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:2")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP, - GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, - CommandLineForSearchTermReplacementOrInputInProgress) { - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableSearchButtonInOmniboxForStrOrIip); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP, - GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, Always) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:3")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, CommandLineAlways) { - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableSearchButtonInOmniboxAlways); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); -} - -TEST_F(DisplaySearchButtonTest, InvalidValue) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); - EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); -} - } // namespace chrome diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm index b95d675..6d13801 100644 --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm @@ -41,13 +41,15 @@ class MockDecoration : public LocationBarDecoration { class MockButtonDecoration : public ButtonDecoration { public: + // Note: It does not matter which images are used here - but ButtonDecoration + // needs _some_ images to work properly. MockButtonDecoration() - : ButtonDecoration(IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, + : ButtonDecoration(IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE), + IDR_OMNIBOX_EV_BUBBLE_CENTER, + IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE), + IDR_OMNIBOX_EV_BUBBLE_CENTER, + IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE), + IDR_OMNIBOX_EV_BUBBLE_CENTER, 3) {} void Hide() { SetVisible(false); } MOCK_METHOD2(OnMousePressed, bool(NSRect frame, NSPoint location)); diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h index b2d170b..53c5914 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h @@ -33,7 +33,6 @@ class ManagePasswordsDecoration; class MicSearchDecoration; class PageActionDecoration; class Profile; -class SearchButtonDecoration; class SelectedKeywordDecoration; class StarDecoration; class TranslateDecoration; @@ -264,9 +263,6 @@ class LocationBarViewMac : public LocationBar, // Generated CC hint decoration. scoped_ptr<GeneratedCreditCardDecoration> generated_credit_card_decoration_; - // The right-hand-side search button that is shown on search result pages. - scoped_ptr<SearchButtonDecoration> search_button_decoration_; - // The right-hand-side button to manage passwords associated with a page. scoped_ptr<ManagePasswordsDecoration> manage_passwords_decoration_; diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm index 608ec33..00a8c05 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm @@ -43,7 +43,6 @@ #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" -#import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" @@ -113,7 +112,6 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, mic_search_decoration_(new MicSearchDecoration(command_updater)), generated_credit_card_decoration_( new GeneratedCreditCardDecoration(this)), - search_button_decoration_(new SearchButtonDecoration(this)), manage_passwords_decoration_( new ManagePasswordsDecoration(command_updater, this)), browser_(browser), @@ -397,7 +395,6 @@ void LocationBarViewMac::Layout() { [cell addLeftDecoration:location_icon_decoration_.get()]; [cell addLeftDecoration:selected_keyword_decoration_.get()]; [cell addLeftDecoration:ev_bubble_decoration_.get()]; - [cell addRightDecoration:search_button_decoration_.get()]; [cell addRightDecoration:star_decoration_.get()]; [cell addRightDecoration:translate_decoration_.get()]; [cell addRightDecoration:zoom_decoration_.get()]; @@ -542,22 +539,6 @@ void LocationBarViewMac::OnChanged() { NSImage* image = OmniboxViewMac::ImageForResource(resource_id); location_icon_decoration_->SetImage(image); ev_bubble_decoration_->SetImage(image); - - ToolbarModel* toolbar_model = GetToolbarModel(); - const chrome::DisplaySearchButtonConditions conditions = - chrome::GetDisplaySearchButtonConditions(); - const bool meets_conditions = - (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) || - ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && - (toolbar_model->WouldPerformSearchTermReplacement(true) || - ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && - toolbar_model->input_in_progress()))); - search_button_decoration_->SetVisible( - ![[field_ cell] isPopupMode] && meets_conditions); - search_button_decoration_->SetIcon( - (resource_id == IDR_OMNIBOX_SEARCH) ? - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW); - Layout(); InstantService* instant_service = diff --git a/chrome/browser/ui/cocoa/location_bar/search_button_decoration.h b/chrome/browser/ui/cocoa/location_bar/search_button_decoration.h deleted file mode 100644 index c6dc1f3..0000000 --- a/chrome/browser/ui/cocoa/location_bar/search_button_decoration.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 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_COCOA_LOCATION_BAR_SEARCH_BUTTON_DECORATION_H_ -#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SEARCH_BUTTON_DECORATION_H_ - -#import <Cocoa/Cocoa.h> - -#include "chrome/browser/ui/cocoa/location_bar/button_decoration.h" - -class LocationBarViewMac; - -// |SearchButtonDecoration| adds a search/go button to the right of the omnibox. - -class SearchButtonDecoration : public ButtonDecoration { - public: - explicit SearchButtonDecoration(LocationBarViewMac* owner); - ~SearchButtonDecoration() override; - - // Implement |LocationBarDecoration|. - CGFloat GetWidthForSpace(CGFloat width) override; - void DrawInFrame(NSRect frame, NSView* control_view) override; - bool OnMousePressed(NSRect frame, NSPoint location) override; - - private: - // The control view that owns this. Weak. - LocationBarViewMac* owner_; - - DISALLOW_COPY_AND_ASSIGN(SearchButtonDecoration); -}; - -#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SEARCH_BUTTON_DECORATION_H_ diff --git a/chrome/browser/ui/cocoa/location_bar/search_button_decoration.mm b/chrome/browser/ui/cocoa/location_bar/search_button_decoration.mm deleted file mode 100644 index 18785c2..0000000 --- a/chrome/browser/ui/cocoa/location_bar/search_button_decoration.mm +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 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. - -#import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" - -#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" -#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" -#include "grit/theme_resources.h" - -namespace { - -const CGFloat kInnerPadding = 16; -const CGFloat kLeftPadding = 3; - -} // namespace - -SearchButtonDecoration::SearchButtonDecoration(LocationBarViewMac* owner) - : ButtonDecoration(IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED), - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE, - kInnerPadding), - owner_(owner) { - DCHECK(owner_); -} - -SearchButtonDecoration::~SearchButtonDecoration() { -} - -CGFloat SearchButtonDecoration::GetWidthForSpace(CGFloat width) { - CGFloat width_for_space = ButtonDecoration::GetWidthForSpace(width); - if (width_for_space == kOmittedWidth || - width_for_space + kLeftPadding > width) - return kOmittedWidth; - return width_for_space + kLeftPadding; -} - -void SearchButtonDecoration::DrawInFrame(NSRect frame, NSView* control_view) { - frame = NSMakeRect(NSMinX(frame) + kLeftPadding, - NSMinY(frame), - NSWidth(frame) - kLeftPadding, - NSHeight(frame)); - ButtonDecoration::DrawInFrame(frame, control_view); -} - -bool SearchButtonDecoration::OnMousePressed(NSRect frame, NSPoint location) { - owner_->GetOmniboxView()->model()->AcceptInput( - owner_->GetWindowOpenDisposition(), false); - return true; -} diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc index aca7450..08b863d 100644 --- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc +++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc @@ -257,13 +257,8 @@ ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( } int ToolbarModelImpl::GetIcon() const { - if (WouldPerformSearchTermReplacement(false)) { - // The secured version of the search icon is necessary if the search button - // is not present to indicate the security state. - return (chrome::GetDisplaySearchButtonConditions() == - chrome::DISPLAY_SEARCH_BUTTON_NEVER) ? - IDR_OMNIBOX_SEARCH_SECURED : IDR_OMNIBOX_SEARCH; - } + if (WouldPerformSearchTermReplacement(false)) + return IDR_OMNIBOX_SEARCH_SECURED; return GetIconForSecurityLevel(GetSecurityLevel(false)); } 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 d1bb6d7..120fd0b 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -48,7 +48,6 @@ #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" -#include "chrome/browser/ui/views/location_bar/search_button.h" #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" #include "chrome/browser/ui/views/location_bar/star_view.h" #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" @@ -102,11 +101,6 @@ using views::View; namespace { -// The search button images are made to look as if they overlay the normal edge -// images, but to align things, the search button needs to be inset horizontally -// by 1 px. -const int kSearchButtonInset = 1; - int GetEditLeadingInternalSpace() { // The textfield has 1 px of whitespace before the text in the RTL case only. return base::i18n::IsRTL() ? 1 : 0; @@ -170,7 +164,6 @@ LocationBarView::LocationBarView(Browser* browser, manage_passwords_icon_view_(NULL), translate_icon_view_(NULL), star_view_(NULL), - search_button_(NULL), is_popup_mode_(is_popup_mode), show_focus_rect_(false), template_url_service_(NULL), @@ -330,10 +323,6 @@ void LocationBarView::Init() { star_view_->SetVisible(false); AddChildView(star_view_); - search_button_ = new SearchButton(this); - search_button_->SetVisible(false); - AddChildView(search_button_); - // Initialize the location entry. We do this to avoid a black flash which is // visible when the location entry has just been initialized. Update(NULL); @@ -559,8 +548,6 @@ gfx::Size LocationBarView::GetPreferredSize() const { gfx::Size min_size(border_painter_->GetMinimumSize()); if (!IsInitialized()) return min_size; - gfx::Size search_button_min_size(search_button_->GetMinimumSize()); - min_size.SetToMax(search_button_min_size); // Compute width of omnibox-leading content. const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); @@ -577,9 +564,7 @@ gfx::Size LocationBarView::GetPreferredSize() const { } // Compute width of omnibox-trailing content. - int trailing_width = search_button_->visible() ? - (search_button_->GetMinimumSize().width() + kSearchButtonInset) : - horizontal_edge_thickness; + int trailing_width = horizontal_edge_thickness; trailing_width += IncrementalMinimumWidth(star_view_) + IncrementalMinimumWidth(translate_icon_view_) + IncrementalMinimumWidth(open_pdf_in_reader_view_) + @@ -719,11 +704,7 @@ void LocationBarView::Layout() { const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); int full_width = width() - horizontal_edge_thickness; - const gfx::Size search_button_size(search_button_->GetPreferredSize()); - const int search_button_reserved_width = - search_button_size.width() + kSearchButtonInset; - full_width -= search_button_->visible() ? - search_button_reserved_width : horizontal_edge_thickness; + full_width -= horizontal_edge_thickness; int entry_width = full_width; leading_decorations.LayoutPass1(&entry_width); trailing_decorations.LayoutPass1(&entry_width); @@ -817,10 +798,6 @@ void LocationBarView::Layout() { } omnibox_view_->SetBoundsRect(location_bounds); - - search_button_->SetBoundsRect(gfx::Rect( - gfx::Point(width() - search_button_reserved_width, 0), - search_button_size)); } //////////////////////////////////////////////////////////////////////////////// @@ -1273,12 +1250,10 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) { void LocationBarView::PaintChildren(gfx::Canvas* canvas, const views::CullSet& cull_set) { // Paint all the children except for the omnibox itself, which may need to be - // clipped if it's animating in, and the search button, which will be painted - // after the border. + // clipped if it's animating in. for (int i = 0, count = child_count(); i < count; ++i) { views::View* child = child_at(i); - if (!child->layer() && (child != omnibox_view_) && - (child != search_button_)) + if (!child->layer() && (child != omnibox_view_)) child->Paint(canvas, cull_set); } @@ -1300,10 +1275,6 @@ void LocationBarView::PaintChildren(gfx::Canvas* canvas, if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) border_rect.Inset(-kPopupEdgeThickness, 0); views::Painter::PaintPainterAt(canvas, border_painter_.get(), border_rect); - - // The search button must be painted after the border so that the border - // shadow is not drawn over them. - search_button_->Paint(canvas, cull_set); } //////////////////////////////////////////////////////////////////////////////// @@ -1311,15 +1282,8 @@ void LocationBarView::PaintChildren(gfx::Canvas* canvas, void LocationBarView::ButtonPressed(views::Button* sender, const ui::Event& event) { - if (sender == mic_search_view_) { - command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); - return; - } - - DCHECK_EQ(search_button_, sender); - // TODO(pkasting): When macourteau adds UMA stats for this, wire them up here. - omnibox_view_->model()->AcceptInput( - ui::DispositionFromEventFlags(event.flags()), false); + DCHECK_EQ(mic_search_view_, sender); + command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); } //////////////////////////////////////////////////////////////////////////////// @@ -1367,18 +1331,6 @@ void LocationBarView::OnChanged() { location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); - ToolbarModel* toolbar_model = GetToolbarModel(); - chrome::DisplaySearchButtonConditions conditions = - chrome::GetDisplaySearchButtonConditions(); - bool meets_conditions = - (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) || - ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && - (toolbar_model->WouldPerformSearchTermReplacement(true) || - ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && - toolbar_model->input_in_progress()))); - search_button_->SetVisible(!is_popup_mode_ && meets_conditions); - search_button_->UpdateIcon(icon_id == IDR_OMNIBOX_SEARCH); - Layout(); SchedulePaint(); } 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 11935fd..0672ef0 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -43,7 +43,6 @@ class ManagePasswordsIconView; class PageActionWithBadgeView; class PageActionImageView; class Profile; -class SearchButton; class SelectedKeywordView; class StarView; class TemplateURLService; @@ -469,9 +468,6 @@ class LocationBarView : public LocationBar, // The star. StarView* star_view_; - // The search/go button. - SearchButton* search_button_; - // Whether we're in popup mode. This value also controls whether the location // bar is read-only. const bool is_popup_mode_; diff --git a/chrome/browser/ui/views/location_bar/search_button.cc b/chrome/browser/ui/views/location_bar/search_button.cc deleted file mode 100644 index b069e8e..0000000 --- a/chrome/browser/ui/views/location_bar/search_button.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 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/search_button.h" - -#include "grit/theme_resources.h" -#include "ui/base/theme_provider.h" -#include "ui/views/controls/button/label_button_border.h" - -SearchButton::SearchButton(views::ButtonListener* listener) - : views::LabelButton(listener, base::string16()) { - EnableCanvasFlippingForRTLUI(true); - set_triggerable_event_flags( - ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON); - SetStyle(views::Button::STYLE_BUTTON); - SetFocusable(false); - SetMinSize(gfx::Size()); - scoped_ptr<views::LabelButtonBorder> border( - new views::LabelButtonBorder(style())); - border->set_insets(gfx::Insets()); - const int kSearchButtonNormalImages[] = IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON); - border->SetPainter( - false, views::Button::STATE_NORMAL, - views::Painter::CreateImageGridPainter(kSearchButtonNormalImages)); - const int kSearchButtonHoveredImages[] = - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_HOVER); - border->SetPainter( - false, views::Button::STATE_HOVERED, - views::Painter::CreateImageGridPainter(kSearchButtonHoveredImages)); - const int kSearchButtonPressedImages[] = - IMAGE_GRID(IDR_OMNIBOX_SEARCH_BUTTON_PRESSED); - border->SetPainter( - false, views::Button::STATE_PRESSED, - views::Painter::CreateImageGridPainter(kSearchButtonPressedImages)); - border->SetPainter(false, views::Button::STATE_DISABLED, NULL); - border->SetPainter(true, views::Button::STATE_NORMAL, NULL); - border->SetPainter(true, views::Button::STATE_HOVERED, NULL); - border->SetPainter(true, views::Button::STATE_PRESSED, NULL); - border->SetPainter(true, views::Button::STATE_DISABLED, NULL); - SetBorder(border.Pass()); - const int kSearchButtonWidth = 56; - SetMinSize(gfx::Size(kSearchButtonWidth, 0)); -} - -SearchButton::~SearchButton() { -} - -void SearchButton::UpdateIcon(bool is_search) { - SetImage( - views::Button::STATE_NORMAL, - *GetThemeProvider()->GetImageSkiaNamed(is_search ? - IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW)); - // Flip the arrow for RTL, but not the loupe. - image()->EnableCanvasFlippingForRTLUI(!is_search); -} diff --git a/chrome/browser/ui/views/location_bar/search_button.h b/chrome/browser/ui/views/location_bar/search_button.h deleted file mode 100644 index 8071166..0000000 --- a/chrome/browser/ui/views/location_bar/search_button.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 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_SEARCH_BUTTON_H_ -#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SEARCH_BUTTON_H_ - -#include "ui/views/controls/button/label_button.h" - -// A blue button shown at the end of the omnibox that holds either a search or -// navigation icon based on the current omnibox text. This is something like a -// cross between a historical browser "Go" button and the Google "search" -// button. -class SearchButton : public views::LabelButton { - public: - explicit SearchButton(views::ButtonListener* listener); - ~SearchButton() override; - - // Updates the search button icon to a search icon if |is_search| is true, or - // a navigation icon otherwise. - void UpdateIcon(bool is_search); - - private: - DISALLOW_COPY_AND_ASSIGN(SearchButton); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SEARCH_BUTTON_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 624eeea..cda737b 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -556,8 +556,6 @@ 'browser/ui/cocoa/location_bar/mic_search_decoration.mm', 'browser/ui/cocoa/location_bar/page_action_decoration.h', 'browser/ui/cocoa/location_bar/page_action_decoration.mm', - 'browser/ui/cocoa/location_bar/search_button_decoration.h', - 'browser/ui/cocoa/location_bar/search_button_decoration.mm', 'browser/ui/cocoa/location_bar/selected_keyword_decoration.h', 'browser/ui/cocoa/location_bar/selected_keyword_decoration.mm', 'browser/ui/cocoa/location_bar/star_decoration.h', @@ -2185,8 +2183,6 @@ 'browser/ui/views/location_bar/page_action_with_badge_view.h', 'browser/ui/views/location_bar/page_info_helper.cc', 'browser/ui/views/location_bar/page_info_helper.h', - 'browser/ui/views/location_bar/search_button.cc', - 'browser/ui/views/location_bar/search_button.h', 'browser/ui/views/location_bar/selected_keyword_view.cc', 'browser/ui/views/location_bar/selected_keyword_view.h', 'browser/ui/views/location_bar/star_view.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index dbb363e..d6541af 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -322,10 +322,6 @@ const char kDisableQuicPortSelection[] = "disable-quic-port-selection"; // Prevents the save password bubble from being enabled. const char kDisableSavePasswordBubble[] = "disable-save-password-bubble"; -// Disables the "search button in omnibox" experiment. -const char kDisableSearchButtonInOmnibox[] = - "disable-search-button-in-omnibox"; - // Disables using bubbles for session restore request. const char kDisableSessionCrashedBubble[] = "disable-session-crashed-bubble"; @@ -536,21 +532,6 @@ const char kEnableSavePasswordBubble[] = "enable-save-password-bubble"; // Enables SDCH for https schemes. const char kEnableSdchOverHttps[] = "enable-sdch-over-https"; -// Controls which branch of the "search button in omnibox" experiment is -// enabled. -// -// We're using independent flags here (as opposed to a common flag with -// different values) to be able to enable/disable the entire experience -// associated with this feature server-side from the FieldTrial (the complete -// experience includes other flag changes as well). It is not currently possible -// to do that with "flag=value" flags. -const char kEnableSearchButtonInOmniboxAlways[] = - "enable-search-button-in-omnibox-always"; -const char kEnableSearchButtonInOmniboxForStr[] = - "enable-search-button-in-omnibox-for-str"; -const char kEnableSearchButtonInOmniboxForStrOrIip[] = - "enable-search-button-in-omnibox-for-str-or-iip"; - // Enables using bubbles for session restore request instead of infobars. const char kEnableSessionCrashedBubble[] = "enable-session-crashed-bubble"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 90ed6f6..3442495 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -97,7 +97,6 @@ extern const char kDisableQuic[]; extern const char kDisableQuicPacing[]; extern const char kDisableQuicPortSelection[]; extern const char kDisableSavePasswordBubble[]; -extern const char kDisableSearchButtonInOmnibox[]; extern const char kDisableSessionCrashedBubble[]; extern const char kDisableSuggestionsService[]; extern const char kDisableSupervisedUserBlacklist[]; @@ -157,9 +156,6 @@ extern const char kEnableQuicPortSelection[]; extern const char kEnableReaderModeToolbarIcon[]; extern const char kEnableSavePasswordBubble[]; extern const char kEnableSdchOverHttps[]; -extern const char kEnableSearchButtonInOmniboxAlways[]; -extern const char kEnableSearchButtonInOmniboxForStr[]; -extern const char kEnableSearchButtonInOmniboxForStrOrIip[]; extern const char kEnableSessionCrashedBubble[]; extern const char kEnableSettingsWindow[]; extern const char kEnableShowModalDialog[]; |