| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/active_script_controller.h" | 8 #include "chrome/browser/extensions/active_script_controller.h" |
| 9 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 9 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 10 #include "chrome/browser/extensions/extension_util.h" | 10 #include "chrome/browser/extensions/extension_util.h" |
| 11 #include "chrome/browser/extensions/permissions_updater.h" | 11 #include "chrome/browser/extensions/permissions_updater.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
| 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "components/crx_file/id_util.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 20 #include "extensions/common/extension_builder.h" | 21 #include "extensions/common/extension_builder.h" |
| 21 #include "extensions/common/feature_switch.h" | 22 #include "extensions/common/feature_switch.h" |
| 22 #include "extensions/common/id_util.h" | |
| 23 #include "extensions/common/manifest.h" | 23 #include "extensions/common/manifest.h" |
| 24 #include "extensions/common/user_script.h" | 24 #include "extensions/common/user_script.h" |
| 25 #include "extensions/common/value_builder.h" | 25 #include "extensions/common/value_builder.h" |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const char kAllHostsPermission[] = "*://*/*"; | 31 const char kAllHostsPermission[] = "*://*/*"; |
| 32 | 32 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ActiveScriptControllerUnitTest::ActiveScriptControllerUnitTest() | 88 ActiveScriptControllerUnitTest::ActiveScriptControllerUnitTest() |
| 89 : feature_override_(FeatureSwitch::scripts_require_action(), | 89 : feature_override_(FeatureSwitch::scripts_require_action(), |
| 90 FeatureSwitch::OVERRIDE_ENABLED), | 90 FeatureSwitch::OVERRIDE_ENABLED), |
| 91 active_script_controller_(NULL) { | 91 active_script_controller_(NULL) { |
| 92 } | 92 } |
| 93 | 93 |
| 94 ActiveScriptControllerUnitTest::~ActiveScriptControllerUnitTest() { | 94 ActiveScriptControllerUnitTest::~ActiveScriptControllerUnitTest() { |
| 95 } | 95 } |
| 96 | 96 |
| 97 const Extension* ActiveScriptControllerUnitTest::AddExtension() { | 97 const Extension* ActiveScriptControllerUnitTest::AddExtension() { |
| 98 const std::string kId = id_util::GenerateId("all_hosts_extension"); | 98 const std::string kId = crx_file::id_util::GenerateId("all_hosts_extension"); |
| 99 extension_ = ExtensionBuilder() | 99 extension_ = ExtensionBuilder() |
| 100 .SetManifest( | 100 .SetManifest( |
| 101 DictionaryBuilder() | 101 DictionaryBuilder() |
| 102 .Set("name", "all_hosts_extension") | 102 .Set("name", "all_hosts_extension") |
| 103 .Set("description", "an extension") | 103 .Set("description", "an extension") |
| 104 .Set("manifest_version", 2) | 104 .Set("manifest_version", 2) |
| 105 .Set("version", "1.0.0") | 105 .Set("version", "1.0.0") |
| 106 .Set("permissions", | 106 .Set("permissions", |
| 107 ListBuilder().Append(kAllHostsPermission))) | 107 ListBuilder().Append(kAllHostsPermission))) |
| 108 .SetLocation(Manifest::INTERNAL) | 108 .SetLocation(Manifest::INTERNAL) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 EXPECT_TRUE(RequiresUserConsent(extension)); | 402 EXPECT_TRUE(RequiresUserConsent(extension)); |
| 403 // Different subdomain... | 403 // Different subdomain... |
| 404 NavigateAndCommit(GURL("https://en.google.com/foo/bar")); | 404 NavigateAndCommit(GURL("https://en.google.com/foo/bar")); |
| 405 EXPECT_TRUE(RequiresUserConsent(extension)); | 405 EXPECT_TRUE(RequiresUserConsent(extension)); |
| 406 // Only the "always run" origin should be allowed to run without user consent. | 406 // Only the "always run" origin should be allowed to run without user consent. |
| 407 NavigateAndCommit(GURL("https://www.google.com/foo/bar")); | 407 NavigateAndCommit(GURL("https://www.google.com/foo/bar")); |
| 408 EXPECT_FALSE(RequiresUserConsent(extension)); | 408 EXPECT_FALSE(RequiresUserConsent(extension)); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace extensions | 411 } // namespace extensions |
| OLD | NEW |