| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
| 10 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 void SetUpCommandLine(base::CommandLine* command_line) override; | 49 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 50 | 50 |
| 51 // Load an extension with a PageAction that sends a message when clicked. | 51 // Load an extension with a PageAction that sends a message when clicked. |
| 52 const extensions::Extension* LoadPageActionExtension( | 52 const extensions::Extension* LoadPageActionExtension( |
| 53 extensions::TestExtensionDir* dir); | 53 extensions::TestExtensionDir* dir); |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_override_; | 56 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_override_; |
| 57 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_; |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTest); | 59 DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTest); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 void LocationBarBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 62 void LocationBarBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
| 62 // In order to let a vanilla extension override the bookmark star, we have to | 63 // In order to let a vanilla extension override the bookmark star, we have to |
| 63 // enable the switch. | 64 // enable the switch. |
| 64 enable_override_.reset(new extensions::FeatureSwitch::ScopedOverride( | 65 enable_override_.reset(new extensions::FeatureSwitch::ScopedOverride( |
| 65 extensions::FeatureSwitch::enable_override_bookmarks_ui(), true)); | 66 extensions::FeatureSwitch::enable_override_bookmarks_ui(), true)); |
| 67 // For testing page actions in the location bar, we also have to be sure to |
| 68 // *not* have the redesign turned on. |
| 69 enable_redesign_.reset(new extensions::FeatureSwitch::ScopedOverride( |
| 70 extensions::FeatureSwitch::extension_action_redesign(), false)); |
| 66 ExtensionBrowserTest::SetUpCommandLine(command_line); | 71 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 67 } | 72 } |
| 68 | 73 |
| 69 const extensions::Extension* LocationBarBrowserTest::LoadPageActionExtension( | 74 const extensions::Extension* LocationBarBrowserTest::LoadPageActionExtension( |
| 70 extensions::TestExtensionDir* dir) { | 75 extensions::TestExtensionDir* dir) { |
| 71 DCHECK(dir); | 76 DCHECK(dir); |
| 72 | 77 |
| 73 dir->WriteManifest(base::StringPrintf(kManifestSource, "page_action1")); | 78 dir->WriteManifest(base::StringPrintf(kManifestSource, "page_action1")); |
| 74 dir->WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundScriptSource); | 79 dir->WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundScriptSource); |
| 75 | 80 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 browser()->tab_strip_model()->GetActiveWebContents(); | 209 browser()->tab_strip_model()->GetActiveWebContents(); |
| 205 int tab_id = SessionTabHelper::IdForTab(tab); | 210 int tab_id = SessionTabHelper::IdForTab(tab); |
| 206 action->SetIsVisible(tab_id, true); | 211 action->SetIsVisible(tab_id, true); |
| 207 extensions::ExtensionActionAPI::Get(profile())->NotifyChange( | 212 extensions::ExtensionActionAPI::Get(profile())->NotifyChange( |
| 208 action, tab, profile()); | 213 action, tab, profile()); |
| 209 | 214 |
| 210 // We should still have no page actions. | 215 // We should still have no page actions. |
| 211 EXPECT_EQ(0, location_bar->PageActionCount()); | 216 EXPECT_EQ(0, location_bar->PageActionCount()); |
| 212 EXPECT_EQ(0, location_bar->PageActionVisibleCount()); | 217 EXPECT_EQ(0, location_bar->PageActionVisibleCount()); |
| 213 } | 218 } |
| OLD | NEW |