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

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: 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 pref_change_registrar_.Init(profile->GetPrefs()); 317 pref_change_registrar_.Init(profile->GetPrefs());
313 base::Closure callback = 318 base::Closure callback =
314 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, 319 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged,
315 base::Unretained(this)); 320 base::Unretained(this));
316 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList, 321 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList,
317 callback); 322 callback);
318 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList, 323 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList,
319 callback); 324 callback);
320 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback); 325 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback);
321 326
327 #if defined(ENABLE_EXTENSIONS)
322 // Set up the ExtensionUpdater 328 // Set up the ExtensionUpdater
323 if (autoupdate_enabled) { 329 if (autoupdate_enabled) {
324 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; 330 int update_frequency = extensions::kDefaultUpdateFrequencySeconds;
325 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { 331 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) {
326 base::StringToInt(command_line->GetSwitchValueASCII( 332 base::StringToInt(command_line->GetSwitchValueASCII(
327 switches::kExtensionsUpdateFrequency), 333 switches::kExtensionsUpdateFrequency),
328 &update_frequency); 334 &update_frequency);
329 } 335 }
330 updater_.reset(new extensions::ExtensionUpdater( 336 updater_.reset(new extensions::ExtensionUpdater(
331 this, 337 this,
332 extension_prefs, 338 extension_prefs,
333 profile->GetPrefs(), 339 profile->GetPrefs(),
334 profile, 340 profile,
335 update_frequency, 341 update_frequency,
336 extensions::ExtensionCache::GetInstance())); 342 extensions::ExtensionCache::GetInstance()));
337 } 343 }
344 #endif
338 345
339 component_loader_.reset( 346 component_loader_.reset(
340 new extensions::ComponentLoader(this, 347 new extensions::ComponentLoader(this,
341 profile->GetPrefs(), 348 profile->GetPrefs(),
342 g_browser_process->local_state(), 349 g_browser_process->local_state(),
343 profile)); 350 profile));
344 351
345 if (extensions_enabled_) { 352 if (extensions_enabled_) {
346 extensions::ExternalProviderImpl::CreateExternalProviders( 353 extensions::ExternalProviderImpl::CreateExternalProviders(
347 this, profile_, &external_extension_providers_); 354 this, profile_, &external_extension_providers_);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) 508 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION)
502 greylist_.Insert(*it); 509 greylist_.Insert(*it);
503 } 510 }
504 } 511 }
505 512
506 bool ExtensionService::UpdateExtension(const std::string& id, 513 bool ExtensionService::UpdateExtension(const std::string& id,
507 const base::FilePath& extension_path, 514 const base::FilePath& extension_path,
508 bool file_ownership_passed, 515 bool file_ownership_passed,
509 CrxInstaller** out_crx_installer) { 516 CrxInstaller** out_crx_installer) {
510 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 517 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
518 #if defined(ENABLE_EXTENSIONS)
511 if (browser_terminating_) { 519 if (browser_terminating_) {
512 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; 520 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown";
513 // 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
514 // 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
515 // 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.
516 return false; 524 return false;
517 } 525 }
518 526
519 const extensions::PendingExtensionInfo* pending_extension_info = 527 const extensions::PendingExtensionInfo* pending_extension_info =
520 pending_extension_manager()->GetById(id); 528 pending_extension_manager()->GetById(id);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 installer->set_creation_flags(creation_flags); 597 installer->set_creation_flags(creation_flags);
590 598
591 installer->set_delete_source(file_ownership_passed); 599 installer->set_delete_source(file_ownership_passed);
592 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); 600 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
593 installer->InstallCrx(extension_path); 601 installer->InstallCrx(extension_path);
594 602
595 if (out_crx_installer) 603 if (out_crx_installer)
596 *out_crx_installer = installer.get(); 604 *out_crx_installer = installer.get();
597 605
598 return true; 606 return true;
607 #else
608 return false;
609 #endif
599 } 610 }
600 611
601 void ExtensionService::ReloadExtension( 612 void ExtensionService::ReloadExtension(
602 // "transient" because the process of reloading may cause the reference 613 // "transient" because the process of reloading may cause the reference
603 // to become invalid. Instead, use |extension_id|, a copy. 614 // to become invalid. Instead, use |extension_id|, a copy.
604 const std::string& transient_extension_id) { 615 const std::string& transient_extension_id) {
605 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 616 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
606 617
607 // If the extension is already reloading, don't reload again. 618 // If the extension is already reloading, don't reload again.
608 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
1170 1181
1171 for (size_t i = 0; i < to_unload.size(); ++i) 1182 for (size_t i = 0; i < to_unload.size(); ++i)
1172 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE); 1183 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE);
1173 1184
1174 for (std::map<std::string, Extension::DisableReason>::const_iterator i = 1185 for (std::map<std::string, Extension::DisableReason>::const_iterator i =
1175 to_disable.begin(); i != to_disable.end(); ++i) 1186 to_disable.begin(); i != to_disable.end(); ++i)
1176 DisableExtension(i->first, i->second); 1187 DisableExtension(i->first, i->second);
1177 } 1188 }
1178 1189
1179 void ExtensionService::CheckForUpdatesSoon() { 1190 void ExtensionService::CheckForUpdatesSoon() {
1191 #if defined(ENABLE_EXTENSIONS)
1180 // This can legitimately happen in unit tests. 1192 // This can legitimately happen in unit tests.
1181 if (!updater_.get()) 1193 if (!updater_.get())
1182 return; 1194 return;
1183 1195
1184 if (AreAllExternalProvidersReady()) { 1196 if (AreAllExternalProvidersReady()) {
1185 updater_->CheckSoon(); 1197 updater_->CheckSoon();
1186 } else { 1198 } else {
1187 // Sync can start updating before all the external providers are ready 1199 // Sync can start updating before all the external providers are ready
1188 // 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,
1189 // but not before. 1201 // but not before.
1190 update_once_all_providers_are_ready_ = true; 1202 update_once_all_providers_are_ready_ = true;
1191 } 1203 }
1204 #endif
1192 } 1205 }
1193 1206
1194 // Some extensions will autoupdate themselves externally from Chrome. These 1207 // Some extensions will autoupdate themselves externally from Chrome. These
1195 // are typically part of some larger client application package. To support 1208 // are typically part of some larger client application package. To support
1196 // 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
1197 // (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
1198 // 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
1199 // a new version is available. 1212 // a new version is available.
1200 // Errors are reported through ExtensionErrorReporter. Succcess is not 1213 // Errors are reported through ExtensionErrorReporter. Succcess is not
1201 // reported. 1214 // reported.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 for (i = external_extension_providers_.begin(); 1252 for (i = external_extension_providers_.begin();
1240 i != external_extension_providers_.end(); ++i) { 1253 i != external_extension_providers_.end(); ++i) {
1241 if (!i->get()->IsReady()) 1254 if (!i->get()->IsReady())
1242 return false; 1255 return false;
1243 } 1256 }
1244 return true; 1257 return true;
1245 } 1258 }
1246 1259
1247 void ExtensionService::OnAllExternalProvidersReady() { 1260 void ExtensionService::OnAllExternalProvidersReady() {
1248 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1261 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1262 #if defined(ENABLE_EXTENSIONS)
1249 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); 1263 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime();
1250 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); 1264 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed);
1251 1265
1252 // Install any pending extensions. 1266 // Install any pending extensions.
1253 if (update_once_all_providers_are_ready_ && updater()) { 1267 if (update_once_all_providers_are_ready_ && updater()) {
1254 update_once_all_providers_are_ready_ = false; 1268 update_once_all_providers_are_ready_ = false;
1255 extensions::ExtensionUpdater::CheckParams params; 1269 extensions::ExtensionUpdater::CheckParams params;
1256 params.callback = external_updates_finished_callback_; 1270 params.callback = external_updates_finished_callback_;
1257 updater()->CheckNow(params); 1271 updater()->CheckNow(params);
1258 } 1272 }
1259 1273
1260 // Uninstall all the unclaimed extensions. 1274 // Uninstall all the unclaimed extensions.
1261 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( 1275 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info(
1262 extension_prefs_->GetInstalledExtensionsInfo()); 1276 extension_prefs_->GetInstalledExtensionsInfo());
1263 for (size_t i = 0; i < extensions_info->size(); ++i) { 1277 for (size_t i = 0; i < extensions_info->size(); ++i) {
1264 ExtensionInfo* info = extensions_info->at(i).get(); 1278 ExtensionInfo* info = extensions_info->at(i).get();
1265 if (Manifest::IsExternalLocation(info->extension_location)) 1279 if (Manifest::IsExternalLocation(info->extension_location))
1266 CheckExternalUninstall(info->extension_id); 1280 CheckExternalUninstall(info->extension_id);
1267 } 1281 }
1268 1282
1269 error_controller_->ShowErrorIfNeeded(); 1283 error_controller_->ShowErrorIfNeeded();
1270 1284
1271 UpdateExternalExtensionAlert(); 1285 UpdateExternalExtensionAlert();
1286 #endif
1272 } 1287 }
1273 1288
1274 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { 1289 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) {
1275 extension_prefs_->AcknowledgeExternalExtension(id); 1290 extension_prefs_->AcknowledgeExternalExtension(id);
1276 UpdateExternalExtensionAlert(); 1291 UpdateExternalExtensionAlert();
1277 } 1292 }
1278 1293
1279 bool ExtensionService::IsUnacknowledgedExternalExtension( 1294 bool ExtensionService::IsUnacknowledgedExternalExtension(
1280 const Extension* extension) { 1295 const Extension* extension) {
1281 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 1296 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled())
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 known_disabled_count); 1340 known_disabled_count);
1326 1341
1327 // Update the list of known disabled to reflect every change to 1342 // Update the list of known disabled to reflect every change to
1328 // |disabled_extensions_| from this point forward. 1343 // |disabled_extensions_| from this point forward.
1329 registry_->SetDisabledModificationCallback( 1344 registry_->SetDisabledModificationCallback(
1330 base::Bind(&extensions::ExtensionPrefs::SetKnownDisabled, 1345 base::Bind(&extensions::ExtensionPrefs::SetKnownDisabled,
1331 base::Unretained(extension_prefs_))); 1346 base::Unretained(extension_prefs_)));
1332 } 1347 }
1333 1348
1334 void ExtensionService::UpdateExternalExtensionAlert() { 1349 void ExtensionService::UpdateExternalExtensionAlert() {
1350 #if defined(ENABLE_EXTENSIONS)
1335 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 1351 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled())
1336 return; 1352 return;
1337 1353
1338 const Extension* extension = NULL; 1354 const Extension* extension = NULL;
1339 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); 1355 const ExtensionSet& disabled_extensions = registry_->disabled_extensions();
1340 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); 1356 for (ExtensionSet::const_iterator iter = disabled_extensions.begin();
1341 iter != disabled_extensions.end(); ++iter) { 1357 iter != disabled_extensions.end(); ++iter) {
1342 const Extension* e = iter->get(); 1358 const Extension* e = iter->get();
1343 if (IsUnacknowledgedExternalExtension(e)) { 1359 if (IsUnacknowledgedExternalExtension(e)) {
1344 extension = e; 1360 extension = e;
(...skipping 29 matching lines...) Expand all
1374 extension_prefs_->SetExternalInstallFirstRun(extension->id()); 1390 extension_prefs_->SetExternalInstallFirstRun(extension->id());
1375 // first_run is true if the extension was installed during a first run 1391 // first_run is true if the extension was installed during a first run
1376 // (even if it's post-first run now). 1392 // (even if it's post-first run now).
1377 bool first_run = extension_prefs_->IsExternalInstallFirstRun( 1393 bool first_run = extension_prefs_->IsExternalInstallFirstRun(
1378 extension->id()); 1394 extension->id());
1379 extensions::AddExternalInstallError(this, extension, first_run); 1395 extensions::AddExternalInstallError(this, extension, first_run);
1380 } 1396 }
1381 } else { 1397 } else {
1382 extensions::RemoveExternalInstallError(this); 1398 extensions::RemoveExternalInstallError(this);
1383 } 1399 }
1400 #endif // defined(ENABLE_EXTENSIONS)
1384 } 1401 }
1385 1402
1386 void ExtensionService::UnloadExtension( 1403 void ExtensionService::UnloadExtension(
1387 const std::string& extension_id, 1404 const std::string& extension_id,
1388 UnloadedExtensionInfo::Reason reason) { 1405 UnloadedExtensionInfo::Reason reason) {
1389 // Make sure the extension gets deleted after we return from this function. 1406 // Make sure the extension gets deleted after we return from this function.
1390 int include_mask = 1407 int include_mask =
1391 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; 1408 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED;
1392 scoped_refptr<const Extension> extension( 1409 scoped_refptr<const Extension> extension(
1393 registry_->GetExtensionById(extension_id, include_mask)); 1410 registry_->GetExtensionById(extension_id, include_mask));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 1475
1459 void ExtensionService::SetReadyAndNotifyListeners() { 1476 void ExtensionService::SetReadyAndNotifyListeners() {
1460 ready_->Signal(); 1477 ready_->Signal();
1461 content::NotificationService::current()->Notify( 1478 content::NotificationService::current()->Notify(
1462 chrome::NOTIFICATION_EXTENSIONS_READY, 1479 chrome::NOTIFICATION_EXTENSIONS_READY,
1463 content::Source<Profile>(profile_), 1480 content::Source<Profile>(profile_),
1464 content::NotificationService::NoDetails()); 1481 content::NotificationService::NoDetails());
1465 } 1482 }
1466 1483
1467 void ExtensionService::OnLoadedInstalledExtensions() { 1484 void ExtensionService::OnLoadedInstalledExtensions() {
1485 #if defined(ENABLE_EXTENSIONS)
1468 if (updater_) 1486 if (updater_)
1469 updater_->Start(); 1487 updater_->Start();
1470 1488
1471 OnBlacklistUpdated(); 1489 OnBlacklistUpdated();
1490 #endif
1472 } 1491 }
1473 1492
1474 void ExtensionService::AddExtension(const Extension* extension) { 1493 void ExtensionService::AddExtension(const Extension* extension) {
1475 // TODO(jstritar): We may be able to get rid of this branch by overriding the 1494 // TODO(jstritar): We may be able to get rid of this branch by overriding the
1476 // default extension state to DISABLED when the --disable-extensions flag 1495 // default extension state to DISABLED when the --disable-extensions flag
1477 // is set (http://crbug.com/29067). 1496 // is set (http://crbug.com/29067).
1478 if (!extensions_enabled() && 1497 if (!extensions_enabled() &&
1479 !extension->is_theme() && 1498 !extension->is_theme() &&
1480 extension->location() != Manifest::COMPONENT && 1499 extension->location() != Manifest::COMPONENT &&
1481 !Manifest::IsExternalLocation(extension->location())) { 1500 !Manifest::IsExternalLocation(extension->location())) {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 } 2090 }
2072 2091
2073 bool ExtensionService::OnExternalExtensionFileFound( 2092 bool ExtensionService::OnExternalExtensionFileFound(
2074 const std::string& id, 2093 const std::string& id,
2075 const Version* version, 2094 const Version* version,
2076 const base::FilePath& path, 2095 const base::FilePath& path,
2077 Manifest::Location location, 2096 Manifest::Location location,
2078 int creation_flags, 2097 int creation_flags,
2079 bool mark_acknowledged) { 2098 bool mark_acknowledged) {
2080 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2099 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2100 #if defined(ENABLE_EXTENSIONS)
2081 CHECK(Extension::IdIsValid(id)); 2101 CHECK(Extension::IdIsValid(id));
2082 if (extension_prefs_->IsExternalExtensionUninstalled(id)) 2102 if (extension_prefs_->IsExternalExtensionUninstalled(id))
2083 return false; 2103 return false;
2084 2104
2085 // Before even bothering to unpack, check and see if we already have this 2105 // Before even bothering to unpack, check and see if we already have this
2086 // version. This is important because these extensions are going to get 2106 // version. This is important because these extensions are going to get
2087 // installed on every startup. 2107 // installed on every startup.
2088 const Extension* existing = GetExtensionById(id, true); 2108 const Extension* existing = GetExtensionById(id, true);
2089 2109
2090 if (existing) { 2110 if (existing) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 installer->InstallCrx(path); 2154 installer->InstallCrx(path);
2135 #endif 2155 #endif
2136 2156
2137 // Depending on the source, a new external extension might not need a user 2157 // Depending on the source, a new external extension might not need a user
2138 // notification on installation. For such extensions, mark them acknowledged 2158 // notification on installation. For such extensions, mark them acknowledged
2139 // now to suppress the notification. 2159 // now to suppress the notification.
2140 if (mark_acknowledged) 2160 if (mark_acknowledged)
2141 AcknowledgeExternalExtension(id); 2161 AcknowledgeExternalExtension(id);
2142 2162
2143 return true; 2163 return true;
2164 #else
2165 return false;
2166 #endif // defined(ENABLE_EXTENSIONS)
2144 } 2167 }
2145 2168
2146 void ExtensionService::DidCreateRenderViewForBackgroundPage( 2169 void ExtensionService::DidCreateRenderViewForBackgroundPage(
2147 extensions::ExtensionHost* host) { 2170 extensions::ExtensionHost* host) {
2148 OrphanedDevTools::iterator iter = 2171 OrphanedDevTools::iterator iter =
2149 orphaned_dev_tools_.find(host->extension_id()); 2172 orphaned_dev_tools_.find(host->extension_id());
2150 if (iter == orphaned_dev_tools_.end()) 2173 if (iter == orphaned_dev_tools_.end())
2151 return; 2174 return;
2152 2175
2153 iter->second->ConnectRenderViewHost(host->render_view_host()); 2176 iter->second->ConnectRenderViewHost(host->render_view_host());
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 } 2525 }
2503 2526
2504 void ExtensionService::OnProfileDestructionStarted() { 2527 void ExtensionService::OnProfileDestructionStarted() {
2505 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2528 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2506 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2529 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2507 it != ids_to_unload.end(); 2530 it != ids_to_unload.end();
2508 ++it) { 2531 ++it) {
2509 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2532 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2510 } 2533 }
2511 } 2534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698