| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Figure out if extension installation should be enabled. | 197 // Figure out if extension installation should be enabled. |
| 198 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 198 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 199 extensions_enabled_ = false; | 199 extensions_enabled_ = false; |
| 200 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 200 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 201 extensions_enabled_ = false; | 201 extensions_enabled_ = false; |
| 202 } | 202 } |
| 203 | 203 |
| 204 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 204 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, |
| 205 NotificationService::AllSources()); | 205 NotificationService::AllSources()); |
| 206 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, | 206 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, |
| 207 Source<Profile>(profile_)); | 207 NotificationService::AllSources()); |
| 208 prefs->AddPrefObserver(prefs::kExtensionInstallAllowList, this); | 208 prefs->AddPrefObserver(prefs::kExtensionInstallAllowList, this); |
| 209 prefs->AddPrefObserver(prefs::kExtensionInstallDenyList, this); | 209 prefs->AddPrefObserver(prefs::kExtensionInstallDenyList, this); |
| 210 | 210 |
| 211 // Set up the ExtensionUpdater | 211 // Set up the ExtensionUpdater |
| 212 if (autoupdate_enabled) { | 212 if (autoupdate_enabled) { |
| 213 int update_frequency = kDefaultUpdateFrequencySeconds; | 213 int update_frequency = kDefaultUpdateFrequencySeconds; |
| 214 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 214 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| 215 base::StringToInt(command_line->GetSwitchValueASCII( | 215 base::StringToInt(command_line->GetSwitchValueASCII( |
| 216 switches::kExtensionsUpdateFrequency), | 216 switches::kExtensionsUpdateFrequency), |
| 217 &update_frequency); | 217 &update_frequency); |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 if (iter == orphaned_dev_tools_.end()) | 1351 if (iter == orphaned_dev_tools_.end()) |
| 1352 return; | 1352 return; |
| 1353 | 1353 |
| 1354 DevToolsManager::GetInstance()->AttachClientHost( | 1354 DevToolsManager::GetInstance()->AttachClientHost( |
| 1355 iter->second, host->render_view_host()); | 1355 iter->second, host->render_view_host()); |
| 1356 orphaned_dev_tools_.erase(iter); | 1356 orphaned_dev_tools_.erase(iter); |
| 1357 break; | 1357 break; |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 case NotificationType::EXTENSION_PROCESS_TERMINATED: { | 1360 case NotificationType::EXTENSION_PROCESS_TERMINATED: { |
| 1361 DCHECK_EQ(profile_, Source<Profile>(source).ptr()); | 1361 if (profile_ != Source<Profile>(source).ptr()->GetOriginalProfile()) |
| 1362 break; |
| 1362 | 1363 |
| 1363 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); | 1364 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); |
| 1364 | 1365 |
| 1365 // TODO(rafaelw): Remove this check and ExtensionHost::recently_deleted(). | 1366 // TODO(rafaelw): Remove this check and ExtensionHost::recently_deleted(). |
| 1366 // This is only here to help track down crbug.com/49114. | 1367 // This is only here to help track down crbug.com/49114. |
| 1367 ExtensionHost::HostPointerList::iterator iter = | 1368 ExtensionHost::HostPointerList::iterator iter = |
| 1368 ExtensionHost::recently_deleted()->begin(); | 1369 ExtensionHost::recently_deleted()->begin(); |
| 1369 for (; iter != ExtensionHost::recently_deleted()->end(); iter++) { | 1370 for (; iter != ExtensionHost::recently_deleted()->end(); iter++) { |
| 1370 if (*iter == host) { | 1371 if (*iter == host) { |
| 1371 CHECK(host->GetURL().spec().size() + 2 != 0); | 1372 CHECK(host->GetURL().spec().size() + 2 != 0); |
| 1372 break; | 1373 break; |
| 1373 } | 1374 } |
| 1374 } | 1375 } |
| 1375 if (iter == ExtensionHost::recently_deleted()->end()) | 1376 if (iter == ExtensionHost::recently_deleted()->end()) |
| 1376 CHECK(host->GetURL().spec().size() + 1 != 0); | 1377 CHECK(host->GetURL().spec().size() + 1 != 0); |
| 1377 | 1378 |
| 1378 // Unload the entire extension. We want it to be in a consistent state: | 1379 // Unload the entire extension. We want it to be in a consistent state: |
| 1379 // either fully working or not loaded at all, but never half-crashed. | 1380 // either fully working or not loaded at all, but never half-crashed. |
| 1380 UnloadExtension(host->extension()->id()); | 1381 // We do it in a PostTask so that other handlers of this notification will |
| 1382 // still have access to the Extension and ExtensionHost. |
| 1383 MessageLoop::current()->PostTask(FROM_HERE, |
| 1384 NewRunnableMethod(this, &ExtensionsService::UnloadExtension, |
| 1385 host->extension()->id())); |
| 1381 break; | 1386 break; |
| 1382 } | 1387 } |
| 1383 | 1388 |
| 1384 case NotificationType::PREF_CHANGED: { | 1389 case NotificationType::PREF_CHANGED: { |
| 1385 std::string* pref_name = Details<std::string>(details).ptr(); | 1390 std::string* pref_name = Details<std::string>(details).ptr(); |
| 1386 DCHECK(*pref_name == prefs::kExtensionInstallAllowList || | 1391 DCHECK(*pref_name == prefs::kExtensionInstallAllowList || |
| 1387 *pref_name == prefs::kExtensionInstallDenyList); | 1392 *pref_name == prefs::kExtensionInstallDenyList); |
| 1388 CheckAdminBlacklist(); | 1393 CheckAdminBlacklist(); |
| 1389 break; | 1394 break; |
| 1390 } | 1395 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 // Finish installing on UI thread. | 1612 // Finish installing on UI thread. |
| 1608 ChromeThread::PostTask( | 1613 ChromeThread::PostTask( |
| 1609 ChromeThread::UI, FROM_HERE, | 1614 ChromeThread::UI, FROM_HERE, |
| 1610 NewRunnableMethod( | 1615 NewRunnableMethod( |
| 1611 frontend_, | 1616 frontend_, |
| 1612 &ExtensionsService::ContinueLoadAllExtensions, | 1617 &ExtensionsService::ContinueLoadAllExtensions, |
| 1613 extensions_to_reload, | 1618 extensions_to_reload, |
| 1614 start_time, | 1619 start_time, |
| 1615 true)); | 1620 true)); |
| 1616 } | 1621 } |
| OLD | NEW |