| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ready_(false) { | 114 ready_(false) { |
| 115 // Figure out if extension installation should be enabled. | 115 // Figure out if extension installation should be enabled. |
| 116 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 116 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 117 extensions_enabled_ = false; | 117 extensions_enabled_ = false; |
| 118 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 118 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 119 extensions_enabled_ = false; | 119 extensions_enabled_ = false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 122 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, |
| 123 NotificationService::AllSources()); | 123 NotificationService::AllSources()); |
| 124 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, |
| 125 Source<Profile>(profile_)); |
| 124 | 126 |
| 125 // Set up the ExtensionUpdater | 127 // Set up the ExtensionUpdater |
| 126 if (autoupdate_enabled) { | 128 if (autoupdate_enabled) { |
| 127 int update_frequency = kDefaultUpdateFrequencySeconds; | 129 int update_frequency = kDefaultUpdateFrequencySeconds; |
| 128 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 130 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| 129 update_frequency = StringToInt(command_line->GetSwitchValueASCII( | 131 update_frequency = StringToInt(command_line->GetSwitchValueASCII( |
| 130 switches::kExtensionsUpdateFrequency)); | 132 switches::kExtensionsUpdateFrequency)); |
| 131 } | 133 } |
| 132 updater_ = new ExtensionUpdater(this, prefs, update_frequency); | 134 updater_ = new ExtensionUpdater(this, prefs, update_frequency); |
| 133 } | 135 } |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 orphaned_dev_tools_.find(host->extension()->id()); | 833 orphaned_dev_tools_.find(host->extension()->id()); |
| 832 if (iter == orphaned_dev_tools_.end()) | 834 if (iter == orphaned_dev_tools_.end()) |
| 833 return; | 835 return; |
| 834 | 836 |
| 835 DevToolsManager::GetInstance()->AttachClientHost( | 837 DevToolsManager::GetInstance()->AttachClientHost( |
| 836 iter->second, host->render_view_host()); | 838 iter->second, host->render_view_host()); |
| 837 orphaned_dev_tools_.erase(iter); | 839 orphaned_dev_tools_.erase(iter); |
| 838 break; | 840 break; |
| 839 } | 841 } |
| 840 | 842 |
| 843 case NotificationType::EXTENSION_PROCESS_CRASHED: { |
| 844 DCHECK_EQ(profile_, Source<Profile>(source).ptr()); |
| 845 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); |
| 846 |
| 847 // Unload the entire extension. We want it to be in a consistent state: |
| 848 // either fully working or not loaded at all, but never half-crashed. |
| 849 UnloadExtension(host->extension()->id()); |
| 850 break; |
| 851 } |
| 852 |
| 841 default: | 853 default: |
| 842 NOTREACHED() << "Unexpected notification type."; | 854 NOTREACHED() << "Unexpected notification type."; |
| 843 } | 855 } |
| 844 } | 856 } |
| 845 | 857 |
| 846 | 858 |
| 847 // ExtensionsServicesBackend | 859 // ExtensionsServicesBackend |
| 848 | 860 |
| 849 ExtensionsServiceBackend::ExtensionsServiceBackend( | 861 ExtensionsServiceBackend::ExtensionsServiceBackend( |
| 850 const FilePath& install_directory) | 862 const FilePath& install_directory) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 | 1003 |
| 992 void ExtensionsServiceBackend::OnExternalExtensionFound( | 1004 void ExtensionsServiceBackend::OnExternalExtensionFound( |
| 993 const std::string& id, const Version* version, const FilePath& path, | 1005 const std::string& id, const Version* version, const FilePath& path, |
| 994 Extension::Location location) { | 1006 Extension::Location location) { |
| 995 ChromeThread::PostTask( | 1007 ChromeThread::PostTask( |
| 996 ChromeThread::UI, FROM_HERE, | 1008 ChromeThread::UI, FROM_HERE, |
| 997 NewRunnableMethod( | 1009 NewRunnableMethod( |
| 998 frontend_, &ExtensionsService::OnExternalExtensionFound, id, | 1010 frontend_, &ExtensionsService::OnExternalExtensionFound, id, |
| 999 version->GetString(), path, location)); | 1011 version->GetString(), path, location)); |
| 1000 } | 1012 } |
| OLD | NEW |