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 "chrome/browser/extensions/extension_system_impl.h" | 5 #include "chrome/browser/extensions/extension_system_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 namespace { | 155 namespace { |
156 | 156 |
157 class ContentVerifierDelegateImpl : public ContentVerifierDelegate { | 157 class ContentVerifierDelegateImpl : public ContentVerifierDelegate { |
158 public: | 158 public: |
159 explicit ContentVerifierDelegateImpl(ExtensionService* service) | 159 explicit ContentVerifierDelegateImpl(ExtensionService* service) |
160 : service_(service->AsWeakPtr()), default_mode_(GetDefaultMode()) {} | 160 : service_(service->AsWeakPtr()), default_mode_(GetDefaultMode()) {} |
161 | 161 |
162 virtual ~ContentVerifierDelegateImpl() {} | 162 virtual ~ContentVerifierDelegateImpl() {} |
163 | 163 |
164 virtual Mode ShouldBeVerified(const Extension& extension) OVERRIDE { | 164 virtual Mode ShouldBeVerified(const Extension& extension) override { |
165 #if defined(OS_CHROMEOS) | 165 #if defined(OS_CHROMEOS) |
166 if (ExtensionAssetsManagerChromeOS::IsSharedInstall(&extension)) | 166 if (ExtensionAssetsManagerChromeOS::IsSharedInstall(&extension)) |
167 return ContentVerifierDelegate::ENFORCE_STRICT; | 167 return ContentVerifierDelegate::ENFORCE_STRICT; |
168 #endif | 168 #endif |
169 | 169 |
170 if (!extension.is_extension() && !extension.is_legacy_packaged_app()) | 170 if (!extension.is_extension() && !extension.is_legacy_packaged_app()) |
171 return ContentVerifierDelegate::NONE; | 171 return ContentVerifierDelegate::NONE; |
172 if (!Manifest::IsAutoUpdateableLocation(extension.location())) | 172 if (!Manifest::IsAutoUpdateableLocation(extension.location())) |
173 return ContentVerifierDelegate::NONE; | 173 return ContentVerifierDelegate::NONE; |
174 | 174 |
175 if (!ManifestURL::UpdatesFromGallery(&extension)) { | 175 if (!ManifestURL::UpdatesFromGallery(&extension)) { |
176 // It's possible that the webstore update url was overridden for testing | 176 // It's possible that the webstore update url was overridden for testing |
177 // so also consider extensions with the default (production) update url | 177 // so also consider extensions with the default (production) update url |
178 // to be from the store as well. | 178 // to be from the store as well. |
179 GURL default_webstore_url = extension_urls::GetDefaultWebstoreUpdateUrl(); | 179 GURL default_webstore_url = extension_urls::GetDefaultWebstoreUpdateUrl(); |
180 if (ManifestURL::GetUpdateURL(&extension) != default_webstore_url) | 180 if (ManifestURL::GetUpdateURL(&extension) != default_webstore_url) |
181 return ContentVerifierDelegate::NONE; | 181 return ContentVerifierDelegate::NONE; |
182 } | 182 } |
183 | 183 |
184 return default_mode_; | 184 return default_mode_; |
185 } | 185 } |
186 | 186 |
187 virtual const ContentVerifierKey& PublicKey() OVERRIDE { | 187 virtual const ContentVerifierKey& PublicKey() override { |
188 static ContentVerifierKey key( | 188 static ContentVerifierKey key( |
189 extension_misc::kWebstoreSignaturesPublicKey, | 189 extension_misc::kWebstoreSignaturesPublicKey, |
190 extension_misc::kWebstoreSignaturesPublicKeySize); | 190 extension_misc::kWebstoreSignaturesPublicKeySize); |
191 return key; | 191 return key; |
192 } | 192 } |
193 | 193 |
194 virtual GURL GetSignatureFetchUrl(const std::string& extension_id, | 194 virtual GURL GetSignatureFetchUrl(const std::string& extension_id, |
195 const base::Version& version) OVERRIDE { | 195 const base::Version& version) override { |
196 // TODO(asargent) Factor out common code from the extension updater's | 196 // TODO(asargent) Factor out common code from the extension updater's |
197 // ManifestFetchData class that can be shared for use here. | 197 // ManifestFetchData class that can be shared for use here. |
198 std::vector<std::string> parts; | 198 std::vector<std::string> parts; |
199 parts.push_back("uc"); | 199 parts.push_back("uc"); |
200 parts.push_back("installsource=signature"); | 200 parts.push_back("installsource=signature"); |
201 parts.push_back("id=" + extension_id); | 201 parts.push_back("id=" + extension_id); |
202 parts.push_back("v=" + version.GetString()); | 202 parts.push_back("v=" + version.GetString()); |
203 std::string x_value = | 203 std::string x_value = |
204 net::EscapeQueryParamValue(JoinString(parts, "&"), true); | 204 net::EscapeQueryParamValue(JoinString(parts, "&"), true); |
205 std::string query = "response=redirect&x=" + x_value; | 205 std::string query = "response=redirect&x=" + x_value; |
206 | 206 |
207 GURL base_url = extension_urls::GetWebstoreUpdateUrl(); | 207 GURL base_url = extension_urls::GetWebstoreUpdateUrl(); |
208 GURL::Replacements replacements; | 208 GURL::Replacements replacements; |
209 replacements.SetQuery(query.c_str(), url::Component(0, query.length())); | 209 replacements.SetQuery(query.c_str(), url::Component(0, query.length())); |
210 return base_url.ReplaceComponents(replacements); | 210 return base_url.ReplaceComponents(replacements); |
211 } | 211 } |
212 | 212 |
213 virtual std::set<base::FilePath> GetBrowserImagePaths( | 213 virtual std::set<base::FilePath> GetBrowserImagePaths( |
214 const extensions::Extension* extension) OVERRIDE { | 214 const extensions::Extension* extension) override { |
215 return extension_file_util::GetBrowserImagePaths(extension); | 215 return extension_file_util::GetBrowserImagePaths(extension); |
216 } | 216 } |
217 | 217 |
218 virtual void VerifyFailed(const std::string& extension_id) OVERRIDE { | 218 virtual void VerifyFailed(const std::string& extension_id) override { |
219 if (!service_) | 219 if (!service_) |
220 return; | 220 return; |
221 ExtensionRegistry* registry = ExtensionRegistry::Get(service_->profile()); | 221 ExtensionRegistry* registry = ExtensionRegistry::Get(service_->profile()); |
222 const Extension* extension = | 222 const Extension* extension = |
223 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 223 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
224 if (!extension) | 224 if (!extension) |
225 return; | 225 return; |
226 Mode mode = ShouldBeVerified(*extension); | 226 Mode mode = ShouldBeVerified(*extension); |
227 if (mode >= ContentVerifierDelegate::ENFORCE) { | 227 if (mode >= ContentVerifierDelegate::ENFORCE) { |
228 service_->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); | 228 service_->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 648 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
649 const std::string& extension_id, | 649 const std::string& extension_id, |
650 const UnloadedExtensionInfo::Reason reason) { | 650 const UnloadedExtensionInfo::Reason reason) { |
651 BrowserThread::PostTask( | 651 BrowserThread::PostTask( |
652 BrowserThread::IO, | 652 BrowserThread::IO, |
653 FROM_HERE, | 653 FROM_HERE, |
654 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 654 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
655 } | 655 } |
656 | 656 |
657 } // namespace extensions | 657 } // namespace extensions |
OLD | NEW |