| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/extensions/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
| 6 | 6 |
| 7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "apps/saved_files_service.h" | 8 #include "apps/saved_files_service.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 management_policy_(NULL), | 165 management_policy_(NULL), |
| 166 ignore_notifications_(false), | 166 ignore_notifications_(false), |
| 167 deleting_rvh_(NULL), | 167 deleting_rvh_(NULL), |
| 168 deleting_rwh_id_(-1), | 168 deleting_rwh_id_(-1), |
| 169 deleting_rph_id_(-1), | 169 deleting_rph_id_(-1), |
| 170 registered_for_notifications_(false), | 170 registered_for_notifications_(false), |
| 171 warning_service_observer_(this), | 171 warning_service_observer_(this), |
| 172 error_console_observer_(this), | 172 error_console_observer_(this), |
| 173 extension_prefs_observer_(this), | 173 extension_prefs_observer_(this), |
| 174 extension_registry_observer_(this), | 174 extension_registry_observer_(this), |
| 175 extension_management_observer_(this), |
| 175 should_do_verification_check_(false) { | 176 should_do_verification_check_(false) { |
| 176 } | 177 } |
| 177 | 178 |
| 178 ExtensionSettingsHandler::~ExtensionSettingsHandler() { | 179 ExtensionSettingsHandler::~ExtensionSettingsHandler() { |
| 179 } | 180 } |
| 180 | 181 |
| 181 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, | 182 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, |
| 182 ManagementPolicy* policy) | 183 ManagementPolicy* policy) |
| 183 : extension_service_(service), | 184 : extension_service_(service), |
| 184 management_policy_(policy), | 185 management_policy_(policy), |
| 185 ignore_notifications_(false), | 186 ignore_notifications_(false), |
| 186 deleting_rvh_(NULL), | 187 deleting_rvh_(NULL), |
| 187 deleting_rwh_id_(-1), | 188 deleting_rwh_id_(-1), |
| 188 deleting_rph_id_(-1), | 189 deleting_rph_id_(-1), |
| 189 registered_for_notifications_(false), | 190 registered_for_notifications_(false), |
| 190 warning_service_observer_(this), | 191 warning_service_observer_(this), |
| 191 error_console_observer_(this), | 192 error_console_observer_(this), |
| 192 extension_prefs_observer_(this), | 193 extension_prefs_observer_(this), |
| 193 extension_registry_observer_(this), | 194 extension_registry_observer_(this), |
| 195 extension_management_observer_(this), |
| 194 should_do_verification_check_(false) { | 196 should_do_verification_check_(false) { |
| 195 } | 197 } |
| 196 | 198 |
| 197 // static | 199 // static |
| 198 void ExtensionSettingsHandler::RegisterProfilePrefs( | 200 void ExtensionSettingsHandler::RegisterProfilePrefs( |
| 199 user_prefs::PrefRegistrySyncable* registry) { | 201 user_prefs::PrefRegistrySyncable* registry) { |
| 200 registry->RegisterBooleanPref( | 202 registry->RegisterBooleanPref( |
| 201 prefs::kExtensionsUIDeveloperMode, | 203 prefs::kExtensionsUIDeveloperMode, |
| 202 false, | 204 false, |
| 203 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 205 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 const Extension* extension, | 743 const Extension* extension, |
| 742 extensions::UninstallReason reason) { | 744 extensions::UninstallReason reason) { |
| 743 MaybeUpdateAfterNotification(); | 745 MaybeUpdateAfterNotification(); |
| 744 } | 746 } |
| 745 | 747 |
| 746 void ExtensionSettingsHandler::OnExtensionDisableReasonsChanged( | 748 void ExtensionSettingsHandler::OnExtensionDisableReasonsChanged( |
| 747 const std::string& extension_id, int disable_reasons) { | 749 const std::string& extension_id, int disable_reasons) { |
| 748 MaybeUpdateAfterNotification(); | 750 MaybeUpdateAfterNotification(); |
| 749 } | 751 } |
| 750 | 752 |
| 753 void ExtensionSettingsHandler::OnExtensionManagementSettingsChanged() { |
| 754 MaybeUpdateAfterNotification(); |
| 755 } |
| 756 |
| 751 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { | 757 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { |
| 752 DCHECK(!extension_id_prompting_.empty()); | 758 DCHECK(!extension_id_prompting_.empty()); |
| 753 | 759 |
| 754 bool was_terminated = false; | 760 bool was_terminated = false; |
| 755 | 761 |
| 756 // The extension can be uninstalled in another window while the UI was | 762 // The extension can be uninstalled in another window while the UI was |
| 757 // showing. Do nothing in that case. | 763 // showing. Do nothing in that case. |
| 758 const Extension* extension = | 764 const Extension* extension = |
| 759 extension_service_->GetExtensionById(extension_id_prompting_, true); | 765 extension_service_->GetExtensionById(extension_id_prompting_, true); |
| 760 if (!extension) { | 766 if (!extension) { |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 | 1265 |
| 1260 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 1266 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
| 1261 | 1267 |
| 1262 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); | 1268 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); |
| 1263 | 1269 |
| 1264 warning_service_observer_.Add( | 1270 warning_service_observer_.Add( |
| 1265 ExtensionSystem::Get(profile)->warning_service()); | 1271 ExtensionSystem::Get(profile)->warning_service()); |
| 1266 | 1272 |
| 1267 error_console_observer_.Add(ErrorConsole::Get(profile)); | 1273 error_console_observer_.Add(ErrorConsole::Get(profile)); |
| 1268 | 1274 |
| 1269 base::Closure callback = base::Bind( | 1275 extension_management_observer_.Add( |
| 1270 &ExtensionSettingsHandler::MaybeUpdateAfterNotification, | 1276 ExtensionManagementFactory::GetForBrowserContext(profile)); |
| 1271 AsWeakPtr()); | |
| 1272 | |
| 1273 pref_registrar_.Init(profile->GetPrefs()); | |
| 1274 pref_registrar_.Add(pref_names::kInstallDenyList, callback); | |
| 1275 } | 1277 } |
| 1276 | 1278 |
| 1277 std::vector<ExtensionPage> | 1279 std::vector<ExtensionPage> |
| 1278 ExtensionSettingsHandler::GetInspectablePagesForExtension( | 1280 ExtensionSettingsHandler::GetInspectablePagesForExtension( |
| 1279 const Extension* extension, bool extension_is_enabled) { | 1281 const Extension* extension, bool extension_is_enabled) { |
| 1280 std::vector<ExtensionPage> result; | 1282 std::vector<ExtensionPage> result; |
| 1281 | 1283 |
| 1282 // Get the extension process's active views. | 1284 // Get the extension process's active views. |
| 1283 extensions::ProcessManager* process_manager = | 1285 extensions::ProcessManager* process_manager = |
| 1284 ExtensionSystem::Get(extension_service_->profile())->process_manager(); | 1286 ExtensionSystem::Get(extension_service_->profile())->process_manager(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 extension_service_->EnableExtension(extension_id); | 1417 extension_service_->EnableExtension(extension_id); |
| 1416 } else { | 1418 } else { |
| 1417 ExtensionErrorReporter::GetInstance()->ReportError( | 1419 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1418 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1420 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1419 true); // Be noisy. | 1421 true); // Be noisy. |
| 1420 } | 1422 } |
| 1421 requirements_checker_.reset(); | 1423 requirements_checker_.reset(); |
| 1422 } | 1424 } |
| 1423 | 1425 |
| 1424 } // namespace extensions | 1426 } // namespace extensions |
| OLD | NEW |