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

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

Issue 403593002: Improve messaging for shared modules on chrome://extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 using extensions::SharedModuleService; 105 using extensions::SharedModuleService;
106 using extensions::UnloadedExtensionInfo; 106 using extensions::UnloadedExtensionInfo;
107 107
108 namespace errors = extensions::manifest_errors; 108 namespace errors = extensions::manifest_errors;
109 109
110 namespace { 110 namespace {
111 111
112 // Wait this many seconds after an extensions becomes idle before updating it. 112 // Wait this many seconds after an extensions becomes idle before updating it.
113 const int kUpdateIdleDelay = 5; 113 const int kUpdateIdleDelay = 5;
114 114
115 bool IsCWSSharedModule(const Extension* extension) {
116 return extension->from_webstore() &&
117 SharedModuleInfo::IsSharedModule(extension);
118 }
119
120 class SharedModuleProvider : public extensions::ManagementPolicy::Provider {
121 public:
122 SharedModuleProvider() {}
123 virtual ~SharedModuleProvider() {}
124
125 virtual std::string GetDebugPolicyProviderName() const OVERRIDE {
126 return "SharedModuleProvider";
127 }
128
129 virtual bool UserMayModifySettings(const Extension* extension,
130 base::string16* error) const OVERRIDE {
131 return !IsCWSSharedModule(extension);
132 }
133
134 virtual bool MustRemainEnabled(const Extension* extension,
135 base::string16* error) const OVERRIDE {
136 return IsCWSSharedModule(extension);
137 }
138
139 private:
140 DISALLOW_COPY_AND_ASSIGN(SharedModuleProvider);
141 };
142
143 } // namespace 115 } // namespace
144 116
145 // ExtensionService. 117 // ExtensionService.
146 118
147 void ExtensionService::CheckExternalUninstall(const std::string& id) { 119 void ExtensionService::CheckExternalUninstall(const std::string& id) {
148 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 120 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
149 121
150 // Check if the providers know about this extension. 122 // Check if the providers know about this extension.
151 extensions::ProviderCollection::const_iterator i; 123 extensions::ProviderCollection::const_iterator i;
152 for (i = external_extension_providers_.begin(); 124 for (i = external_extension_providers_.begin();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 error_controller_.reset( 320 error_controller_.reset(
349 new extensions::ExtensionErrorController(profile_, is_first_run_)); 321 new extensions::ExtensionErrorController(profile_, is_first_run_));
350 external_install_manager_.reset( 322 external_install_manager_.reset(
351 new extensions::ExternalInstallManager(profile_, is_first_run_)); 323 new extensions::ExternalInstallManager(profile_, is_first_run_));
352 324
353 #if defined(ENABLE_EXTENSIONS) 325 #if defined(ENABLE_EXTENSIONS)
354 extension_action_storage_manager_.reset( 326 extension_action_storage_manager_.reset(
355 new extensions::ExtensionActionStorageManager(profile_)); 327 new extensions::ExtensionActionStorageManager(profile_));
356 #endif 328 #endif
357 329
358 shared_module_policy_provider_.reset(new SharedModuleProvider);
359
360 // How long is the path to the Extensions directory? 330 // How long is the path to the Extensions directory?
361 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", 331 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength",
362 install_directory_.value().length(), 0, 500, 100); 332 install_directory_.value().length(), 0, 500, 100);
363 } 333 }
364 334
365 const ExtensionSet* ExtensionService::extensions() const { 335 const ExtensionSet* ExtensionService::extensions() const {
366 return &registry_->enabled_extensions(); 336 return &registry_->enabled_extensions();
367 } 337 }
368 338
369 extensions::PendingExtensionManager* 339 extensions::PendingExtensionManager*
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 extension_prefs_->GetAllDelayedInstallInfo()); 435 extension_prefs_->GetAllDelayedInstallInfo());
466 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad", 436 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad",
467 delayed_info2->size() - delayed_info->size()); 437 delayed_info2->size() - delayed_info->size());
468 438
469 SetReadyAndNotifyListeners(); 439 SetReadyAndNotifyListeners();
470 440
471 // TODO(erikkay) this should probably be deferred to a future point 441 // TODO(erikkay) this should probably be deferred to a future point
472 // rather than running immediately at startup. 442 // rather than running immediately at startup.
473 CheckForExternalUpdates(); 443 CheckForExternalUpdates();
474 444
475 system_->management_policy()->RegisterProvider(
476 shared_module_policy_provider_.get());
477
478 LoadGreylistFromPrefs(); 445 LoadGreylistFromPrefs();
479 } 446 }
480 447
481 UMA_HISTOGRAM_TIMES("Extensions.ExtensionServiceInitTime", 448 UMA_HISTOGRAM_TIMES("Extensions.ExtensionServiceInitTime",
482 base::Time::Now() - begin_time); 449 base::Time::Now() - begin_time);
483 } 450 }
484 451
485 void ExtensionService::LoadGreylistFromPrefs() { 452 void ExtensionService::LoadGreylistFromPrefs() {
486 scoped_ptr<ExtensionSet> all_extensions = 453 scoped_ptr<ExtensionSet> all_extensions =
487 registry_->GenerateInstalledExtensionsSet(); 454 registry_->GenerateInstalledExtensionsSet();
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2330 }
2364 2331
2365 void ExtensionService::OnProfileDestructionStarted() { 2332 void ExtensionService::OnProfileDestructionStarted() {
2366 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2333 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2367 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2334 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2368 it != ids_to_unload.end(); 2335 it != ids_to_unload.end();
2369 ++it) { 2336 ++it) {
2370 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2337 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2371 } 2338 }
2372 } 2339 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/extensions/extension_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698