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/api/content_settings/content_settings_api.h" | 5 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/content_settings/cookie_settings.h" | 14 #include "chrome/browser/content_settings/cookie_settings.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
16 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" | 16 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" |
17 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" | 17 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
18 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" | 18 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
19 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" | 19 #include "chrome/browser/extensions/api/preference/preference_api_constants.h" |
20 #include "chrome/browser/extensions/api/preference/preference_helpers.h" | 20 #include "chrome/browser/extensions/api/preference/preference_helpers.h" |
21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/plugins/plugin_finder.h" | 22 #include "chrome/browser/plugins/plugin_finder.h" |
23 #include "chrome/browser/plugins/plugin_installer.h" | 23 #include "chrome/browser/plugins/plugin_installer.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/extensions/api/content_settings.h" | 27 #include "chrome/common/extensions/api/content_settings.h" |
28 #include "chrome/common/extensions/extension_error_utils.h" | |
29 #include "content/public/browser/plugin_service.h" | 28 #include "content/public/browser/plugin_service.h" |
| 29 #include "extensions/common/error_utils.h" |
30 | 30 |
31 using content::BrowserThread; | 31 using content::BrowserThread; |
32 using content::PluginService; | 32 using content::PluginService; |
33 | 33 |
34 namespace Clear = extensions::api::content_settings::ContentSetting::Clear; | 34 namespace Clear = extensions::api::content_settings::ContentSetting::Clear; |
35 namespace Get = extensions::api::content_settings::ContentSetting::Get; | 35 namespace Get = extensions::api::content_settings::ContentSetting::Get; |
36 namespace Set = extensions::api::content_settings::ContentSetting::Set; | 36 namespace Set = extensions::api::content_settings::ContentSetting::Set; |
37 namespace pref_helpers = extensions::preference_helpers; | 37 namespace pref_helpers = extensions::preference_helpers; |
38 namespace pref_keys = extensions::preference_api_constants; | 38 namespace pref_keys = extensions::preference_api_constants; |
39 | 39 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 bool GetContentSettingFunction::RunImpl() { | 98 bool GetContentSettingFunction::RunImpl() { |
99 ContentSettingsType content_type; | 99 ContentSettingsType content_type; |
100 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); | 100 EXTENSION_FUNCTION_VALIDATE(RemoveContentType(args_.get(), &content_type)); |
101 | 101 |
102 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); | 102 scoped_ptr<Get::Params> params(Get::Params::Create(*args_)); |
103 EXTENSION_FUNCTION_VALIDATE(params.get()); | 103 EXTENSION_FUNCTION_VALIDATE(params.get()); |
104 | 104 |
105 GURL primary_url(params->details.primary_url); | 105 GURL primary_url(params->details.primary_url); |
106 if (!primary_url.is_valid()) { | 106 if (!primary_url.is_valid()) { |
107 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, | 107 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
108 params->details.primary_url); | 108 params->details.primary_url); |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 GURL secondary_url(primary_url); | 112 GURL secondary_url(primary_url); |
113 if (params->details.secondary_url.get()) { | 113 if (params->details.secondary_url.get()) { |
114 secondary_url = GURL(*params->details.secondary_url); | 114 secondary_url = GURL(*params->details.secondary_url); |
115 if (!secondary_url.is_valid()) { | 115 if (!secondary_url.is_valid()) { |
116 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, | 116 error_ = ErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
117 *params->details.secondary_url); | 117 *params->details.secondary_url); |
118 return false; | 118 return false; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 std::string resource_identifier; | 122 std::string resource_identifier; |
123 if (params->details.resource_identifier.get()) | 123 if (params->details.resource_identifier.get()) |
124 resource_identifier = params->details.resource_identifier->id; | 124 resource_identifier = params->details.resource_identifier->id; |
125 | 125 |
126 bool incognito = false; | 126 bool incognito = false; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 &GetResourceIdentifiersFunction::SendResponse, this, true)); | 291 &GetResourceIdentifiersFunction::SendResponse, this, true)); |
292 } | 292 } |
293 | 293 |
294 // static | 294 // static |
295 void GetResourceIdentifiersFunction::SetPluginsForTesting( | 295 void GetResourceIdentifiersFunction::SetPluginsForTesting( |
296 const std::vector<webkit::WebPluginInfo>* plugins) { | 296 const std::vector<webkit::WebPluginInfo>* plugins) { |
297 g_testing_plugins_ = plugins; | 297 g_testing_plugins_ = plugins; |
298 } | 298 } |
299 | 299 |
300 } // namespace extensions | 300 } // namespace extensions |
OLD | NEW |