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_; | |
58 | 57 |
59 DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTest); | 58 DISALLOW_COPY_AND_ASSIGN(LocationBarBrowserTest); |
60 }; | 59 }; |
61 | 60 |
62 void LocationBarBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 61 void LocationBarBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
63 // In order to let a vanilla extension override the bookmark star, we have to | 62 // In order to let a vanilla extension override the bookmark star, we have to |
64 // enable the switch. | 63 // enable the switch. |
65 enable_override_.reset(new extensions::FeatureSwitch::ScopedOverride( | 64 enable_override_.reset(new extensions::FeatureSwitch::ScopedOverride( |
66 extensions::FeatureSwitch::enable_override_bookmarks_ui(), true)); | 65 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)); | |
71 ExtensionBrowserTest::SetUpCommandLine(command_line); | 66 ExtensionBrowserTest::SetUpCommandLine(command_line); |
72 } | 67 } |
73 | 68 |
74 const extensions::Extension* LocationBarBrowserTest::LoadPageActionExtension( | 69 const extensions::Extension* LocationBarBrowserTest::LoadPageActionExtension( |
75 extensions::TestExtensionDir* dir) { | 70 extensions::TestExtensionDir* dir) { |
76 DCHECK(dir); | 71 DCHECK(dir); |
77 | 72 |
78 dir->WriteManifest(base::StringPrintf(kManifestSource, "page_action1")); | 73 dir->WriteManifest(base::StringPrintf(kManifestSource, "page_action1")); |
79 dir->WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundScriptSource); | 74 dir->WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundScriptSource); |
80 | 75 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 browser()->tab_strip_model()->GetActiveWebContents(); | 204 browser()->tab_strip_model()->GetActiveWebContents(); |
210 int tab_id = SessionTabHelper::IdForTab(tab); | 205 int tab_id = SessionTabHelper::IdForTab(tab); |
211 action->SetIsVisible(tab_id, true); | 206 action->SetIsVisible(tab_id, true); |
212 extensions::ExtensionActionAPI::Get(profile())->NotifyChange( | 207 extensions::ExtensionActionAPI::Get(profile())->NotifyChange( |
213 action, tab, profile()); | 208 action, tab, profile()); |
214 | 209 |
215 // We should still have no page actions. | 210 // We should still have no page actions. |
216 EXPECT_EQ(0, location_bar->PageActionCount()); | 211 EXPECT_EQ(0, location_bar->PageActionCount()); |
217 EXPECT_EQ(0, location_bar->PageActionVisibleCount()); | 212 EXPECT_EQ(0, location_bar->PageActionVisibleCount()); |
218 } | 213 } |
OLD | NEW |