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 17 matching lines...) Expand all Loading... | |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "components/crx_file/id_util.h" | 29 #include "components/crx_file/id_util.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "extensions/browser/extension_system.h" | 31 #include "extensions/browser/extension_system.h" |
32 #include "extensions/browser/external_provider_interface.h" | 32 #include "extensions/browser/external_provider_interface.h" |
33 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
34 #include "extensions/common/manifest.h" | 34 #include "extensions/common/manifest.h" |
35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
36 | 36 |
37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
38 #include "base/prefs/pref_service.h" | |
38 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 39 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
39 #include "chrome/browser/chromeos/customization/customization_document.h" | 40 #include "chrome/browser/chromeos/customization/customization_document.h" |
40 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" | 41 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" |
41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 42 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
42 #include "chrome/browser/chromeos/policy/device_local_account.h" | 43 #include "chrome/browser/chromeos/policy/device_local_account.h" |
43 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 44 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
44 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 45 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
46 #include "chrome/common/pref_names.h" | |
45 #include "components/user_manager/user.h" | 47 #include "components/user_manager/user.h" |
46 #else | 48 #else |
47 #include "chrome/browser/extensions/default_apps.h" | 49 #include "chrome/browser/extensions/default_apps.h" |
48 #endif | 50 #endif |
49 | 51 |
50 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
51 #include "chrome/browser/extensions/external_registry_loader_win.h" | 53 #include "chrome/browser/extensions/external_registry_loader_win.h" |
52 #endif | 54 #endif |
53 | 55 |
54 using content::BrowserThread; | 56 using content::BrowserThread; |
55 | 57 |
56 namespace extensions { | 58 namespace extensions { |
57 | 59 |
58 // Constants for keeping track of extension preferences in a dictionary. | 60 // Constants for keeping track of extension preferences in a dictionary. |
59 const char ExternalProviderImpl::kInstallParam[] = "install_parameter"; | 61 const char ExternalProviderImpl::kInstallParam[] = "install_parameter"; |
60 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; | 62 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; |
61 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; | 63 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; |
62 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; | 64 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; |
63 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; | 65 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; |
64 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; | 66 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; |
65 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; | 67 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; |
66 const char ExternalProviderImpl::kWasInstalledByOem[] = "was_installed_by_oem"; | 68 const char ExternalProviderImpl::kWasInstalledByOem[] = "was_installed_by_oem"; |
67 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; | 69 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; |
68 const char ExternalProviderImpl::kMayBeUntrusted[] = "may_be_untrusted"; | 70 const char ExternalProviderImpl::kMayBeUntrusted[] = "may_be_untrusted"; |
71 const char ExternalProviderImpl::kMinProfileCreatedByVersion[] = | |
72 "min_profile_created_by_version"; | |
69 | 73 |
70 ExternalProviderImpl::ExternalProviderImpl( | 74 ExternalProviderImpl::ExternalProviderImpl( |
71 VisitorInterface* service, | 75 VisitorInterface* service, |
72 const scoped_refptr<ExternalLoader>& loader, | 76 const scoped_refptr<ExternalLoader>& loader, |
73 Profile* profile, | 77 Profile* profile, |
74 Manifest::Location crx_location, | 78 Manifest::Location crx_location, |
75 Manifest::Location download_location, | 79 Manifest::Location download_location, |
76 int creation_flags) | 80 int creation_flags) |
77 : crx_location_(crx_location), | 81 : crx_location_(crx_location), |
78 download_location_(download_location), | 82 download_location_(download_location), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 creation_flags |= Extension::FROM_WEBSTORE; | 215 creation_flags |= Extension::FROM_WEBSTORE; |
212 } | 216 } |
213 bool keep_if_present = false; | 217 bool keep_if_present = false; |
214 if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) && | 218 if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) && |
215 keep_if_present && profile_) { | 219 keep_if_present && profile_) { |
216 ExtensionServiceInterface* extension_service = | 220 ExtensionServiceInterface* extension_service = |
217 ExtensionSystem::Get(profile_)->extension_service(); | 221 ExtensionSystem::Get(profile_)->extension_service(); |
218 const Extension* extension = extension_service ? | 222 const Extension* extension = extension_service ? |
219 extension_service->GetExtensionById(extension_id, true) : NULL; | 223 extension_service->GetExtensionById(extension_id, true) : NULL; |
220 if (!extension) { | 224 if (!extension) { |
225 unsupported_extensions.insert(extension_id); | |
221 VLOG(1) << "Skip installing (or uninstall) external extension: " | 226 VLOG(1) << "Skip installing (or uninstall) external extension: " |
222 << extension_id << " because the extension should be kept " | 227 << extension_id << " because the extension should be kept " |
223 << "only if it is already installed."; | 228 << "only if it is already installed."; |
224 continue; | 229 continue; |
225 } | 230 } |
226 } | 231 } |
227 bool was_installed_by_oem = false; | 232 bool was_installed_by_oem = false; |
228 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && | 233 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) && |
229 was_installed_by_oem) { | 234 was_installed_by_oem) { |
230 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; | 235 creation_flags |= Extension::WAS_INSTALLED_BY_OEM; |
231 } | 236 } |
232 bool may_be_untrusted = false; | 237 bool may_be_untrusted = false; |
233 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && | 238 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) && |
234 may_be_untrusted) { | 239 may_be_untrusted) { |
235 creation_flags |= Extension::MAY_BE_UNTRUSTED; | 240 creation_flags |= Extension::MAY_BE_UNTRUSTED; |
236 } | 241 } |
237 | 242 |
243 #if defined(OS_CHROMEOS) | |
244 std::string min_profile_created_by_version; | |
245 if (profile_ && | |
246 extension->GetString(kMinProfileCreatedByVersion, | |
247 &min_profile_created_by_version)) { | |
248 Version profile_version( | |
249 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion)); | |
250 Version min_version(min_profile_created_by_version); | |
251 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) { | |
252 unsupported_extensions.insert(extension_id); | |
253 VLOG(1) << "Skip installing (or uninstall) external extension: " | |
254 << extension_id << " profile.created_by_version: " | |
255 << profile_version.GetString() | |
256 << " min_profile_created_by_version:" | |
257 << min_profile_created_by_version; | |
258 continue; | |
259 } | |
260 } | |
261 #endif // OS_CHROMEOS | |
262 | |
asargent_no_longer_on_chrome
2015/05/08 20:53:25
This method is getting really long, so it would be
Dmitry Polukhin
2015/05/09 07:36:50
Done. I just removed #ifdef there is nothing reall
| |
238 std::string install_parameter; | 263 std::string install_parameter; |
239 extension->GetString(kInstallParam, &install_parameter); | 264 extension->GetString(kInstallParam, &install_parameter); |
240 | 265 |
241 if (has_external_crx) { | 266 if (has_external_crx) { |
242 if (crx_location_ == Manifest::INVALID_LOCATION) { | 267 if (crx_location_ == Manifest::INVALID_LOCATION) { |
243 LOG(WARNING) << "This provider does not support installing external " | 268 LOG(WARNING) << "This provider does not support installing external " |
244 << "extensions from crx files."; | 269 << "extensions from crx files."; |
245 continue; | 270 continue; |
246 } | 271 } |
247 if (external_crx.find(base::FilePath::kParentDirectory) != | 272 if (external_crx.find(base::FilePath::kParentDirectory) != |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 new ExternalProviderImpl( | 609 new ExternalProviderImpl( |
585 service, | 610 service, |
586 new ExternalComponentLoader(profile), | 611 new ExternalComponentLoader(profile), |
587 profile, | 612 profile, |
588 Manifest::INVALID_LOCATION, | 613 Manifest::INVALID_LOCATION, |
589 Manifest::EXTERNAL_COMPONENT, | 614 Manifest::EXTERNAL_COMPONENT, |
590 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 615 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
591 } | 616 } |
592 | 617 |
593 } // namespace extensions | 618 } // namespace extensions |
OLD | NEW |