Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: chrome/browser/extensions/external_provider_impl.cc

Issue 1128753003: Add minimal profile creation version for default apps install on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed #ifdef Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/external_provider_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "base/version.h" 19 #include "base/version.h"
19 #include "chrome/browser/app_mode/app_mode_utils.h" 20 #include "chrome/browser/app_mode/app_mode_utils.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/extensions/extension_management.h" 22 #include "chrome/browser/extensions/extension_management.h"
22 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/extensions/external_component_loader.h" 24 #include "chrome/browser/extensions/external_component_loader.h"
24 #include "chrome/browser/extensions/external_policy_loader.h" 25 #include "chrome/browser/extensions/external_policy_loader.h"
25 #include "chrome/browser/extensions/external_pref_loader.h" 26 #include "chrome/browser/extensions/external_pref_loader.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h"
29 #include "components/crx_file/id_util.h" 31 #include "components/crx_file/id_util.h"
30 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
31 #include "extensions/browser/extension_system.h" 33 #include "extensions/browser/extension_system.h"
32 #include "extensions/browser/external_provider_interface.h" 34 #include "extensions/browser/external_provider_interface.h"
33 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
34 #include "extensions/common/manifest.h" 36 #include "extensions/common/manifest.h"
35 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
36 38
37 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
38 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 40 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
(...skipping 20 matching lines...) Expand all
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
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 (!ExternalProviderImpl::HandleMinProfileVersion(extension, extension_id,
244 &unsupported_extensions))
245 continue;
246
238 std::string install_parameter; 247 std::string install_parameter;
239 extension->GetString(kInstallParam, &install_parameter); 248 extension->GetString(kInstallParam, &install_parameter);
240 249
241 if (has_external_crx) { 250 if (has_external_crx) {
242 if (crx_location_ == Manifest::INVALID_LOCATION) { 251 if (crx_location_ == Manifest::INVALID_LOCATION) {
243 LOG(WARNING) << "This provider does not support installing external " 252 LOG(WARNING) << "This provider does not support installing external "
244 << "extensions from crx files."; 253 << "extensions from crx files.";
245 continue; 254 continue;
246 } 255 }
247 if (external_crx.find(base::FilePath::kParentDirectory) != 256 if (external_crx.find(base::FilePath::kParentDirectory) !=
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 NOTREACHED(); // Chrome should not allow prefs to get into this state. 362 NOTREACHED(); // Chrome should not allow prefs to get into this state.
354 return false; 363 return false;
355 } 364 }
356 365
357 if (location) 366 if (location)
358 *location = loc; 367 *location = loc;
359 368
360 return true; 369 return true;
361 } 370 }
362 371
372 bool ExternalProviderImpl::HandleMinProfileVersion(
373 const base::DictionaryValue* extension,
374 const std::string& extension_id,
375 std::set<std::string>* unsupported_extensions) {
376 std::string min_profile_created_by_version;
377 if (profile_ &&
378 extension->GetString(kMinProfileCreatedByVersion,
379 &min_profile_created_by_version)) {
380 Version profile_version(
381 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion));
382 Version min_version(min_profile_created_by_version);
383 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) {
384 unsupported_extensions->insert(extension_id);
385 VLOG(1) << "Skip installing (or uninstall) external extension: "
386 << extension_id
387 << " profile.created_by_version: " << profile_version.GetString()
388 << " min_profile_created_by_version: "
389 << min_profile_created_by_version;
390 return false;
391 }
392 }
393 return true;
394 }
395
363 // static 396 // static
364 void ExternalProviderImpl::CreateExternalProviders( 397 void ExternalProviderImpl::CreateExternalProviders(
365 VisitorInterface* service, 398 VisitorInterface* service,
366 Profile* profile, 399 Profile* profile,
367 ProviderCollection* provider_list) { 400 ProviderCollection* provider_list) {
368 TRACE_EVENT0("browser,startup", 401 TRACE_EVENT0("browser,startup",
369 "ExternalProviderImpl::CreateExternalProviders"); 402 "ExternalProviderImpl::CreateExternalProviders");
370 scoped_refptr<ExternalLoader> external_loader; 403 scoped_refptr<ExternalLoader> external_loader;
371 scoped_refptr<ExternalLoader> external_recommended_loader; 404 scoped_refptr<ExternalLoader> external_recommended_loader;
372 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION; 405 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 new ExternalProviderImpl( 617 new ExternalProviderImpl(
585 service, 618 service,
586 new ExternalComponentLoader(profile), 619 new ExternalComponentLoader(profile),
587 profile, 620 profile,
588 Manifest::INVALID_LOCATION, 621 Manifest::INVALID_LOCATION,
589 Manifest::EXTERNAL_COMPONENT, 622 Manifest::EXTERNAL_COMPONENT,
590 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 623 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
591 } 624 }
592 625
593 } // namespace extensions 626 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_provider_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698