summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 21:12:47 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 21:12:47 +0000
commit5d58f95e529c759360713965e806624e74596afb (patch)
tree4737dfbc691b238feacfb170ebeb53f7fbb4923d
parent0ee9dc8efb04959a9bcbc367ee43086628e1410c (diff)
downloadchromium_src-5d58f95e529c759360713965e806624e74596afb.zip
chromium_src-5d58f95e529c759360713965e806624e74596afb.tar.gz
chromium_src-5d58f95e529c759360713965e806624e74596afb.tar.bz2
Remove origin chip v1 and "hide on input" v2 behavior.
Eliminates "V2" from all origin chip v2 code/names except the field trial flag name (so as not to screw up in-process field trials). Eliminates "hide on" flags and just uses a single "enabled" flag for v2. BUG=none TEST=Only one origin chip flag appears in about:flags. Review URL: https://codereview.chromium.org/287543002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271746 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd34
-rw-r--r--chrome/browser/about_flags.cc29
-rw-r--r--chrome/browser/search/search.cc47
-rw-r--r--chrome/browser/search/search.h36
-rw-r--r--chrome/browser/search/search_unittest.cc150
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm2
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm14
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm2
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc2
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view.cc13
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model.cc3
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model_impl.cc15
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model_unittest.cc89
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc31
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h16
-rw-r--r--chrome/browser/ui/views/location_bar/location_icon_view.cc8
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc5
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc383
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h110
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_view.cc54
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_view.h3
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--chrome/common/chrome_switches.cc31
-rw-r--r--chrome/common/chrome_switches.h11
25 files changed, 116 insertions, 978 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 6c0994c..57ff983 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6359,35 +6359,17 @@ 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_ORIGIN_CHIP_NAME" desc="Name of about:flags option to enable the display of the Origin Chip experiment.">
- Enable origin chip
+ <message name="IDS_FLAGS_ORIGIN_CHIP_NAME" desc="Name of about:flags option to enable the display of the origin chip experiment.">
+ Origin chip
</message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_DESCRIPTION" desc="Description of about:flags option to enable the display of the Origin Chip experiment.">
- Moves the URL out of the Omnibox and shows the hostname in the origin chip in the toolbar.
+ <message name="IDS_FLAGS_ORIGIN_CHIP_DESCRIPTION" desc="Description of about:flags option to enable the display of the origin chip experiment.">
+ Hides the URL in the Omnibox and instead shows the hostname in a clickable chip.
</message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_LEADING_LOCATION_BAR" desc="Option in a drop-down menu to enable the display of the origin chip leading the location bar.">
- Enabled and positioned leading the location bar
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_TRAILING_LOCATION_BAR" desc="Option in a drop-down menu to enable the display of the origin chip trailing the location bar.">
- Enabled and positioned trailing the location bar
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_LEADING_MENU_BUTTON" desc="Option in a drop-down menu to enable the display of the origin chip leading the app menu button.">
- Enabled and positioned leading the app menu button
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_V2_NAME" desc="Name of about:flags option to enable the display of the origin chip v2 experiment.">
- Enable origin chip in Omnibox
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_V2_DESCRIPTION" desc="Description of about:flags option to enable the display of the origin chip v2 experiment.">
- Moves the URL out of the Omnibox and shows the hostname in the origin chip in the Omnibox.
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE" desc="Option in a drop-down menu to enable the display of the origin chip v2, with the hides-on-mouse-release behavior.">
- Enabled; hides on click in the Omnibox
- </message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT" desc="Option in a drop-down menu to enable the display of the origin chip v2, with the hides-on-input behavior.">
- Enabled; hides on input in the Omnibox
+ <message name="IDS_FLAGS_ORIGIN_CHIP_ALWAYS" desc="Option in a drop-down menu to enable the display of the origin chip on all pages.">
+ Enabled on all pages
</message>
- <message name="IDS_FLAGS_ORIGIN_CHIP_V2_ON_SRP" desc="Option in a drop-down menu to enable the display of the origin chip v2, with the shown-only-on-srp behavior.">
- Enabled; shown only on search result pages
+ <message name="IDS_FLAGS_ORIGIN_CHIP_ON_SRP" desc="Option in a drop-down menu to enable the display of the origin chip on search result pages only.">
+ Enabled on search result pages only
</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
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index cc92fea..3363387 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -361,22 +361,8 @@ const Experiment::Choice kSearchButtonInOmniboxChoices[] = {
const Experiment::Choice kOriginChipChoices[] = {
{ IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
{ IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, switches::kDisableOriginChip, ""},
- { IDS_FLAGS_ORIGIN_CHIP_TRAILING_LOCATION_BAR,
- switches::kEnableOriginChipTrailingLocationBar, ""},
- { IDS_FLAGS_ORIGIN_CHIP_LEADING_LOCATION_BAR,
- switches::kEnableOriginChipLeadingLocationBar, ""},
- { IDS_FLAGS_ORIGIN_CHIP_LEADING_MENU_BUTTON,
- switches::kEnableOriginChipLeadingMenuButton, ""}
-};
-const Experiment::Choice kOriginChipV2Choices[] = {
- { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
- { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, switches::kDisableOriginChipV2, ""},
- { IDS_FLAGS_ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE,
- switches::kEnableOriginChipV2HideOnMouseRelease, ""},
- { IDS_FLAGS_ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT,
- switches::kEnableOriginChipV2HideOnUserInput, ""},
- { IDS_FLAGS_ORIGIN_CHIP_V2_ON_SRP,
- switches::kEnableOriginChipV2OnSrp, ""}
+ { IDS_FLAGS_ORIGIN_CHIP_ALWAYS, switches::kEnableOriginChipAlways, ""},
+ { IDS_FLAGS_ORIGIN_CHIP_ON_SRP, switches::kEnableOriginChipOnSrp, ""}
};
const Experiment::Choice kTouchScrollingModeChoices[] = {
@@ -1661,18 +1647,11 @@ const Experiment kExperiments[] = {
MULTI_VALUE_TYPE(kNumRasterThreadsChoices)
},
{
- "origin-chip",
+ "origin-chip-in-omnibox",
IDS_FLAGS_ORIGIN_CHIP_NAME,
IDS_FLAGS_ORIGIN_CHIP_DESCRIPTION,
- kOsCrOS | kOsWin | kOsLinux,
- MULTI_VALUE_TYPE(kOriginChipChoices)
- },
- {
- "origin-chip-in-omnibox",
- IDS_FLAGS_ORIGIN_CHIP_V2_NAME,
- IDS_FLAGS_ORIGIN_CHIP_V2_DESCRIPTION,
kOsCrOS | kOsMac | kOsWin | kOsLinux,
- MULTI_VALUE_TYPE(kOriginChipV2Choices)
+ MULTI_VALUE_TYPE(kOriginChipChoices)
},
{
"search-button-in-omnibox",
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index 135833c..7e01ef4 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -73,7 +73,6 @@ const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page";
const char kDisplaySearchButtonFlagName[] = "display_search_button";
const char kOriginChipFlagName[] = "origin_chip";
-const char kOriginChipV2FlagName[] = "origin_chip_v2";
#if !defined(OS_IOS) && !defined(OS_ANDROID)
const char kEnableQueryExtractionFlagName[] = "query_extraction";
#endif
@@ -623,23 +622,17 @@ DisplaySearchButtonConditions GetDisplaySearchButtonConditions() {
}
bool ShouldDisplayOriginChip() {
- return GetOriginChipPosition() != ORIGIN_CHIP_DISABLED;
+ return GetOriginChipCondition() != ORIGIN_CHIP_DISABLED;
}
-OriginChipPosition GetOriginChipPosition() {
- if (ShouldDisplayOriginChipV2())
- return ORIGIN_CHIP_DISABLED;
-
+OriginChipCondition GetOriginChipCondition() {
const CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kDisableOriginChip))
return ORIGIN_CHIP_DISABLED;
- if (cl->HasSwitch(switches::kEnableOriginChipLeadingLocationBar))
- return ORIGIN_CHIP_LEADING_LOCATION_BAR;
- if (cl->HasSwitch(switches::kEnableOriginChip) ||
- cl->HasSwitch(switches::kEnableOriginChipTrailingLocationBar))
- return ORIGIN_CHIP_TRAILING_LOCATION_BAR;
- if (cl->HasSwitch(switches::kEnableOriginChipLeadingMenuButton))
- return ORIGIN_CHIP_LEADING_MENU_BUTTON;
+ if (cl->HasSwitch(switches::kEnableOriginChipAlways))
+ return ORIGIN_CHIP_ALWAYS;
+ if (cl->HasSwitch(switches::kEnableOriginChipOnSrp))
+ return ORIGIN_CHIP_ON_SRP;
FieldTrialFlags flags;
if (!GetFieldTrialInfo(&flags))
@@ -647,33 +640,7 @@ OriginChipPosition GetOriginChipPosition() {
uint64 value =
GetUInt64ValueForFlagWithDefault(kOriginChipFlagName, 0, flags);
return (value < ORIGIN_CHIP_NUM_VALUES) ?
- static_cast<OriginChipPosition>(value) :
- ORIGIN_CHIP_DISABLED;
-}
-
-bool ShouldDisplayOriginChipV2() {
- return GetOriginChipV2Condition() != ORIGIN_CHIP_V2_DISABLED;
-}
-
-OriginChipV2Condition GetOriginChipV2Condition() {
- const CommandLine* cl = CommandLine::ForCurrentProcess();
- if (cl->HasSwitch(switches::kDisableOriginChipV2))
- return ORIGIN_CHIP_V2_DISABLED;
- if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnMouseRelease))
- return ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE;
- if (cl->HasSwitch(switches::kEnableOriginChipV2HideOnUserInput))
- return ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT;
- if (cl->HasSwitch(switches::kEnableOriginChipV2OnSrp))
- return ORIGIN_CHIP_V2_ON_SRP;
-
- FieldTrialFlags flags;
- if (!GetFieldTrialInfo(&flags))
- return ORIGIN_CHIP_V2_DISABLED;
- uint64 value =
- GetUInt64ValueForFlagWithDefault(kOriginChipV2FlagName, 0, flags);
- return (value < ORIGIN_CHIP_V2_NUM_VALUES) ?
- static_cast<OriginChipV2Condition>(value) :
- ORIGIN_CHIP_V2_DISABLED;
+ static_cast<OriginChipCondition>(value) : ORIGIN_CHIP_DISABLED;
}
bool ShouldShowGoogleLocalNTP() {
diff --git a/chrome/browser/search/search.h b/chrome/browser/search/search.h
index f5fa06c..3cbd7d8 100644
--- a/chrome/browser/search/search.h
+++ b/chrome/browser/search/search.h
@@ -48,22 +48,13 @@ enum DisplaySearchButtonConditions {
DISPLAY_SEARCH_BUTTON_NUM_VALUES,
};
-enum OriginChipPosition {
- ORIGIN_CHIP_DISABLED,
- ORIGIN_CHIP_LEADING_LOCATION_BAR,
- ORIGIN_CHIP_TRAILING_LOCATION_BAR,
- ORIGIN_CHIP_LEADING_MENU_BUTTON,
+enum OriginChipCondition {
+ ORIGIN_CHIP_DISABLED = 0,
+ ORIGIN_CHIP_ALWAYS,
+ ORIGIN_CHIP_ON_SRP,
ORIGIN_CHIP_NUM_VALUES,
};
-enum OriginChipV2Condition {
- ORIGIN_CHIP_V2_DISABLED,
- ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE,
- ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT,
- ORIGIN_CHIP_V2_ON_SRP,
- ORIGIN_CHIP_V2_NUM_VALUES,
-};
-
// Use this value for "start margin" to prevent the "es_sm" parameter from
// being used.
extern const int kDisableStartMargin;
@@ -194,24 +185,11 @@ bool ShouldHideTopVerbatimMatch();
// ToolbarModel::WouldPerformSearchTermReplacement().
DisplaySearchButtonConditions GetDisplaySearchButtonConditions();
-// Returns true if the origin chip should be shown in the toolbar. This
-// also includes the related changes to the omnibox. Always returns false if
-// ShouldDisplayOriginChipV2() returns true.
+// Returns true if the origin chip should be shown.
bool ShouldDisplayOriginChip();
-// Returns a value indicating where the origin chip should be positioned on the
-// toolbar.
-OriginChipPosition GetOriginChipPosition();
-
-// Returns true if version 2 of the origin chip should be shown. This version
-// places the origin chip inside the location bar instead of the toolbar and
-// adds show/hide behavior and animations to make the relationship between the
-// chip and the text in the Omnibox clearer.
-bool ShouldDisplayOriginChipV2();
-
-// Returns a value indicating what event should trigger hiding the origin chip
-// in the location bar.
-OriginChipV2Condition GetOriginChipV2Condition();
+// Returns a value indicating when the origin chip should be shown.
+OriginChipCondition GetOriginChipCondition();
// 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.
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index 374e961..e8b0e46 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -1084,176 +1084,62 @@ TEST_F(OriginChipTest, NotSet) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2"));
EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition());
}
TEST_F(OriginChipTest, Disabled) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition());
}
-TEST_F(OriginChipTest, OriginChipLeadingLocationBar) {
+TEST_F(OriginChipTest, Always) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_ALWAYS, GetOriginChipCondition());
}
-TEST_F(OriginChipTest, OriginChipTrailingLocationBar) {
+TEST_F(OriginChipTest, OnSrp) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 origin_chip:2"));
EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition());
}
-TEST_F(OriginChipTest, OriginChipLeadingMenuButton) {
+TEST_F(OriginChipTest, InvalidValue) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 origin_chip:3"));
- EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
-}
-
-TEST_F(OriginChipTest, OriginChipInvalidValue) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip:4"));
EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition());
}
TEST_F(OriginChipTest, CommandLineDisabled) {
- CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip);
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisableOriginChip);
EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition());
// Command-line disable should override the field trial.
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
-}
-
-TEST_F(OriginChipTest, CommandLineOriginChip) {
- CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip);
- EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
-
- // Command-line enable should override the field trial.
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
- EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
-}
-
-TEST_F(OriginChipTest, CommandLineOriginChipLeadingLocationBar) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipLeadingLocationBar);
- EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition());
}
-TEST_F(OriginChipTest, CommandLineOriginChipTrailingLocationBar) {
+TEST_F(OriginChipTest, CommandLineAlways) {
CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipTrailingLocationBar);
+ switches::kEnableOriginChipAlways);
EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
+ EXPECT_EQ(ORIGIN_CHIP_ALWAYS, GetOriginChipCondition());
}
-TEST_F(OriginChipTest, CommandLineOriginChipLeadingMenuButton) {
+TEST_F(OriginChipTest, CommandLineOnSrp) {
CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipLeadingMenuButton);
+ switches::kEnableOriginChipOnSrp);
EXPECT_TRUE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
-}
-
-typedef SearchTest OriginChipV2Test;
-
-TEST_F(OriginChipV2Test, NotSet) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2"));
- EXPECT_FALSE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, Disabled) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:0"));
- EXPECT_FALSE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, HideOnMouseRelease) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1"));
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, HideOnUserInput) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:2"));
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, OnSrp) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:3"));
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_ON_SRP, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, InvalidValue) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:4"));
- EXPECT_FALSE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, BothVersions) {
- // With both the original and v2 origin chip experiments enabled, v2 should
- // disable the original.
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip:1 origin_chip_v2:1"));
- EXPECT_FALSE(ShouldDisplayOriginChip());
- EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, CommandLineDisabled) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kDisableOriginChipV2);
- EXPECT_FALSE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
-
- // Command-line disable should override the field trial.
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1"));
- EXPECT_FALSE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, CommandLineHideOnMouseRelease) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipV2HideOnMouseRelease);
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, CommandLineHideOnUserInput) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipV2HideOnUserInput);
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2Condition());
-}
-
-TEST_F(OriginChipV2Test, CommandLineOnSrp) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableOriginChipV2OnSrp);
- EXPECT_TRUE(ShouldDisplayOriginChipV2());
- EXPECT_EQ(ORIGIN_CHIP_V2_ON_SRP, GetOriginChipV2Condition());
+ EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition());
}
} // namespace chrome
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 ae5ee2d..533d48a 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
@@ -163,7 +163,7 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field,
[[field_ cell] setIsPopupMode:
!browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)];
- if (chrome::ShouldDisplayOriginChipV2())
+ if (chrome::ShouldDisplayOriginChip())
origin_chip_decoration_.reset(new OriginChipDecoration(
this, location_icon_decoration_.get()));
}
diff --git a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
index 54476d1..53b6724 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
@@ -105,21 +105,17 @@ bool LocationIconDecoration::OnMousePressed(NSRect frame, NSPoint location) {
// bar, or the location bar is at the NTP. However, if the origin chip is
// enabled, the omnibox will be empty by default, so the page info should be
// shown in those cases as well.
- if ((chrome::ShouldDisplayOriginChipV2() &&
- owner_->GetOmniboxView()->model() &&
- owner_->GetOmniboxView()->model()->user_input_in_progress()) ||
- (!chrome::ShouldDisplayOriginChipV2() &&
- owner_->GetOmniboxView()->IsEditingOrEmpty()))
+ if (chrome::ShouldDisplayOriginChip() ?
+ (owner_->GetOmniboxView()->model() &&
+ owner_->GetOmniboxView()->model()->user_input_in_progress()) :
+ owner_->GetOmniboxView()->IsEditingOrEmpty())
return true;
WebContents* tab = owner_->GetWebContents();
const NavigationController& controller = tab->GetController();
// Important to use GetVisibleEntry to match what's showing in the omnibox.
NavigationEntry* nav_entry = controller.GetVisibleEntry();
- if (!nav_entry) {
- NOTREACHED();
- return true;
- }
+ DCHECK(nav_entry);
Browser* browser = chrome::FindBrowserWithWebContents(tab);
chrome::ShowWebsiteSettings(browser, tab, nav_entry->GetURL(),
nav_entry->GetSSL());
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 12c61ba..b6177b5 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -209,7 +209,7 @@ void OmniboxViewMac::OnTabChanged(const WebContents* web_contents) {
}
void OmniboxViewMac::Update() {
- if (chrome::ShouldDisplayOriginChipV2()) {
+ if (chrome::ShouldDisplayOriginChip()) {
NSDictionary* placeholder_attributes = @{
NSFontAttributeName : GetFieldFont(gfx::Font::NORMAL),
NSForegroundColorAttributeName : [NSColor disabledControlTextColor]
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 587dd72..1e81c18 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -518,7 +518,7 @@ void OmniboxEditModel::SetInputInProgress(bool in_progress) {
// * For HIDE_ON_MOUSE_RELEASE, which only hides the chip on mouse release if
// the omnibox is empty, it handles the "omnibox was not empty" case by
// acting like HIDE_ON_USER_INPUT.
- if (chrome::ShouldDisplayOriginChipV2() && in_progress)
+ if (chrome::ShouldDisplayOriginChip() && in_progress)
controller()->GetToolbarModel()->set_origin_chip_enabled(false);
controller_->GetToolbarModel()->set_input_in_progress(in_progress);
diff --git a/chrome/browser/ui/omnibox/omnibox_view.cc b/chrome/browser/ui/omnibox/omnibox_view.cc
index 256a582..22b9732 100644
--- a/chrome/browser/ui/omnibox/omnibox_view.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view.cc
@@ -88,20 +88,15 @@ OmniboxView::~OmniboxView() {
}
void OmniboxView::HandleOriginChipMouseRelease() {
- // HIDE_ON_MOUSE_RELEASE only hides if there isn't any current text in the
- // Omnibox (e.g. search terms).
- if ((chrome::GetOriginChipV2Condition() ==
- chrome::ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE) &&
- controller()->GetToolbarModel()->GetText().empty()) {
+ // Only hide if there isn't any current text in the Omnibox (e.g. search
+ // terms).
+ if (controller()->GetToolbarModel()->GetText().empty())
controller()->HideOriginChip();
- }
}
void OmniboxView::OnDidKillFocus() {
- if (chrome::ShouldDisplayOriginChipV2() &&
- !model()->user_input_in_progress()) {
+ if (chrome::ShouldDisplayOriginChip() && !model()->user_input_in_progress())
controller()->ShowOriginChip();
- }
}
void OmniboxView::OpenMatch(const AutocompleteMatch& match,
diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc
index a5a2b0c..8dc3acb 100644
--- a/chrome/browser/ui/toolbar/toolbar_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model.cc
@@ -21,7 +21,6 @@ bool ToolbarModel::WouldReplaceURL() const {
}
bool ToolbarModel::ShouldShowOriginChip() const {
- return chrome::ShouldDisplayOriginChipV2() &&
- WouldOmitURLDueToOriginChip() &&
+ return chrome::ShouldDisplayOriginChip() && WouldOmitURLDueToOriginChip() &&
origin_chip_enabled();
}
diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
index 94ad48f..d4df2bb 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
@@ -186,15 +186,10 @@ int ToolbarModelImpl::GetIcon() const {
// button nor origin chip are present to indicate the security state.
return (chrome::GetDisplaySearchButtonConditions() ==
chrome::DISPLAY_SEARCH_BUTTON_NEVER) &&
- !chrome::ShouldDisplayOriginChipV2() ?
+ !chrome::ShouldDisplayOriginChip() ?
IDR_OMNIBOX_SEARCH_SECURED : IDR_OMNIBOX_SEARCH;
}
- // When the original site chip experiment is running, the icon in the location
- // bar, when not the search icon, should be the page icon.
- if (chrome::ShouldDisplayOriginChip())
- return GetIconForSecurityLevel(NONE);
-
return GetIconForSecurityLevel(GetSecurityLevel(false));
}
@@ -285,10 +280,10 @@ bool ToolbarModelImpl::WouldOmitURLDueToOriginChip() const {
if (chrome::ShouldDisplayOriginChip())
return true;
- const chrome::OriginChipV2Condition chip_condition =
- chrome::GetOriginChipV2Condition();
- return (chip_condition != chrome::ORIGIN_CHIP_V2_DISABLED) &&
- ((chip_condition != chrome::ORIGIN_CHIP_V2_ON_SRP) ||
+ const chrome::OriginChipCondition chip_condition =
+ chrome::GetOriginChipCondition();
+ return (chip_condition == chrome::ORIGIN_CHIP_ALWAYS) ||
+ ((chip_condition == chrome::ORIGIN_CHIP_ON_SRP) &&
WouldPerformSearchTermReplacement(false));
}
diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
index 1807b01..c178854 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
@@ -4,16 +4,12 @@
#include "chrome/browser/ui/toolbar/toolbar_model.h"
-#include <vector>
-
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/search_terms_data.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -22,13 +18,9 @@
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/variations/entropy_provider.h"
#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "content/public/common/url_constants.h"
-#include "net/base/escape.h"
-using base::ASCIIToUTF16;
// Test data ------------------------------------------------------------------
@@ -41,8 +33,6 @@ struct TestItem {
base::string16 expected_text_url_replacement_inactive;
// The expected text to display when query extraction is active.
base::string16 expected_text_query_extraction;
- // The expected text to display when the origin chip (URL removal) is active.
- base::string16 expected_text_origin_chip;
// The expected text to display when both query extraction and URL removal are
// active.
base::string16 expected_text_both;
@@ -51,100 +41,90 @@ struct TestItem {
} test_items[] = {
{
GURL("view-source:http://www.google.com"),
- ASCIIToUTF16("view-source:www.google.com"),
- ASCIIToUTF16("view-source:www.google.com"),
- base::string16(),
+ base::ASCIIToUTF16("view-source:www.google.com"),
+ base::ASCIIToUTF16("view-source:www.google.com"),
base::string16(),
false,
true
},
{
GURL("view-source:chrome://newtab/"),
- ASCIIToUTF16("view-source:chrome://newtab"),
- ASCIIToUTF16("view-source:chrome://newtab"),
- base::string16(),
+ base::ASCIIToUTF16("view-source:chrome://newtab"),
+ base::ASCIIToUTF16("view-source:chrome://newtab"),
base::string16(),
false,
true
},
{
GURL("chrome-extension://monkey/balls.html"),
- ASCIIToUTF16("chrome-extension://monkey/balls.html"),
- ASCIIToUTF16("chrome-extension://monkey/balls.html"),
- base::string16(),
+ base::ASCIIToUTF16("chrome-extension://monkey/balls.html"),
+ base::ASCIIToUTF16("chrome-extension://monkey/balls.html"),
base::string16(),
false,
true
},
{
GURL(content::kAboutBlankURL),
- ASCIIToUTF16(content::kAboutBlankURL),
- ASCIIToUTF16(content::kAboutBlankURL),
- base::string16(),
+ base::ASCIIToUTF16(content::kAboutBlankURL),
+ base::ASCIIToUTF16(content::kAboutBlankURL),
base::string16(),
false,
true
},
{
GURL("http://searchurl/?q=tractor+supply"),
- ASCIIToUTF16("searchurl/?q=tractor+supply"),
- ASCIIToUTF16("searchurl/?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("searchurl/?q=tractor+supply"),
+ base::ASCIIToUTF16("searchurl/?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("http://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
- base::string16(),
+ base::ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
+ base::ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
base::string16(),
false,
true
},
{
GURL("https://google.ca/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
+ base::ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("https://google.com/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("https://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("tractor supply"),
- base::string16(),
- ASCIIToUTF16("tractor supply"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
+ base::ASCIIToUTF16("tractor supply"),
+ base::ASCIIToUTF16("tractor supply"),
true,
true
},
{
GURL("https://google.com/search?q=tractorsupply.com&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
- ASCIIToUTF16("tractorsupply.com"),
- base::string16(),
- ASCIIToUTF16("tractorsupply.com"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
+ base::ASCIIToUTF16("tractorsupply.com"),
+ base::ASCIIToUTF16("tractorsupply.com"),
true,
true
},
{
GURL("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
- ASCIIToUTF16("ftp://tractorsupply.ie"),
- base::string16(),
- ASCIIToUTF16("ftp://tractorsupply.ie"),
+ base::ASCIIToUTF16(
+ "https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
+ base::ASCIIToUTF16("ftp://tractorsupply.ie"),
+ base::ASCIIToUTF16("ftp://tractorsupply.ie"),
true,
true
},
@@ -167,11 +147,11 @@ class ToolbarModelTest : public BrowserWithTestWindowTest {
virtual void SetUp() OVERRIDE;
protected:
+ void EnableOriginChipFieldTrial();
void NavigateAndCheckText(const GURL& url,
const base::string16& expected_text,
bool would_perform_search_term_replacement,
bool should_display_url);
- void EnableOriginChipFieldTrial();
private:
scoped_ptr<base::FieldTrialList> field_trial_list_;
@@ -206,8 +186,8 @@ void ToolbarModelTest::SetUp() {
void ToolbarModelTest::EnableOriginChipFieldTrial() {
field_trial_list_.reset(new base::FieldTrialList(
new metrics::SHA1EntropyProvider("platypus")));
- base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip:1");
+ base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
+ "Group1 espv:2 origin_chip:1");
}
void ToolbarModelTest::NavigateAndCheckText(
@@ -316,8 +296,8 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL_OriginChip) {
EXPECT_FALSE(chrome::IsQueryExtractionEnabled());
for (size_t i = 0; i < arraysize(test_items); ++i) {
const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text_origin_chip,
- false, test_item.should_display_url);
+ NavigateAndCheckText(test_item.url, base::string16(), false,
+ test_item.should_display_url);
}
// Check with both enabled.
@@ -341,7 +321,7 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL_OriginChip) {
}
}
-// Verify that search terms are extracted while the page is loading.
+ // Verify that search terms are extracted while the page is loading.
TEST_F(ToolbarModelTest, SearchTermsWhileLoading) {
chrome::EnableQueryExtractionForTesting();
AddTab(browser(), GURL(content::kAboutBlankURL));
@@ -377,7 +357,8 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
UIThreadSearchTermsData::SetGoogleBaseURL("http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false, true);
+ base::ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false,
+ true);
// The same URL, when specified on the command line, should allow search term
// extraction.
@@ -386,7 +367,7 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
"http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("tractor supply"), true, true);
+ base::ASCIIToUTF16("tractor supply"), true, true);
}
// Popup windows don't have an origin chip, so test that URL display in a popup
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 6630897..a9a14e0 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -485,7 +485,7 @@ void BrowserView::InitStatusBubble() {
void BrowserView::InitPermissionBubbleView() {
permission_bubble_view_.reset(new PermissionBubbleViewViews(
- GetLocationBarView()->GetLocationIconView()));
+ GetLocationBarView()->location_icon_view()));
}
gfx::Rect BrowserView::GetToolbarBounds() const {
@@ -1254,7 +1254,7 @@ void BrowserView::ShowWebsiteSettings(Profile* profile,
const GURL& url,
const content::SSLStatus& ssl) {
WebsiteSettingsPopupView::ShowPopup(
- GetLocationBarView()->GetLocationIconView(), profile,
+ GetLocationBarView()->location_icon_view(), profile,
web_contents, url, ssl, browser_.get());
}
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 4ecf75e..b6e2cb0 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -61,7 +61,6 @@
#include "chrome/browser/ui/views/location_bar/zoom_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
-#include "chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h"
#include "chrome/browser/ui/zoom/zoom_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -207,7 +206,6 @@ LocationBarView::LocationBarView(Browser* browser,
omnibox_view_(NULL),
delegate_(delegate),
origin_chip_view_(NULL),
- toolbar_origin_chip_view_(NULL),
location_icon_view_(NULL),
ev_bubble_view_(NULL),
ime_inline_autocomplete_view_(NULL),
@@ -597,27 +595,13 @@ void LocationBarView::SelectAll() {
omnibox_view_->SelectAll(true);
}
-views::ImageView* LocationBarView::GetLocationIconView() {
- return toolbar_origin_chip_view_ ?
- toolbar_origin_chip_view_->location_icon_view() : location_icon_view_;
-}
-
-const views::ImageView* LocationBarView::GetLocationIconView() const {
- return toolbar_origin_chip_view_ ?
- toolbar_origin_chip_view_->location_icon_view() : location_icon_view_;
-}
-
-views::View* LocationBarView::GetLocationBarAnchor() {
- return GetLocationIconView();
-}
-
gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
// The +1 in the next line creates a 1-px gap between icon and arrow tip.
- gfx::Point icon_bottom(0, GetLocationIconView()->GetImageBounds().bottom() -
+ gfx::Point icon_bottom(0, location_icon_view_->GetImageBounds().bottom() -
LocationBarView::kIconInternalPadding + 1);
- gfx::Point icon_center(GetLocationIconView()->GetImageBounds().CenterPoint());
+ gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint());
gfx::Point point(icon_center.x(), icon_bottom.y());
- ConvertPointToTarget(GetLocationIconView(), this, &point);
+ ConvertPointToTarget(location_icon_view_, this, &point);
return point;
}
@@ -1054,7 +1038,7 @@ void LocationBarView::Update(const WebContents* contents) {
}
void LocationBarView::ShowURL() {
- if (chrome::ShouldDisplayOriginChipV2()) {
+ if (chrome::ShouldDisplayOriginChip()) {
omnibox_view_->SetVisible(false);
omnibox_view_->ShowURL();
show_url_animation_->Show();
@@ -1235,7 +1219,7 @@ void LocationBarView::ShowFirstRunBubbleInternal() {
return;
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
if (browser)
- FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor());
+ FirstRunBubble::ShowBubble(browser, location_icon_view_);
#endif
}
@@ -1254,7 +1238,7 @@ bool LocationBarView::ShouldShowKeywordBubble() const {
}
bool LocationBarView::ShouldShowEVBubble() const {
- return !toolbar_origin_chip_view_ && !chrome::ShouldDisplayOriginChipV2() &&
+ return !chrome::ShouldDisplayOriginChip() &&
(GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE);
}
@@ -1588,9 +1572,6 @@ void LocationBarView::OnChanged() {
*GetThemeProvider()->GetImageSkiaNamed((icon_id == IDR_OMNIBOX_SEARCH) ?
IDR_OMNIBOX_SEARCH_BUTTON_LOUPE : IDR_OMNIBOX_SEARCH_BUTTON_ARROW));
- if (toolbar_origin_chip_view_)
- toolbar_origin_chip_view_->OnChanged();
-
if (origin_chip_view_->visible())
origin_chip_view_->OnChanged();
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 ccf36a95..7bf3c2f 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -49,7 +49,6 @@ class Profile;
class SelectedKeywordView;
class StarView;
class TemplateURLService;
-class ToolbarOriginChipView;
class TranslateIconView;
class ZoomView;
@@ -194,11 +193,6 @@ class LocationBarView : public LocationBar,
// The translate icon. It may not be visible.
TranslateIconView* translate_icon_view() { return translate_icon_view_; }
- void set_toolbar_origin_chip_view(
- ToolbarOriginChipView* toolbar_origin_chip_view) {
- toolbar_origin_chip_view_ = toolbar_origin_chip_view;
- }
-
// Returns the screen coordinates of the omnibox (where the URL text appears,
// not where the icons are shown).
gfx::Point GetOmniboxViewOrigin() const;
@@ -223,11 +217,8 @@ class LocationBarView : public LocationBar,
// in the toolbar in full keyboard accessibility mode.
virtual void SelectAll();
- views::ImageView* GetLocationIconView();
- const views::ImageView* GetLocationIconView() const;
+ LocationIconView* location_icon_view() { return location_icon_view_; }
- // Return a view suitable for anchoring location-bar-anchored bubbles to.
- views::View* GetLocationBarAnchor();
// Return the point suitable for anchoring location-bar-anchored bubbles at.
// The point will be returned in the coordinates of the LocationBarView.
gfx::Point GetLocationBarAnchorPoint() const;
@@ -435,12 +426,9 @@ class LocationBarView : public LocationBar,
// Object used to paint the border.
scoped_ptr<views::Painter> border_painter_;
- // The version of the origin chip that appears in the location bar.
+ // The origin chip that may appear in the location bar.
OriginChipView* origin_chip_view_;
- // The version of the origin chip that appears in the toolbar.
- ToolbarOriginChipView* toolbar_origin_chip_view_;
-
// An icon to the left of the edit field.
LocationIconView* location_icon_view_;
diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc
index a096cd8..7a3b179 100644
--- a/chrome/browser/ui/views/location_bar/location_icon_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/search/search.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -55,11 +54,8 @@ void LocationIconView::OnGestureEvent(ui::GestureEvent* event) {
void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) {
// Do not show page info if the user has been editing the location bar or the
- // location bar is at the NTP. Also skip showing the page info if the
- // toolbar-based origin chip is being shown because it is responsible for
- // showing the page info instead.
- if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty() ||
- chrome::ShouldDisplayOriginChip())
+ // location bar is at the NTP.
+ if (page_info_helper_.location_bar()->GetOmniboxView()->IsEditingOrEmpty())
return;
page_info_helper_.ProcessEvent(event);
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 6152130..4b64cb7 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -225,7 +225,7 @@ void OmniboxViewViews::OnTabChanged(const content::WebContents* web_contents) {
}
void OmniboxViewViews::Update() {
- if (chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2())
+ if (chrome::ShouldDisplayOriginChip())
set_placeholder_text(GetHintText());
const ToolbarModel::SecurityLevel old_security_level = security_level_;
@@ -1026,8 +1026,7 @@ void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {
menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
- if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip() ||
- chrome::ShouldDisplayOriginChipV2()) {
+ if (chrome::IsQueryExtractionEnabled() || chrome::ShouldDisplayOriginChip()) {
int select_all_position = menu_contents->GetIndexOfCommandId(
IDS_APP_SELECT_ALL);
DCHECK_GE(select_all_position, 0);
diff --git a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc b/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc
deleted file mode 100644
index f588543..0000000
--- a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.cc
+++ /dev/null
@@ -1,383 +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/toolbar/toolbar_origin_chip_view.h"
-
-#include "base/files/file_path.h"
-#include "base/metrics/histogram.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_icon_image.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_util.h"
-#include "chrome/browser/favicon/favicon_tab_helper.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/safe_browsing/safe_browsing_service.h"
-#include "chrome/browser/safe_browsing/ui_manager.h"
-#include "chrome/browser/search/search.h"
-#include "chrome/browser/themes/theme_properties.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/elide_url.h"
-#include "chrome/browser/ui/omnibox/omnibox_view.h"
-#include "chrome/browser/ui/toolbar/origin_chip_info.h"
-#include "chrome/browser/ui/toolbar/toolbar_model.h"
-#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
-#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "content/public/browser/navigation_controller.h"
-#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/user_metrics.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/common/url_constants.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/common/constants.h"
-#include "extensions/common/manifest_handlers/icons_handler.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/theme_provider.h"
-#include "ui/views/background.h"
-#include "ui/views/button_drag_utils.h"
-#include "ui/views/controls/button/label_button.h"
-#include "ui/views/controls/button/label_button_border.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/painter.h"
-
-
-// ToolbarOriginChipExtensionIcon ---------------------------------------------
-
-class ToolbarOriginChipExtensionIcon : public extensions::IconImage::Observer {
- public:
- ToolbarOriginChipExtensionIcon(LocationIconView* icon_view,
- Profile* profile,
- const extensions::Extension* extension);
- virtual ~ToolbarOriginChipExtensionIcon();
-
- // IconImage::Observer:
- virtual void OnExtensionIconImageChanged(
- extensions::IconImage* image) OVERRIDE;
-
- private:
- LocationIconView* icon_view_;
- scoped_ptr<extensions::IconImage> icon_image_;
-
- DISALLOW_COPY_AND_ASSIGN(ToolbarOriginChipExtensionIcon);
-};
-
-ToolbarOriginChipExtensionIcon::ToolbarOriginChipExtensionIcon(
- LocationIconView* icon_view,
- Profile* profile,
- const extensions::Extension* extension)
- : icon_view_(icon_view),
- icon_image_(new extensions::IconImage(
- profile,
- extension,
- extensions::IconsInfo::GetIcons(extension),
- extension_misc::EXTENSION_ICON_BITTY,
- extensions::util::GetDefaultAppIcon(),
- this)) {
- // Forces load of the image.
- icon_image_->image_skia().GetRepresentation(1.0f);
-
- if (!icon_image_->image_skia().image_reps().empty())
- OnExtensionIconImageChanged(icon_image_.get());
-}
-
-ToolbarOriginChipExtensionIcon::~ToolbarOriginChipExtensionIcon() {
-}
-
-void ToolbarOriginChipExtensionIcon::OnExtensionIconImageChanged(
- extensions::IconImage* image) {
- if (icon_view_)
- icon_view_->SetImage(&icon_image_->image_skia());
-}
-
-
-// ToolbarOriginChipView ------------------------------------------------------
-
-namespace {
-
-const int kEdgeThickness = 5;
-const int k16x16IconLeadingSpacing = 1;
-const int k16x16IconTrailingSpacing = 2;
-const int kIconTextSpacing = 3;
-const int kTrailingLabelMargin = 0;
-
-const SkColor kEVBackgroundColor = SkColorSetRGB(163, 226, 120);
-const SkColor kMalwareBackgroundColor = SkColorSetRGB(145, 0, 0);
-const SkColor kBrokenSSLBackgroundColor = SkColorSetRGB(253, 196, 36);
-
-} // namespace
-
-ToolbarOriginChipView::ToolbarOriginChipView(ToolbarView* toolbar_view)
- : ToolbarButton(this, NULL),
- toolbar_view_(toolbar_view),
- painter_(NULL),
- showing_16x16_icon_(false) {
- scoped_refptr<SafeBrowsingService> sb_service =
- g_browser_process->safe_browsing_service();
- // May not be set for unit tests.
- if (sb_service.get() && sb_service->ui_manager())
- sb_service->ui_manager()->AddObserver(this);
-
- set_drag_controller(this);
-}
-
-ToolbarOriginChipView::~ToolbarOriginChipView() {
- scoped_refptr<SafeBrowsingService> sb_service =
- g_browser_process->safe_browsing_service();
- if (sb_service.get() && sb_service->ui_manager())
- sb_service->ui_manager()->RemoveObserver(this);
-}
-
-void ToolbarOriginChipView::Init() {
- ToolbarButton::Init();
- image()->EnableCanvasFlippingForRTLUI(false);
-
- // TODO(gbillock): Would be nice to just use stock LabelButton stuff here.
- location_icon_view_ = new LocationIconView(toolbar_view_->location_bar());
- // Make location icon hover events count as hovering the origin chip.
- location_icon_view_->set_interactive(false);
-
- host_label_ = new views::Label();
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- host_label_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont));
-
- AddChildView(location_icon_view_);
- AddChildView(host_label_);
-
- location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(
- IDR_LOCATION_BAR_HTTP));
- location_icon_view_->ShowTooltip(true);
-
- const int kEVBackgroundImages[] = IMAGE_GRID(IDR_SITE_CHIP_EV);
- ev_background_painter_.reset(
- views::Painter::CreateImageGridPainter(kEVBackgroundImages));
- const int kBrokenSSLBackgroundImages[] = IMAGE_GRID(IDR_SITE_CHIP_BROKENSSL);
- broken_ssl_background_painter_.reset(
- views::Painter::CreateImageGridPainter(kBrokenSSLBackgroundImages));
- const int kMalwareBackgroundImages[] = IMAGE_GRID(IDR_SITE_CHIP_MALWARE);
- malware_background_painter_.reset(
- views::Painter::CreateImageGridPainter(kMalwareBackgroundImages));
-}
-
-bool ToolbarOriginChipView::ShouldShow() {
- return chrome::ShouldDisplayOriginChip();
-}
-
-void ToolbarOriginChipView::Update(content::WebContents* web_contents) {
- if (!web_contents)
- return;
-
- // Note: security level can change async as the connection is made.
- GURL url = toolbar_view_->GetToolbarModel()->GetURL();
- const ToolbarModel::SecurityLevel security_level =
- toolbar_view_->GetToolbarModel()->GetSecurityLevel(true);
-
- bool url_malware = OriginChip::IsMalware(url, web_contents);
-
- // TODO(gbillock): We persist a malware setting while a new WebContents
- // content is loaded, meaning that we end up transiently marking a safe
- // page as malware. Need to fix that.
-
- if ((url == url_displayed_) &&
- (security_level == security_level_) &&
- (url_malware == url_malware_))
- return;
-
- url_displayed_ = url;
- url_malware_ = url_malware;
- security_level_ = security_level;
-
- SkColor label_background =
- GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR);
- if (url_malware_) {
- painter_ = malware_background_painter_.get();
- label_background = kMalwareBackgroundColor;
- } else if (security_level_ == ToolbarModel::SECURITY_ERROR) {
- painter_ = broken_ssl_background_painter_.get();
- label_background = kBrokenSSLBackgroundColor;
- } else if (security_level_ == ToolbarModel::EV_SECURE) {
- painter_ = ev_background_painter_.get();
- label_background = kEVBackgroundColor;
- } else {
- painter_ = NULL;
- }
-
- base::string16 host =
- OriginChip::LabelFromURLForProfile(url_displayed_,
- toolbar_view_->browser()->profile());
- if (security_level_ == ToolbarModel::EV_SECURE) {
- host = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL,
- toolbar_view_->GetToolbarModel()->GetEVCertName(),
- host);
- }
-
- host_label_->SetText(host);
- host_label_->SetTooltipText(host);
- host_label_->SetBackgroundColor(label_background);
- host_label_->SetElideBehavior(views::Label::NO_ELIDE);
-
- int icon = toolbar_view_->GetToolbarModel()->GetIconForSecurityLevel(
- security_level_);
- showing_16x16_icon_ = false;
-
- if (url_displayed_.is_empty() ||
- url_displayed_.SchemeIs(content::kChromeUIScheme)) {
- icon = IDR_PRODUCT_LOGO_16;
- showing_16x16_icon_ = true;
- }
-
- location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon));
-
- if (url_displayed_.SchemeIs(extensions::kExtensionScheme)) {
- icon = IDR_EXTENSIONS_FAVICON;
- showing_16x16_icon_ = true;
- location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon));
-
- ExtensionService* service =
- extensions::ExtensionSystem::Get(
- toolbar_view_->browser()->profile())->extension_service();
- const extensions::Extension* extension =
- service->extensions()->GetExtensionOrAppByURL(url_displayed_);
- extension_icon_.reset(
- new ToolbarOriginChipExtensionIcon(location_icon_view_,
- toolbar_view_->browser()->profile(),
- extension));
- } else {
- extension_icon_.reset();
- }
-
- Layout();
- SchedulePaint();
-}
-
-void ToolbarOriginChipView::OnChanged() {
- Update(toolbar_view_->GetWebContents());
- toolbar_view_->Layout();
- toolbar_view_->SchedulePaint();
- // TODO(gbillock): Also need to potentially repaint infobars to make sure the
- // arrows are pointing to the right spot. Only needed for some edge cases.
-}
-
-gfx::Size ToolbarOriginChipView::GetPreferredSize() const {
- gfx::Size label_size = host_label_->GetPreferredSize();
- gfx::Size icon_size = location_icon_view_->GetPreferredSize();
- int icon_spacing = showing_16x16_icon_ ?
- (k16x16IconLeadingSpacing + k16x16IconTrailingSpacing) : 0;
- return gfx::Size(kEdgeThickness + icon_size.width() + icon_spacing +
- kIconTextSpacing + label_size.width() +
- kTrailingLabelMargin + kEdgeThickness,
- icon_size.height());
-}
-
-void ToolbarOriginChipView::Layout() {
- // TODO(gbillock): Eventually we almost certainly want to use
- // LocationBarLayout for leading and trailing decorations.
-
- location_icon_view_->SetBounds(
- kEdgeThickness + (showing_16x16_icon_ ? k16x16IconLeadingSpacing : 0),
- LocationBarView::kNormalEdgeThickness,
- location_icon_view_->GetPreferredSize().width(),
- height() - 2 * LocationBarView::kNormalEdgeThickness);
-
- int host_label_x = location_icon_view_->x() + location_icon_view_->width() +
- kIconTextSpacing;
- host_label_x += showing_16x16_icon_ ? k16x16IconTrailingSpacing : 0;
- int host_label_width =
- width() - host_label_x - kEdgeThickness - kTrailingLabelMargin;
- host_label_->SetBounds(host_label_x,
- LocationBarView::kNormalEdgeThickness,
- host_label_width,
- height() - 2 * LocationBarView::kNormalEdgeThickness);
-}
-
-void ToolbarOriginChipView::OnPaint(gfx::Canvas* canvas) {
- gfx::Rect rect(GetLocalBounds());
- if (painter_)
- views::Painter::PaintPainterAt(canvas, painter_, rect);
-
- ToolbarButton::OnPaint(canvas);
-}
-
-int ToolbarOriginChipView::ElideDomainTarget(int target_max_width) {
- base::string16 host =
- OriginChip::LabelFromURLForProfile(url_displayed_,
- toolbar_view_->browser()->profile());
- host_label_->SetText(host);
- int width = GetPreferredSize().width();
- if (width <= target_max_width)
- return width;
-
- gfx::Size label_size = host_label_->GetPreferredSize();
- int padding_width = width - label_size.width();
-
- host_label_->SetText(ElideHost(
- toolbar_view_->GetToolbarModel()->GetURL(),
- host_label_->font_list(), target_max_width - padding_width));
- return GetPreferredSize().width();
-}
-
-// TODO(gbillock): Make the LocationBarView or OmniboxView the listener for
-// this button.
-void ToolbarOriginChipView::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- // See if the event needs to be passed to the LocationIconView.
- if (event.IsMouseEvent() || (event.type() == ui::ET_GESTURE_TAP)) {
- location_icon_view_->set_interactive(true);
- const ui::LocatedEvent& located_event =
- static_cast<const ui::LocatedEvent&>(event);
- if (GetEventHandlerForPoint(located_event.location()) ==
- location_icon_view_) {
- location_icon_view_->page_info_helper()->ProcessEvent(located_event);
- location_icon_view_->set_interactive(false);
- return;
- }
- location_icon_view_->set_interactive(false);
- }
-
- UMA_HISTOGRAM_COUNTS("OriginChip.Pressed", 1);
- content::RecordAction(base::UserMetricsAction("OriginChipPress"));
-
- toolbar_view_->location_bar()->ShowURL();
-}
-
-void ToolbarOriginChipView::WriteDragDataForView(View* sender,
- const gfx::Point& press_pt,
- OSExchangeData* data) {
- // TODO(gbillock): Consolidate this with the identical logic in
- // LocationBarView.
- content::WebContents* web_contents = toolbar_view_->GetWebContents();
- FaviconTabHelper* favicon_tab_helper =
- FaviconTabHelper::FromWebContents(web_contents);
- gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia();
- button_drag_utils::SetURLAndDragImage(web_contents->GetURL(),
- web_contents->GetTitle(),
- favicon,
- data,
- sender->GetWidget());
-}
-
-int ToolbarOriginChipView::GetDragOperationsForView(View* sender,
- const gfx::Point& p) {
- return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK;
-}
-
-bool ToolbarOriginChipView::CanStartDragForView(View* sender,
- const gfx::Point& press_pt,
- const gfx::Point& p) {
- return true;
-}
-
-// Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will
-// have already been called.
-void ToolbarOriginChipView::OnSafeBrowsingHit(
- const SafeBrowsingUIManager::UnsafeResource& resource) {}
-
-void ToolbarOriginChipView::OnSafeBrowsingMatch(
- const SafeBrowsingUIManager::UnsafeResource& resource) {
- OnChanged();
-}
diff --git a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h b/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h
deleted file mode 100644
index b9903e8..0000000
--- a/chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h
+++ /dev/null
@@ -1,110 +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_TOOLBAR_TOOLBAR_ORIGIN_CHIP_VIEW_H_
-#define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ORIGIN_CHIP_VIEW_H_
-
-#include "chrome/browser/safe_browsing/ui_manager.h"
-#include "chrome/browser/ui/toolbar/toolbar_model.h"
-#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
-#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
-#include "ui/views/controls/button/button.h"
-#include "ui/views/drag_controller.h"
-
-class ToolbarOriginChipExtensionIcon;
-class ToolbarView;
-
-namespace content {
-class WebContents;
-}
-
-namespace gfx {
-class Canvas;
-}
-
-namespace views {
-class Button;
-class Label;
-}
-
-class ToolbarOriginChipView : public ToolbarButton,
- public views::ButtonListener,
- public views::DragController,
- public SafeBrowsingUIManager::Observer {
- public:
- explicit ToolbarOriginChipView(ToolbarView* toolbar_view);
- virtual ~ToolbarOriginChipView();
-
- void Init();
-
- // Returns true if the origin chip should be visible. This will always be
- // true if the original origin chip experiment is enabled. If the V2
- // experiment is enabled this is true if the chip hasn't been hidden by
- // clicking on it or interacting with the Omnibox.
- bool ShouldShow();
-
- // Recalculates the contents of the Origin Chip based on the displayed tab.
- void Update(content::WebContents* tab);
-
- // Called to signal that the contents of the tab being shown has changed, so
- // the origin chip needs to update itself to the new state.
- void OnChanged();
-
- views::ImageView* location_icon_view() {
- return location_icon_view_;
- }
- const views::ImageView* location_icon_view() const {
- return location_icon_view_;
- }
-
- // Elides the hostname shown to the indicated width, if needed. Returns the
- // final width of the origin chip. Note: this may be more than the target
- // width, since the hostname will not be elided past the TLD+1.
- int ElideDomainTarget(int target_max_width);
-
- // ToolbarButton:
- virtual gfx::Size GetPreferredSize() const OVERRIDE;
- virtual void Layout() OVERRIDE;
- virtual void OnPaint(gfx::Canvas* canvas) 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,
- OSExchangeData* data) OVERRIDE;
- virtual int GetDragOperationsForView(View* sender,
- const gfx::Point& p) OVERRIDE;
- virtual bool CanStartDragForView(View* sender,
- const gfx::Point& press_pt,
- const gfx::Point& p) OVERRIDE;
-
- // SafeBrowsingUIManager::Observer:
- virtual void OnSafeBrowsingHit(
- const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
- virtual void OnSafeBrowsingMatch(
- const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
-
- private:
- ToolbarView* toolbar_view_;
- views::Label* host_label_;
- LocationIconView* location_icon_view_;
- scoped_ptr<views::Painter> ev_background_painter_;
- scoped_ptr<views::Painter> broken_ssl_background_painter_;
- scoped_ptr<views::Painter> malware_background_painter_;
- // Will point to one of the background painters, or NULL if the state of the
- // chip has no background.
- views::Painter* painter_;
- bool showing_16x16_icon_;
- scoped_ptr<ToolbarOriginChipExtensionIcon> extension_icon_;
- GURL url_displayed_;
- ToolbarModel::SecurityLevel security_level_;
- bool url_malware_;
-
- DISALLOW_COPY_AND_ASSIGN(ToolbarOriginChipView);
-};
-
-#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ORIGIN_CHIP_VIEW_H_
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index cbaea00..d610cea 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search/search.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_command_controller.h"
@@ -43,7 +42,6 @@
#include "chrome/browser/ui/views/toolbar/home_button.h"
#include "chrome/browser/ui/views/toolbar/reload_button.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
-#include "chrome/browser/ui/views/toolbar/toolbar_origin_chip_view.h"
#include "chrome/browser/ui/views/toolbar/wrench_menu.h"
#include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h"
#include "chrome/browser/upgrade_detector.h"
@@ -134,7 +132,6 @@ ToolbarView::ToolbarView(Browser* browser)
reload_(NULL),
home_(NULL),
location_bar_(NULL),
- origin_chip_view_(NULL),
browser_actions_(NULL),
app_menu_(NULL),
browser_(browser),
@@ -238,22 +235,12 @@ void ToolbarView::Init() {
app_menu_->set_id(VIEW_ID_APP_MENU);
// Always add children in order from left to right, for accessibility.
- origin_chip_view_ = new ToolbarOriginChipView(this);
- chrome::OriginChipPosition origin_chip_position =
- chrome::GetOriginChipPosition();
AddChildView(back_);
AddChildView(forward_);
AddChildView(reload_);
AddChildView(home_);
- if (origin_chip_position == chrome::ORIGIN_CHIP_LEADING_LOCATION_BAR)
- AddChildView(origin_chip_view_);
AddChildView(location_bar_);
- if (origin_chip_position == chrome::ORIGIN_CHIP_TRAILING_LOCATION_BAR)
- AddChildView(origin_chip_view_);
AddChildView(browser_actions_);
- if (origin_chip_position == chrome::ORIGIN_CHIP_LEADING_MENU_BUTTON ||
- origin_chip_position == chrome::ORIGIN_CHIP_DISABLED)
- AddChildView(origin_chip_view_);
AddChildView(app_menu_);
LoadImages();
@@ -275,10 +262,6 @@ void ToolbarView::Init() {
location_bar_->Init();
- origin_chip_view_->Init();
- if (origin_chip_view_->ShouldShow())
- location_bar_->set_toolbar_origin_chip_view(origin_chip_view_);
-
show_home_button_.Init(prefs::kShowHomeButton,
browser_->profile()->GetPrefs(),
base::Bind(&ToolbarView::OnShowHomeButtonChanged,
@@ -306,12 +289,8 @@ void ToolbarView::OnWidgetVisibilityChanged(views::Widget* widget,
void ToolbarView::Update(WebContents* tab) {
if (location_bar_)
location_bar_->Update(tab);
- if (origin_chip_view_->visible())
- origin_chip_view_->Update(tab);
-
if (browser_actions_)
browser_actions_->RefreshBrowserActionViews();
-
if (reload_)
reload_->set_menu_enabled(chrome::IsDebuggerAttachedToCurrentTab(browser_));
}
@@ -547,8 +526,6 @@ gfx::Size ToolbarView::GetPreferredSize() const {
(show_home_button_.GetValue() ? home_->GetPreferredSize().width() : 0) +
kStandardSpacing + browser_actions_->GetPreferredSize().width() +
app_menu_->GetPreferredSize().width() + kRightEdgeSpacing;
- content_width += origin_chip_view_->visible() ?
- (origin_chip_view_->GetPreferredSize().width() + kStandardSpacing) : 0;
size.Enlarge(content_width, 0);
}
return SizeForContentSize(size);
@@ -562,8 +539,6 @@ gfx::Size ToolbarView::GetMinimumSize() const {
(show_home_button_.GetValue() ? home_->GetMinimumSize().width() : 0) +
kStandardSpacing + browser_actions_->GetMinimumSize().width() +
app_menu_->GetMinimumSize().width() + kRightEdgeSpacing;
- content_width += origin_chip_view_->visible() ?
- (origin_chip_view_->GetMinimumSize().width() + kStandardSpacing) : 0;
size.Enlarge(content_width, 0);
}
return SizeForContentSize(size);
@@ -629,34 +604,12 @@ void ToolbarView::Layout() {
int available_width = std::max(0, width() - kRightEdgeSpacing -
app_menu_width - browser_actions_width - next_element_x);
- origin_chip_view_->SetVisible(origin_chip_view_->ShouldShow());
- int origin_chip_width =
- origin_chip_view_->ElideDomainTarget(available_width / 2);
- if (origin_chip_view_->visible())
- available_width -= origin_chip_width + kStandardSpacing;
-
- chrome::OriginChipPosition origin_chip_position =
- chrome::GetOriginChipPosition();
- if (origin_chip_view_->visible() &&
- origin_chip_position == chrome::ORIGIN_CHIP_LEADING_LOCATION_BAR) {
- origin_chip_view_->SetBounds(next_element_x, child_y,
- origin_chip_width, child_height);
- next_element_x = origin_chip_view_->bounds().right() + kStandardSpacing;
- }
-
int location_height = location_bar_->GetPreferredSize().height();
int location_y = (height() - location_height + 1) / 2;
location_bar_->SetBounds(next_element_x, location_y,
std::max(available_width, 0), location_height);
next_element_x = location_bar_->bounds().right();
- if (origin_chip_view_->visible() &&
- origin_chip_position == chrome::ORIGIN_CHIP_TRAILING_LOCATION_BAR) {
- origin_chip_view_->SetBounds(next_element_x + kStandardSpacing, child_y,
- origin_chip_width, child_height);
- next_element_x = origin_chip_view_->bounds().right();
- }
-
browser_actions_->SetBounds(
next_element_x, child_y, browser_actions_width, child_height);
next_element_x = browser_actions_->bounds().right();
@@ -670,13 +623,6 @@ void ToolbarView::Layout() {
// required.
browser_actions_->Layout();
- if (origin_chip_view_->visible() &&
- origin_chip_position == chrome::ORIGIN_CHIP_LEADING_MENU_BUTTON) {
- origin_chip_view_->SetBounds(next_element_x, child_y,
- origin_chip_width, child_height);
- next_element_x = origin_chip_view_->bounds().right() + kStandardSpacing;
- }
-
// Extend the app menu to the screen's right edge in maximized mode just like
// we extend the back button to the left edge.
if (maximized)
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.h b/chrome/browser/ui/views/toolbar/toolbar_view.h
index 743a91b..d841465 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.h
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.h
@@ -26,7 +26,6 @@ class Browser;
class HomeButton;
class ReloadButton;
class ToolbarButton;
-class ToolbarOriginChipView;
class WrenchMenu;
class WrenchMenuModel;
class WrenchToolbarButton;
@@ -103,7 +102,6 @@ class ToolbarView : public views::AccessiblePaneView,
BrowserActionsContainer* browser_actions() const { return browser_actions_; }
ReloadButton* reload_button() const { return reload_; }
LocationBarView* location_bar() const { return location_bar_; }
- ToolbarOriginChipView* origin_chip() const { return origin_chip_view_; }
views::MenuButton* app_menu() const;
HomeButton* home_button() const { return home_; }
@@ -235,7 +233,6 @@ class ToolbarView : public views::AccessiblePaneView,
ReloadButton* reload_;
HomeButton* home_;
LocationBarView* location_bar_;
- ToolbarOriginChipView* origin_chip_view_;
BrowserActionsContainer* browser_actions_;
WrenchToolbarButton* app_menu_;
Browser* browser_;
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index d23444d..0ec744b 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1937,8 +1937,6 @@
'browser/ui/views/toolbar/browser_actions_container_observer.h',
'browser/ui/views/toolbar/home_button.cc',
'browser/ui/views/toolbar/home_button.h',
- 'browser/ui/views/toolbar/toolbar_origin_chip_view.cc',
- 'browser/ui/views/toolbar/toolbar_origin_chip_view.h',
'browser/ui/views/toolbar/reload_button.cc',
'browser/ui/views/toolbar/reload_button.h',
'browser/ui/views/toolbar/toolbar_button.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 1760175..e7230f7 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -310,9 +310,6 @@ const char kDisableOfflineAutoReload[] = "disable-offline-auto-reload";
// Disable the origin chip.
const char kDisableOriginChip[] = "disable-origin-chip";
-// Disable the origin chip in the location bar.
-const char kDisableOriginChipV2[] = "disable-origin-chip-v2";
-
// Disable the setting to prompt the user for their OS account password before
// revealing plaintext passwords in the password manager.
const char kDisablePasswordManagerReauthentication[] =
@@ -547,24 +544,6 @@ const char kEnableOfflineLoadStaleCache[] = "enable-offline-load-stale-cache";
const char kDisableOfflineLoadStaleCache[] =
"disable-offline-load-stale-cache";
-// Controls which branch of the origin chip experiment is enabled. The first
-// flag (enable-origin-chip) is equivalent to the third
-// (enable-origin-chip-trailing-location-bar) and exists for backwards
-// compatability with an earlier version of the experiment.
-//
-// 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 kEnableOriginChip[] = "enable-origin-chip";
-const char kEnableOriginChipLeadingLocationBar[] =
- "enable-origin-chip-leading-location-bar";
-const char kEnableOriginChipTrailingLocationBar[] =
- "enable-origin-chip-trailing-location-bar";
-const char kEnableOriginChipLeadingMenuButton[] =
- "enable-origin-chip-leading-menu-button";
-
// Controls which branch of the origin chip in location bar experiment is
// enabled.
//
@@ -573,12 +552,8 @@ const char kEnableOriginChipLeadingMenuButton[] =
// 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 kEnableOriginChipV2[] = "enable-origin-chip-v2";
-const char kEnableOriginChipV2HideOnMouseRelease[] =
- "enable-origin-chip-v2-hide-on-mouse-release";
-const char kEnableOriginChipV2HideOnUserInput[] =
- "enable-origin-chip-v2-hide-on-user-input";
-const char kEnableOriginChipV2OnSrp[] = "enable-origin-chip-v2-on-srp";
+const char kEnableOriginChipAlways[] = "enable-origin-chip-always";
+const char kEnableOriginChipOnSrp[] = "enable-origin-chip-on-srp";
// Enables panels (always on-top docked pop-up windows).
const char kEnablePanels[] = "enable-panels";
@@ -588,7 +563,7 @@ const char kEnablePrintPreviewRegisterPromos[] =
"enable-print-preview-register-promos";
// Enable Privet storage.
-const char kEnablePrivetStorage[] = "enable-privet-storage";
+const char kEnablePrivetStorage[] = "enable-privet-storage";
// Enables tracking of tasks in profiler for viewing via about:profiler.
// To predominantly disable tracking (profiling), use the command line switch:
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 7dce431..097aad1 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -94,7 +94,6 @@ extern const char kDisableMinimizeOnSecondLauncherItemClick[];
extern const char kDisableNTPOtherSessionsMenu[];
extern const char kDisableOfflineAutoReload[];
extern const char kDisableOriginChip[];
-extern const char kDisableOriginChipV2[];
extern const char kDisablePasswordManagerReauthentication[];
extern const char kDisablePeopleSearch[];
extern const char kDisablePnacl[];
@@ -160,14 +159,8 @@ extern const char kEnableNpnHttpOnly[];
extern const char kEnableOfflineAutoReload[];
extern const char kEnableOfflineLoadStaleCache[];
extern const char kDisableOfflineLoadStaleCache[];
-extern const char kEnableOriginChip[];
-extern const char kEnableOriginChipLeadingLocationBar[];
-extern const char kEnableOriginChipTrailingLocationBar[];
-extern const char kEnableOriginChipLeadingMenuButton[];
-extern const char kEnableOriginChipV2[];
-extern const char kEnableOriginChipV2HideOnMouseRelease[];
-extern const char kEnableOriginChipV2HideOnUserInput[];
-extern const char kEnableOriginChipV2OnSrp[];
+extern const char kEnableOriginChipAlways[];
+extern const char kEnableOriginChipOnSrp[];
extern const char kEnablePanels[];
extern const char kEnablePermissionsBubbles[];
extern const char kEnableQueryExtraction[];