| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/location_bar_controller.h" |
| 6 |
| 7 #include <memory> |
| 5 #include <string> | 8 #include <string> |
| 6 #include <utility> | 9 #include <utility> |
| 7 | 10 |
| 8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 13 #include "chrome/browser/extensions/extension_action.h" | 15 #include "chrome/browser/extensions/extension_action.h" |
| 14 #include "chrome/browser/extensions/extension_action_manager.h" | 16 #include "chrome/browser/extensions/extension_action_manager.h" |
| 15 #include "chrome/browser/extensions/extension_action_runner.h" | 17 #include "chrome/browser/extensions/extension_action_runner.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/location_bar_controller.h" | |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/extensions/test_extension_system.h" | 20 #include "chrome/browser/extensions/test_extension_system.h" |
| 20 #include "chrome/browser/sessions/session_tab_helper.h" | 21 #include "chrome/browser/sessions/session_tab_helper.h" |
| 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "components/crx_file/id_util.h" | 24 #include "components/crx_file/id_util.h" |
| 24 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/extension_builder.h" | 26 #include "extensions/common/extension_builder.h" |
| 26 #include "extensions/common/feature_switch.h" | 27 #include "extensions/common/feature_switch.h" |
| 27 #include "extensions/common/value_builder.h" | 28 #include "extensions/common/value_builder.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 extension_service_->AddExtension(extension.get()); | 95 extension_service_->AddExtension(extension.get()); |
| 95 return extension.get(); | 96 return extension.get(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 ExtensionService* extension_service_; | 99 ExtensionService* extension_service_; |
| 99 | 100 |
| 100 private: | 101 private: |
| 101 #if defined OS_CHROMEOS | 102 #if defined OS_CHROMEOS |
| 102 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 103 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 103 chromeos::ScopedTestCrosSettings test_cros_settings_; | 104 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 104 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; | 105 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 105 #endif | 106 #endif |
| 106 | 107 |
| 107 // Since we also test that we show page actions for pending script requests, | 108 // Since we also test that we show page actions for pending script requests, |
| 108 // we need to enable that feature. | 109 // we need to enable that feature. |
| 109 scoped_ptr<FeatureSwitch::ScopedOverride> active_script_override_; | 110 std::unique_ptr<FeatureSwitch::ScopedOverride> active_script_override_; |
| 110 | 111 |
| 111 // This tests legacy page actions. | 112 // This tests legacy page actions. |
| 112 scoped_ptr<FeatureSwitch::ScopedOverride> extension_action_override_; | 113 std::unique_ptr<FeatureSwitch::ScopedOverride> extension_action_override_; |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 // Test that the location bar gets the proper current actions. | 116 // Test that the location bar gets the proper current actions. |
| 116 TEST_F(LocationBarControllerUnitTest, LocationBarDisplaysPageActions) { | 117 TEST_F(LocationBarControllerUnitTest, LocationBarDisplaysPageActions) { |
| 117 // Load up two extensions, one with a page action and one without. | 118 // Load up two extensions, one with a page action and one without. |
| 118 const Extension* page_action = AddExtension(true, "page_actions"); | 119 const Extension* page_action = AddExtension(true, "page_actions"); |
| 119 const Extension* no_action = AddExtension(false, "no_actions"); | 120 const Extension* no_action = AddExtension(false, "no_actions"); |
| 120 | 121 |
| 121 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents()); | 122 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents()); |
| 122 ASSERT_TRUE(tab_helper); | 123 ASSERT_TRUE(tab_helper); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Should discard the settings, and go back to the defaults. | 197 // Should discard the settings, and go back to the defaults. |
| 197 NavigateAndCommit(GURL("http://www.yahoo.com")); | 198 NavigateAndCommit(GURL("http://www.yahoo.com")); |
| 198 | 199 |
| 199 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); | 200 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); |
| 200 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); | 201 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); |
| 201 EXPECT_FALSE(PageActionWantsToRun(extension)); | 202 EXPECT_FALSE(PageActionWantsToRun(extension)); |
| 202 } | 203 } |
| 203 | 204 |
| 204 } // namespace | 205 } // namespace |
| 205 } // namespace extensions | 206 } // namespace extensions |
| OLD | NEW |