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/external_provider_impl.h" | 5 #include "chrome/browser/extensions/external_provider_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Constants for keeping track of extension preferences in a dictionary. | 59 // Constants for keeping track of extension preferences in a dictionary. |
60 const char ExternalProviderImpl::kInstallParam[] = "install_parameter"; | 60 const char ExternalProviderImpl::kInstallParam[] = "install_parameter"; |
61 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; | 61 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; |
62 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; | 62 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; |
63 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; | 63 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; |
64 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; | 64 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; |
65 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; | 65 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; |
66 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; | 66 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; |
67 const char ExternalProviderImpl::kWasInstalledByOem[] = "was_installed_by_oem"; | 67 const char ExternalProviderImpl::kWasInstalledByOem[] = "was_installed_by_oem"; |
68 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; | 68 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; |
| 69 const char ExternalProviderImpl::kMayBeUntrusted[] = "may_be_untrusted"; |
69 | 70 |
70 ExternalProviderImpl::ExternalProviderImpl( | 71 ExternalProviderImpl::ExternalProviderImpl( |
71 VisitorInterface* service, | 72 VisitorInterface* service, |
72 const scoped_refptr<ExternalLoader>& loader, | 73 const scoped_refptr<ExternalLoader>& loader, |
73 Profile* profile, | 74 Profile* profile, |
74 Manifest::Location crx_location, | 75 Manifest::Location crx_location, |
75 Manifest::Location download_location, | 76 Manifest::Location download_location, |
76 int creation_flags) | 77 int creation_flags) |
77 : crx_location_(crx_location), | 78 : crx_location_(crx_location), |
78 download_location_(download_location), | 79 download_location_(download_location), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 continue; | 198 continue; |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 int creation_flags = creation_flags_; | 202 int creation_flags = creation_flags_; |
202 bool is_bookmark_app; | 203 bool is_bookmark_app; |
203 if (extension->GetBoolean(kIsBookmarkApp, &is_bookmark_app) && | 204 if (extension->GetBoolean(kIsBookmarkApp, &is_bookmark_app) && |
204 is_bookmark_app) { | 205 is_bookmark_app) { |
205 creation_flags |= Extension::FROM_BOOKMARK; | 206 creation_flags |= Extension::FROM_BOOKMARK; |
206 } | 207 } |
207 bool is_from_webstore; | 208 bool is_from_webstore = false; |
208 if (extension->GetBoolean(kIsFromWebstore, &is_from_webstore) && | 209 if (extension->GetBoolean(kIsFromWebstore, &is_from_webstore) && |
209 is_from_webstore) { | 210 is_from_webstore) { |
210 creation_flags |= Extension::FROM_WEBSTORE; | 211 creation_flags |= Extension::FROM_WEBSTORE; |
211 } | 212 } |
212 bool keep_if_present; | 213 bool keep_if_present = false; |
213 if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) && | 214 if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) && |
214 keep_if_present && profile_) { | 215 keep_if_present && profile_) { |
215 ExtensionServiceInterface* extension_service = | 216 ExtensionServiceInterface* extension_service = |
216 ExtensionSystem::Get(profile_)->extension_service(); | 217 ExtensionSystem::Get(profile_)->extension_service(); |
217 const Extension* extension = extension_service ? | 218 const Extension* extension = extension_service ? |
218 extension_service->GetExtensionById(extension_id, true) : NULL; | 219 extension_service->GetExtensionById(extension_id, true) : NULL; |
219 if (!extension) { | 220 if (!extension) { |
220 VLOG(1) << "Skip installing (or uninstall) external extension: " | 221 VLOG(1) << "Skip installing (or uninstall) external extension: " |
221 << extension_id << " because the extension should be kept " | 222 << extension_id << " because the extension should be kept " |
222 << "only if it is already installed."; | 223 << "only if it is already installed."; |
223 continue; | 224 continue; |
224 } | 225 } |
225 } | 226 } |
226 bool was_installed_by_oem; | 227 bool was_installed_by_oem = false; |
227 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && | 228 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && |
228 was_installed_by_oem) { | 229 was_installed_by_oem) { |
229 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; | 230 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; |
230 } | 231 } |
| 232 bool may_be_untrusted = false; |
| 233 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && |
| 234 may_be_untrusted) { |
| 235 creation_flags |= Extension::MAY_BE_UNTRUSTED; |
| 236 } |
231 | 237 |
232 std::string install_parameter; | 238 std::string install_parameter; |
233 extension->GetString(kInstallParam, &install_parameter); | 239 extension->GetString(kInstallParam, &install_parameter); |
234 | 240 |
235 if (has_external_crx) { | 241 if (has_external_crx) { |
236 if (crx_location_ == Manifest::INVALID_LOCATION) { | 242 if (crx_location_ == Manifest::INVALID_LOCATION) { |
237 LOG(WARNING) << "This provider does not support installing external " | 243 LOG(WARNING) << "This provider does not support installing external " |
238 << "extensions from crx files."; | 244 << "extensions from crx files."; |
239 continue; | 245 continue; |
240 } | 246 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 service, | 573 service, |
568 new ExternalComponentLoader(profile), | 574 new ExternalComponentLoader(profile), |
569 profile, | 575 profile, |
570 Manifest::INVALID_LOCATION, | 576 Manifest::INVALID_LOCATION, |
571 Manifest::EXTERNAL_COMPONENT, | 577 Manifest::EXTERNAL_COMPONENT, |
572 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 578 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
573 } | 579 } |
574 } | 580 } |
575 | 581 |
576 } // namespace extensions | 582 } // namespace extensions |
OLD | NEW |