Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: chrome/browser/ui/location_bar/location_bar_browsertest.cc

Issue 540483002: Fix regression in showing bookmark star when an extension should override it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/location_bar/location_bar_browsertest.cc
diff --git a/chrome/browser/ui/location_bar/location_bar_browsertest.cc b/chrome/browser/ui/location_bar/location_bar_browsertest.cc
index a1f5e2ce540d43f7ce79c32178d89cc710fd981a..4fe408c42b067e381ca85933b290ad2b9a55dca6 100644
--- a/chrome/browser/ui/location_bar/location_bar_browsertest.cc
+++ b/chrome/browser/ui/location_bar/location_bar_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/test_extension_dir.h"
#include "chrome/browser/sessions/session_tab_helper.h"
@@ -17,7 +18,9 @@
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
#include "extensions/common/feature_switch.h"
+#include "extensions/common/value_builder.h"
namespace {
@@ -42,11 +45,26 @@ class LocationBarBrowserTest : public ExtensionBrowserTest {
virtual ~LocationBarBrowserTest() {}
protected:
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
+
// Load an extension with a PageAction that sends a message when clicked.
const extensions::Extension* LoadPageActionExtension(
extensions::TestExtensionDir* dir);
+
+ private:
+ scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_override_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTest);
};
+void LocationBarBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
+ // In order to let a vanilla extension override the bookmark star, we have to
+ // enable the switch.
+ enable_override_.reset(new extensions::FeatureSwitch::ScopedOverride(
+ extensions::FeatureSwitch::enable_override_bookmarks_ui(), true));
+ ExtensionBrowserTest::SetUpCommandLine(command_line);
+}
+
const extensions::Extension* LocationBarBrowserTest::LoadPageActionExtension(
extensions::TestExtensionDir* dir) {
DCHECK(dir);
@@ -110,11 +128,44 @@ IN_PROC_BROWSER_TEST_F(LocationBarBrowserTest, PageActionUITest) {
EXPECT_TRUE(clicked_listener.WaitUntilSatisfied());
}
+// Test that installing an extension that overrides the bookmark star
+// successfully hides the star.
+IN_PROC_BROWSER_TEST_F(LocationBarBrowserTest,
+ ExtensionCanOverrideBookmarkStar) {
+ LocationBarTesting* location_bar =
+ browser()->window()->GetLocationBar()->GetLocationBarForTesting();
+ // By default, we should show the star.
+ EXPECT_TRUE(location_bar->GetBookmarkStarVisibility());
+
+ // Create and install an extension that overrides the bookmark star.
+ extensions::DictionaryBuilder chrome_ui_overrides;
+ chrome_ui_overrides.Set(
+ "bookmarks_ui",
+ extensions::DictionaryBuilder().
+ SetBoolean("remove_button", true).
+ SetBoolean("remove_bookmark_shortcut", true));
Mike Wittman 2014/09/03 23:57:44 nit: this property shouldn't be necessary
Devlin 2014/09/05 20:15:16 True enough. Removed.
+ scoped_refptr<const extensions::Extension> extension =
+ extensions::ExtensionBuilder().
+ SetManifest(extensions::DictionaryBuilder().
+ Set("name", "overrides star").
+ Set("manifest_version", 2).
+ Set("version", "0.1").
+ Set("description", "override the star").
+ Set("chrome_ui_overrides",
+ chrome_ui_overrides.Pass())).Build();
+ extension_service()->AddExtension(extension);
+
+ // The star should now be hidden.
+ EXPECT_FALSE(location_bar->GetBookmarkStarVisibility());
+}
+
class LocationBarBrowserTestWithRedesign : public LocationBarBrowserTest {
private:
virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTestWithRedesign);
};
void LocationBarBrowserTestWithRedesign::SetUpCommandLine(
« no previous file with comments | « chrome/browser/ui/location_bar/location_bar.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698