| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 441 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 442 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 442 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 443 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 443 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| 444 MaybeUpdateAfterNotification(); | 444 MaybeUpdateAfterNotification(); |
| 445 break; | 445 break; |
| 446 default: | 446 default: |
| 447 NOTREACHED(); | 447 NOTREACHED(); |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 | 450 |
| 451 void ExtensionSettingsHandler::OnPreferenceChanged( | |
| 452 PrefServiceBase* service, | |
| 453 const std::string& pref_name) { | |
| 454 MaybeUpdateAfterNotification(); | |
| 455 } | |
| 456 | |
| 457 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { | 451 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { |
| 458 DCHECK(!extension_id_prompting_.empty()); | 452 DCHECK(!extension_id_prompting_.empty()); |
| 459 | 453 |
| 460 bool was_terminated = false; | 454 bool was_terminated = false; |
| 461 | 455 |
| 462 // The extension can be uninstalled in another window while the UI was | 456 // The extension can be uninstalled in another window while the UI was |
| 463 // showing. Do nothing in that case. | 457 // showing. Do nothing in that case. |
| 464 const Extension* extension = | 458 const Extension* extension = |
| 465 extension_service_->GetExtensionById(extension_id_prompting_, true); | 459 extension_service_->GetExtensionById(extension_id_prompting_, true); |
| 466 if (!extension) { | 460 if (!extension) { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 content::NotificationService::AllBrowserContextsAndSources()); | 840 content::NotificationService::AllBrowserContextsAndSources()); |
| 847 registrar_.Add( | 841 registrar_.Add( |
| 848 this, | 842 this, |
| 849 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 843 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
| 850 content::Source<extensions::ExtensionPrefs>( | 844 content::Source<extensions::ExtensionPrefs>( |
| 851 profile->GetExtensionService()->extension_prefs())); | 845 profile->GetExtensionService()->extension_prefs())); |
| 852 | 846 |
| 853 warning_service_observer_.Add( | 847 warning_service_observer_.Add( |
| 854 extensions::ExtensionSystem::Get(profile)->warning_service()); | 848 extensions::ExtensionSystem::Get(profile)->warning_service()); |
| 855 | 849 |
| 850 base::Closure callback = base::Bind( |
| 851 &ExtensionSettingsHandler::MaybeUpdateAfterNotification, |
| 852 base::Unretained(this)); |
| 853 |
| 856 pref_registrar_.Init(profile->GetPrefs()); | 854 pref_registrar_.Init(profile->GetPrefs()); |
| 857 pref_registrar_.Add(prefs::kExtensionInstallDenyList, this); | 855 pref_registrar_.Add(prefs::kExtensionInstallDenyList, callback); |
| 858 local_state_pref_registrar_.Init(g_browser_process->local_state()); | 856 local_state_pref_registrar_.Init(g_browser_process->local_state()); |
| 859 local_state_pref_registrar_.Add(prefs::kInManagedMode, this); | 857 local_state_pref_registrar_.Add(prefs::kInManagedMode, callback); |
| 860 } | 858 } |
| 861 | 859 |
| 862 std::vector<ExtensionPage> | 860 std::vector<ExtensionPage> |
| 863 ExtensionSettingsHandler::GetInspectablePagesForExtension( | 861 ExtensionSettingsHandler::GetInspectablePagesForExtension( |
| 864 const Extension* extension, bool extension_is_enabled) { | 862 const Extension* extension, bool extension_is_enabled) { |
| 865 std::vector<ExtensionPage> result; | 863 std::vector<ExtensionPage> result; |
| 866 | 864 |
| 867 // Get the extension process's active views. | 865 // Get the extension process's active views. |
| 868 ExtensionProcessManager* process_manager = | 866 ExtensionProcessManager* process_manager = |
| 869 extensions::ExtensionSystem::Get(extension_service_->profile())-> | 867 extensions::ExtensionSystem::Get(extension_service_->profile())-> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 std::vector<std::string> requirement_errors) { | 967 std::vector<std::string> requirement_errors) { |
| 970 if (requirement_errors.empty()) { | 968 if (requirement_errors.empty()) { |
| 971 extension_service_->EnableExtension(extension_id); | 969 extension_service_->EnableExtension(extension_id); |
| 972 } else { | 970 } else { |
| 973 ExtensionErrorReporter::GetInstance()->ReportError( | 971 ExtensionErrorReporter::GetInstance()->ReportError( |
| 974 UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 972 UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 975 true /* be noisy */); | 973 true /* be noisy */); |
| 976 } | 974 } |
| 977 requirements_checker_.reset(); | 975 requirements_checker_.reset(); |
| 978 } | 976 } |
| OLD | NEW |