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

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

Issue 345693002: Extensions: Split extensions utility IPC messages into its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
22 #include "chrome/browser/extensions/component_loader.h" 22 #include "chrome/browser/extensions/component_loader.h"
23 #include "chrome/browser/extensions/crx_installer.h"
24 #include "chrome/browser/extensions/data_deleter.h" 23 #include "chrome/browser/extensions/data_deleter.h"
25 #include "chrome/browser/extensions/extension_assets_manager.h" 24 #include "chrome/browser/extensions/extension_assets_manager.h"
26 #include "chrome/browser/extensions/extension_disabled_ui.h" 25 #include "chrome/browser/extensions/extension_disabled_ui.h"
27 #include "chrome/browser/extensions/extension_error_controller.h" 26 #include "chrome/browser/extensions/extension_error_controller.h"
28 #include "chrome/browser/extensions/extension_install_ui.h" 27 #include "chrome/browser/extensions/extension_install_ui.h"
29 #include "chrome/browser/extensions/extension_special_storage_policy.h" 28 #include "chrome/browser/extensions/extension_special_storage_policy.h"
30 #include "chrome/browser/extensions/extension_sync_service.h" 29 #include "chrome/browser/extensions/extension_sync_service.h"
31 #include "chrome/browser/extensions/extension_util.h" 30 #include "chrome/browser/extensions/extension_util.h"
32 #include "chrome/browser/extensions/external_install_ui.h"
33 #include "chrome/browser/extensions/external_provider_impl.h" 31 #include "chrome/browser/extensions/external_provider_impl.h"
34 #include "chrome/browser/extensions/install_verifier.h" 32 #include "chrome/browser/extensions/install_verifier.h"
35 #include "chrome/browser/extensions/installed_loader.h" 33 #include "chrome/browser/extensions/installed_loader.h"
36 #include "chrome/browser/extensions/pending_extension_manager.h" 34 #include "chrome/browser/extensions/pending_extension_manager.h"
37 #include "chrome/browser/extensions/permissions_updater.h" 35 #include "chrome/browser/extensions/permissions_updater.h"
38 #include "chrome/browser/extensions/shared_module_service.h" 36 #include "chrome/browser/extensions/shared_module_service.h"
39 #include "chrome/browser/extensions/unpacked_installer.h" 37 #include "chrome/browser/extensions/unpacked_installer.h"
40 #include "chrome/browser/extensions/updater/extension_cache.h" 38 #include "chrome/browser/extensions/updater/extension_cache.h"
41 #include "chrome/browser/extensions/updater/extension_updater.h"
42 #include "chrome/browser/profiles/profile.h" 39 #include "chrome/browser/profiles/profile.h"
43 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 40 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
44 #include "chrome/browser/ui/webui/favicon_source.h" 41 #include "chrome/browser/ui/webui/favicon_source.h"
45 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 42 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
46 #include "chrome/browser/ui/webui/theme_source.h" 43 #include "chrome/browser/ui/webui/theme_source.h"
47 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/crash_keys.h" 45 #include "chrome/common/crash_keys.h"
49 #include "chrome/common/extensions/extension_constants.h" 46 #include "chrome/common/extensions/extension_constants.h"
50 #include "chrome/common/extensions/features/feature_channel.h" 47 #include "chrome/common/extensions/features/feature_channel.h"
51 #include "chrome/common/extensions/manifest_url_handler.h" 48 #include "chrome/common/extensions/manifest_url_handler.h"
(...skipping 21 matching lines...) Expand all
73 #include "extensions/common/one_shot_event.h" 70 #include "extensions/common/one_shot_event.h"
74 #include "extensions/common/permissions/permission_message_provider.h" 71 #include "extensions/common/permissions/permission_message_provider.h"
75 #include "extensions/common/permissions/permissions_data.h" 72 #include "extensions/common/permissions/permissions_data.h"
76 73
77 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
78 #include "chrome/browser/chromeos/extensions/install_limiter.h" 75 #include "chrome/browser/chromeos/extensions/install_limiter.h"
79 #include "webkit/browser/fileapi/file_system_backend.h" 76 #include "webkit/browser/fileapi/file_system_backend.h"
80 #include "webkit/browser/fileapi/file_system_context.h" 77 #include "webkit/browser/fileapi/file_system_context.h"
81 #endif 78 #endif
82 79
80 // TODO(thestig) Eventually remove the #ifdefs when ExtensionService is no
81 // longer used on mobile.
82 #if defined(ENABLE_EXTENSIONS)
83 #include "chrome/browser/extensions/crx_installer.h"
84 #include "chrome/browser/extensions/external_install_ui.h"
85 #include "chrome/browser/extensions/updater/extension_updater.h"
86 #endif
87
83 using content::BrowserContext; 88 using content::BrowserContext;
84 using content::BrowserThread; 89 using content::BrowserThread;
85 using content::DevToolsAgentHost; 90 using content::DevToolsAgentHost;
86 using extensions::CrxInstaller; 91 using extensions::CrxInstaller;
87 using extensions::Extension; 92 using extensions::Extension;
88 using extensions::ExtensionIdSet; 93 using extensions::ExtensionIdSet;
89 using extensions::ExtensionInfo; 94 using extensions::ExtensionInfo;
90 using extensions::ExtensionRegistry; 95 using extensions::ExtensionRegistry;
91 using extensions::ExtensionSet; 96 using extensions::ExtensionSet;
92 using extensions::FeatureSwitch; 97 using extensions::FeatureSwitch;
(...skipping 14 matching lines...) Expand all
107 // Histogram values for logging events related to externally installed 112 // Histogram values for logging events related to externally installed
108 // extensions. 113 // extensions.
109 enum ExternalExtensionEvent { 114 enum ExternalExtensionEvent {
110 EXTERNAL_EXTENSION_INSTALLED = 0, 115 EXTERNAL_EXTENSION_INSTALLED = 0,
111 EXTERNAL_EXTENSION_IGNORED, 116 EXTERNAL_EXTENSION_IGNORED,
112 EXTERNAL_EXTENSION_REENABLED, 117 EXTERNAL_EXTENSION_REENABLED,
113 EXTERNAL_EXTENSION_UNINSTALLED, 118 EXTERNAL_EXTENSION_UNINSTALLED,
114 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, 119 EXTERNAL_EXTENSION_BUCKET_BOUNDARY,
115 }; 120 };
116 121
122 #if defined(ENABLE_EXTENSIONS)
117 // Prompt the user this many times before considering an extension acknowledged. 123 // Prompt the user this many times before considering an extension acknowledged.
118 static const int kMaxExtensionAcknowledgePromptCount = 3; 124 const int kMaxExtensionAcknowledgePromptCount = 3;
125 #endif
119 126
120 // Wait this many seconds after an extensions becomes idle before updating it. 127 // Wait this many seconds after an extensions becomes idle before updating it.
121 static const int kUpdateIdleDelay = 5; 128 const int kUpdateIdleDelay = 5;
122 129
123 static bool IsCWSSharedModule(const Extension* extension) { 130 bool IsCWSSharedModule(const Extension* extension) {
124 return extension->from_webstore() && 131 return extension->from_webstore() &&
125 SharedModuleInfo::IsSharedModule(extension); 132 SharedModuleInfo::IsSharedModule(extension);
126 } 133 }
127 134
128 class SharedModuleProvider : public extensions::ManagementPolicy::Provider { 135 class SharedModuleProvider : public extensions::ManagementPolicy::Provider {
129 public: 136 public:
130 SharedModuleProvider() {} 137 SharedModuleProvider() {}
131 virtual ~SharedModuleProvider() {} 138 virtual ~SharedModuleProvider() {}
132 139
133 virtual std::string GetDebugPolicyProviderName() const OVERRIDE { 140 virtual std::string GetDebugPolicyProviderName() const OVERRIDE {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 pref_change_registrar_.Init(profile->GetPrefs()); 319 pref_change_registrar_.Init(profile->GetPrefs());
313 base::Closure callback = 320 base::Closure callback =
314 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, 321 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged,
315 base::Unretained(this)); 322 base::Unretained(this));
316 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList, 323 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList,
317 callback); 324 callback);
318 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList, 325 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList,
319 callback); 326 callback);
320 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback); 327 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback);
321 328
329 #if defined(ENABLE_EXTENSIONS)
322 // Set up the ExtensionUpdater 330 // Set up the ExtensionUpdater
323 if (autoupdate_enabled) { 331 if (autoupdate_enabled) {
324 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; 332 int update_frequency = extensions::kDefaultUpdateFrequencySeconds;
325 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { 333 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) {
326 base::StringToInt(command_line->GetSwitchValueASCII( 334 base::StringToInt(command_line->GetSwitchValueASCII(
327 switches::kExtensionsUpdateFrequency), 335 switches::kExtensionsUpdateFrequency),
328 &update_frequency); 336 &update_frequency);
329 } 337 }
330 updater_.reset(new extensions::ExtensionUpdater( 338 updater_.reset(new extensions::ExtensionUpdater(
331 this, 339 this,
332 extension_prefs, 340 extension_prefs,
333 profile->GetPrefs(), 341 profile->GetPrefs(),
334 profile, 342 profile,
335 update_frequency, 343 update_frequency,
336 extensions::ExtensionCache::GetInstance())); 344 extensions::ExtensionCache::GetInstance()));
337 } 345 }
346 #endif
338 347
339 component_loader_.reset( 348 component_loader_.reset(
340 new extensions::ComponentLoader(this, 349 new extensions::ComponentLoader(this,
341 profile->GetPrefs(), 350 profile->GetPrefs(),
342 g_browser_process->local_state(), 351 g_browser_process->local_state(),
343 profile)); 352 profile));
344 353
345 if (extensions_enabled_) { 354 if (extensions_enabled_) {
346 extensions::ExternalProviderImpl::CreateExternalProviders( 355 extensions::ExternalProviderImpl::CreateExternalProviders(
347 this, profile_, &external_extension_providers_); 356 this, profile_, &external_extension_providers_);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) 508 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION)
500 greylist_.Insert(*it); 509 greylist_.Insert(*it);
501 } 510 }
502 } 511 }
503 512
504 bool ExtensionService::UpdateExtension(const std::string& id, 513 bool ExtensionService::UpdateExtension(const std::string& id,
505 const base::FilePath& extension_path, 514 const base::FilePath& extension_path,
506 bool file_ownership_passed, 515 bool file_ownership_passed,
507 CrxInstaller** out_crx_installer) { 516 CrxInstaller** out_crx_installer) {
508 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 517 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
518 #if defined(ENABLE_EXTENSIONS)
509 if (browser_terminating_) { 519 if (browser_terminating_) {
510 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; 520 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown";
511 // Leak the temp file at extension_path. We don't want to add to the disk 521 // Leak the temp file at extension_path. We don't want to add to the disk
512 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and 522 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and
513 // the file is in the OS temp directory which should be cleaned up for us. 523 // the file is in the OS temp directory which should be cleaned up for us.
514 return false; 524 return false;
515 } 525 }
516 526
517 const extensions::PendingExtensionInfo* pending_extension_info = 527 const extensions::PendingExtensionInfo* pending_extension_info =
518 pending_extension_manager()->GetById(id); 528 pending_extension_manager()->GetById(id);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 installer->set_creation_flags(creation_flags); 597 installer->set_creation_flags(creation_flags);
588 598
589 installer->set_delete_source(file_ownership_passed); 599 installer->set_delete_source(file_ownership_passed);
590 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); 600 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
591 installer->InstallCrx(extension_path); 601 installer->InstallCrx(extension_path);
592 602
593 if (out_crx_installer) 603 if (out_crx_installer)
594 *out_crx_installer = installer.get(); 604 *out_crx_installer = installer.get();
595 605
596 return true; 606 return true;
607 #else
608 return false;
609 #endif
597 } 610 }
598 611
599 void ExtensionService::ReloadExtension( 612 void ExtensionService::ReloadExtension(
600 // "transient" because the process of reloading may cause the reference 613 // "transient" because the process of reloading may cause the reference
601 // to become invalid. Instead, use |extension_id|, a copy. 614 // to become invalid. Instead, use |extension_id|, a copy.
602 const std::string& transient_extension_id) { 615 const std::string& transient_extension_id) {
603 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 616 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
604 617
605 // If the extension is already reloading, don't reload again. 618 // If the extension is already reloading, don't reload again.
606 if (extension_prefs_->GetDisableReasons(transient_extension_id) & 619 if (extension_prefs_->GetDisableReasons(transient_extension_id) &
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1181
1169 for (size_t i = 0; i < to_unload.size(); ++i) 1182 for (size_t i = 0; i < to_unload.size(); ++i)
1170 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE); 1183 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE);
1171 1184
1172 for (std::map<std::string, Extension::DisableReason>::const_iterator i = 1185 for (std::map<std::string, Extension::DisableReason>::const_iterator i =
1173 to_disable.begin(); i != to_disable.end(); ++i) 1186 to_disable.begin(); i != to_disable.end(); ++i)
1174 DisableExtension(i->first, i->second); 1187 DisableExtension(i->first, i->second);
1175 } 1188 }
1176 1189
1177 void ExtensionService::CheckForUpdatesSoon() { 1190 void ExtensionService::CheckForUpdatesSoon() {
1191 #if defined(ENABLE_EXTENSIONS)
1178 // This can legitimately happen in unit tests. 1192 // This can legitimately happen in unit tests.
1179 if (!updater_.get()) 1193 if (!updater_.get())
1180 return; 1194 return;
1181 1195
1182 if (AreAllExternalProvidersReady()) { 1196 if (AreAllExternalProvidersReady()) {
1183 updater_->CheckSoon(); 1197 updater_->CheckSoon();
1184 } else { 1198 } else {
1185 // Sync can start updating before all the external providers are ready 1199 // Sync can start updating before all the external providers are ready
1186 // during startup. Start the update as soon as those providers are ready, 1200 // during startup. Start the update as soon as those providers are ready,
1187 // but not before. 1201 // but not before.
1188 update_once_all_providers_are_ready_ = true; 1202 update_once_all_providers_are_ready_ = true;
1189 } 1203 }
1204 #endif
1190 } 1205 }
1191 1206
1192 // Some extensions will autoupdate themselves externally from Chrome. These 1207 // Some extensions will autoupdate themselves externally from Chrome. These
1193 // are typically part of some larger client application package. To support 1208 // are typically part of some larger client application package. To support
1194 // these, the extension will register its location in the the preferences file 1209 // these, the extension will register its location in the the preferences file
1195 // (and also, on Windows, in the registry) and this code will periodically 1210 // (and also, on Windows, in the registry) and this code will periodically
1196 // check that location for a .crx file, which it will then install locally if 1211 // check that location for a .crx file, which it will then install locally if
1197 // a new version is available. 1212 // a new version is available.
1198 // Errors are reported through ExtensionErrorReporter. Succcess is not 1213 // Errors are reported through ExtensionErrorReporter. Succcess is not
1199 // reported. 1214 // reported.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 for (i = external_extension_providers_.begin(); 1252 for (i = external_extension_providers_.begin();
1238 i != external_extension_providers_.end(); ++i) { 1253 i != external_extension_providers_.end(); ++i) {
1239 if (!i->get()->IsReady()) 1254 if (!i->get()->IsReady())
1240 return false; 1255 return false;
1241 } 1256 }
1242 return true; 1257 return true;
1243 } 1258 }
1244 1259
1245 void ExtensionService::OnAllExternalProvidersReady() { 1260 void ExtensionService::OnAllExternalProvidersReady() {
1246 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1261 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1262 #if defined(ENABLE_EXTENSIONS)
1247 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); 1263 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime();
1248 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); 1264 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed);
1249 1265
1250 // Install any pending extensions. 1266 // Install any pending extensions.
1251 if (update_once_all_providers_are_ready_ && updater()) { 1267 if (update_once_all_providers_are_ready_ && updater()) {
1252 update_once_all_providers_are_ready_ = false; 1268 update_once_all_providers_are_ready_ = false;
1253 extensions::ExtensionUpdater::CheckParams params; 1269 extensions::ExtensionUpdater::CheckParams params;
1254 params.callback = external_updates_finished_callback_; 1270 params.callback = external_updates_finished_callback_;
1255 updater()->CheckNow(params); 1271 updater()->CheckNow(params);
1256 } 1272 }
1257 1273
1258 // Uninstall all the unclaimed extensions. 1274 // Uninstall all the unclaimed extensions.
1259 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( 1275 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info(
1260 extension_prefs_->GetInstalledExtensionsInfo()); 1276 extension_prefs_->GetInstalledExtensionsInfo());
1261 for (size_t i = 0; i < extensions_info->size(); ++i) { 1277 for (size_t i = 0; i < extensions_info->size(); ++i) {
1262 ExtensionInfo* info = extensions_info->at(i).get(); 1278 ExtensionInfo* info = extensions_info->at(i).get();
1263 if (Manifest::IsExternalLocation(info->extension_location)) 1279 if (Manifest::IsExternalLocation(info->extension_location))
1264 CheckExternalUninstall(info->extension_id); 1280 CheckExternalUninstall(info->extension_id);
1265 } 1281 }
1266 1282
1267 error_controller_->ShowErrorIfNeeded(); 1283 error_controller_->ShowErrorIfNeeded();
1268 1284
1269 UpdateExternalExtensionAlert(); 1285 UpdateExternalExtensionAlert();
1286 #endif
1270 } 1287 }
1271 1288
1272 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { 1289 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) {
1273 extension_prefs_->AcknowledgeExternalExtension(id); 1290 extension_prefs_->AcknowledgeExternalExtension(id);
1274 UpdateExternalExtensionAlert(); 1291 UpdateExternalExtensionAlert();
1275 } 1292 }
1276 1293
1277 bool ExtensionService::IsUnacknowledgedExternalExtension( 1294 bool ExtensionService::IsUnacknowledgedExternalExtension(
1278 const Extension* extension) { 1295 const Extension* extension) {
1279 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 1296 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled())
1280 return false; 1297 return false;
1281 1298
1282 return (Manifest::IsExternalLocation(extension->location()) && 1299 return (Manifest::IsExternalLocation(extension->location()) &&
1283 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && 1300 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) &&
1284 !(extension_prefs_->GetDisableReasons(extension->id()) & 1301 !(extension_prefs_->GetDisableReasons(extension->id()) &
1285 Extension::DISABLE_SIDELOAD_WIPEOUT)); 1302 Extension::DISABLE_SIDELOAD_WIPEOUT));
1286 } 1303 }
1287 1304
1288 void ExtensionService::UpdateExternalExtensionAlert() { 1305 void ExtensionService::UpdateExternalExtensionAlert() {
1306 #if defined(ENABLE_EXTENSIONS)
1289 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 1307 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled())
1290 return; 1308 return;
1291 1309
1292 const Extension* extension = NULL; 1310 const Extension* extension = NULL;
1293 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); 1311 const ExtensionSet& disabled_extensions = registry_->disabled_extensions();
1294 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); 1312 for (ExtensionSet::const_iterator iter = disabled_extensions.begin();
1295 iter != disabled_extensions.end(); ++iter) { 1313 iter != disabled_extensions.end(); ++iter) {
1296 const Extension* e = iter->get(); 1314 const Extension* e = iter->get();
1297 if (IsUnacknowledgedExternalExtension(e)) { 1315 if (IsUnacknowledgedExternalExtension(e)) {
1298 extension = e; 1316 extension = e;
(...skipping 29 matching lines...) Expand all
1328 extension_prefs_->SetExternalInstallFirstRun(extension->id()); 1346 extension_prefs_->SetExternalInstallFirstRun(extension->id());
1329 // first_run is true if the extension was installed during a first run 1347 // first_run is true if the extension was installed during a first run
1330 // (even if it's post-first run now). 1348 // (even if it's post-first run now).
1331 bool first_run = extension_prefs_->IsExternalInstallFirstRun( 1349 bool first_run = extension_prefs_->IsExternalInstallFirstRun(
1332 extension->id()); 1350 extension->id());
1333 extensions::AddExternalInstallError(this, extension, first_run); 1351 extensions::AddExternalInstallError(this, extension, first_run);
1334 } 1352 }
1335 } else { 1353 } else {
1336 extensions::RemoveExternalInstallError(this); 1354 extensions::RemoveExternalInstallError(this);
1337 } 1355 }
1356 #endif // defined(ENABLE_EXTENSIONS)
1338 } 1357 }
1339 1358
1340 void ExtensionService::UnloadExtension( 1359 void ExtensionService::UnloadExtension(
1341 const std::string& extension_id, 1360 const std::string& extension_id,
1342 UnloadedExtensionInfo::Reason reason) { 1361 UnloadedExtensionInfo::Reason reason) {
1343 // Make sure the extension gets deleted after we return from this function. 1362 // Make sure the extension gets deleted after we return from this function.
1344 int include_mask = 1363 int include_mask =
1345 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; 1364 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED;
1346 scoped_refptr<const Extension> extension( 1365 scoped_refptr<const Extension> extension(
1347 registry_->GetExtensionById(extension_id, include_mask)); 1366 registry_->GetExtensionById(extension_id, include_mask));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 1431
1413 void ExtensionService::SetReadyAndNotifyListeners() { 1432 void ExtensionService::SetReadyAndNotifyListeners() {
1414 ready_->Signal(); 1433 ready_->Signal();
1415 content::NotificationService::current()->Notify( 1434 content::NotificationService::current()->Notify(
1416 chrome::NOTIFICATION_EXTENSIONS_READY, 1435 chrome::NOTIFICATION_EXTENSIONS_READY,
1417 content::Source<Profile>(profile_), 1436 content::Source<Profile>(profile_),
1418 content::NotificationService::NoDetails()); 1437 content::NotificationService::NoDetails());
1419 } 1438 }
1420 1439
1421 void ExtensionService::OnLoadedInstalledExtensions() { 1440 void ExtensionService::OnLoadedInstalledExtensions() {
1441 #if defined(ENABLE_EXTENSIONS)
1422 if (updater_) 1442 if (updater_)
1423 updater_->Start(); 1443 updater_->Start();
1424 1444
1425 OnBlacklistUpdated(); 1445 OnBlacklistUpdated();
1446 #endif
1426 } 1447 }
1427 1448
1428 void ExtensionService::AddExtension(const Extension* extension) { 1449 void ExtensionService::AddExtension(const Extension* extension) {
1429 // TODO(jstritar): We may be able to get rid of this branch by overriding the 1450 // TODO(jstritar): We may be able to get rid of this branch by overriding the
1430 // default extension state to DISABLED when the --disable-extensions flag 1451 // default extension state to DISABLED when the --disable-extensions flag
1431 // is set (http://crbug.com/29067). 1452 // is set (http://crbug.com/29067).
1432 if (!extensions_enabled() && 1453 if (!extensions_enabled() &&
1433 !extension->is_theme() && 1454 !extension->is_theme() &&
1434 extension->location() != Manifest::COMPONENT && 1455 extension->location() != Manifest::COMPONENT &&
1435 !Manifest::IsExternalLocation(extension->location())) { 1456 !Manifest::IsExternalLocation(extension->location())) {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 } 2046 }
2026 2047
2027 bool ExtensionService::OnExternalExtensionFileFound( 2048 bool ExtensionService::OnExternalExtensionFileFound(
2028 const std::string& id, 2049 const std::string& id,
2029 const Version* version, 2050 const Version* version,
2030 const base::FilePath& path, 2051 const base::FilePath& path,
2031 Manifest::Location location, 2052 Manifest::Location location,
2032 int creation_flags, 2053 int creation_flags,
2033 bool mark_acknowledged) { 2054 bool mark_acknowledged) {
2034 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2055 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2056 #if defined(ENABLE_EXTENSIONS)
2035 CHECK(Extension::IdIsValid(id)); 2057 CHECK(Extension::IdIsValid(id));
2036 if (extension_prefs_->IsExternalExtensionUninstalled(id)) 2058 if (extension_prefs_->IsExternalExtensionUninstalled(id))
2037 return false; 2059 return false;
2038 2060
2039 // Before even bothering to unpack, check and see if we already have this 2061 // Before even bothering to unpack, check and see if we already have this
2040 // version. This is important because these extensions are going to get 2062 // version. This is important because these extensions are going to get
2041 // installed on every startup. 2063 // installed on every startup.
2042 const Extension* existing = GetExtensionById(id, true); 2064 const Extension* existing = GetExtensionById(id, true);
2043 2065
2044 if (existing) { 2066 if (existing) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 installer->InstallCrx(path); 2110 installer->InstallCrx(path);
2089 #endif 2111 #endif
2090 2112
2091 // Depending on the source, a new external extension might not need a user 2113 // Depending on the source, a new external extension might not need a user
2092 // notification on installation. For such extensions, mark them acknowledged 2114 // notification on installation. For such extensions, mark them acknowledged
2093 // now to suppress the notification. 2115 // now to suppress the notification.
2094 if (mark_acknowledged) 2116 if (mark_acknowledged)
2095 AcknowledgeExternalExtension(id); 2117 AcknowledgeExternalExtension(id);
2096 2118
2097 return true; 2119 return true;
2120 #else
2121 return false;
2122 #endif // defined(ENABLE_EXTENSIONS)
2098 } 2123 }
2099 2124
2100 void ExtensionService::DidCreateRenderViewForBackgroundPage( 2125 void ExtensionService::DidCreateRenderViewForBackgroundPage(
2101 extensions::ExtensionHost* host) { 2126 extensions::ExtensionHost* host) {
2102 OrphanedDevTools::iterator iter = 2127 OrphanedDevTools::iterator iter =
2103 orphaned_dev_tools_.find(host->extension_id()); 2128 orphaned_dev_tools_.find(host->extension_id());
2104 if (iter == orphaned_dev_tools_.end()) 2129 if (iter == orphaned_dev_tools_.end())
2105 return; 2130 return;
2106 2131
2107 iter->second->ConnectRenderViewHost(host->render_view_host()); 2132 iter->second->ConnectRenderViewHost(host->render_view_host());
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 } 2481 }
2457 2482
2458 void ExtensionService::OnProfileDestructionStarted() { 2483 void ExtensionService::OnProfileDestructionStarted() {
2459 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2484 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2460 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2485 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2461 it != ids_to_unload.end(); 2486 it != ids_to_unload.end();
2462 ++it) { 2487 ++it) {
2463 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2488 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2464 } 2489 }
2465 } 2490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698