| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "base/version.h" | 18 #include "base/version.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/devtools/devtools_window.h" | 20 #include "chrome/browser/devtools/devtools_window.h" |
| 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 21 #include "chrome/browser/extensions/crx_installer.h" | 22 #include "chrome/browser/extensions/crx_installer.h" |
| 22 #include "chrome/browser/extensions/extension_action_manager.h" | 23 #include "chrome/browser/extensions/extension_action_manager.h" |
| 23 #include "chrome/browser/extensions/extension_disabled_ui.h" | 24 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 24 #include "chrome/browser/extensions/extension_error_reporter.h" | 25 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 25 #include "chrome/browser/extensions/extension_host.h" | 26 #include "chrome/browser/extensions/extension_host.h" |
| 26 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/extensions/extension_system.h" | 28 #include "chrome/browser/extensions/extension_system.h" |
| 28 #include "chrome/browser/extensions/extension_tab_util.h" | 29 #include "chrome/browser/extensions/extension_tab_util.h" |
| 29 #include "chrome/browser/extensions/extension_warning_set.h" | 30 #include "chrome/browser/extensions/extension_warning_set.h" |
| 30 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 31 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 extension_data->SetBoolean("homepageProvided", | 171 extension_data->SetBoolean("homepageProvided", |
| 171 extensions::ManifestURL::GetHomepageURL(extension).is_valid()); | 172 extensions::ManifestURL::GetHomepageURL(extension).is_valid()); |
| 172 | 173 |
| 173 // Determine the sort order: Extensions loaded through --load-extensions show | 174 // Determine the sort order: Extensions loaded through --load-extensions show |
| 174 // up at the top. Disabled extensions show up at the bottom. | 175 // up at the top. Disabled extensions show up at the bottom. |
| 175 if (Manifest::IsUnpackedLocation(extension->location())) | 176 if (Manifest::IsUnpackedLocation(extension->location())) |
| 176 extension_data->SetInteger("order", 1); | 177 extension_data->SetInteger("order", 1); |
| 177 else | 178 else |
| 178 extension_data->SetInteger("order", 2); | 179 extension_data->SetInteger("order", 2); |
| 179 | 180 |
| 180 if (!extension_service_->extension_prefs()-> | 181 if (!extensions::ExtensionActionAPI::GetBrowserActionVisibility( |
| 181 GetBrowserActionVisibility(extension)) { | 182 extension_service_->extension_prefs(), extension->id())) { |
| 182 extension_data->SetBoolean("enable_show_button", true); | 183 extension_data->SetBoolean("enable_show_button", true); |
| 183 } | 184 } |
| 184 | 185 |
| 185 // Add views | 186 // Add views |
| 186 ListValue* views = new ListValue; | 187 ListValue* views = new ListValue; |
| 187 for (std::vector<ExtensionPage>::const_iterator iter = pages.begin(); | 188 for (std::vector<ExtensionPage>::const_iterator iter = pages.begin(); |
| 188 iter != pages.end(); ++iter) { | 189 iter != pages.end(); ++iter) { |
| 189 DictionaryValue* view_value = new DictionaryValue; | 190 DictionaryValue* view_value = new DictionaryValue; |
| 190 if (iter->url.scheme() == extensions::kExtensionScheme) { | 191 if (iter->url.scheme() == extensions::kExtensionScheme) { |
| 191 // No leading slash. | 192 // No leading slash. |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 true /* include disabled */); | 767 true /* include disabled */); |
| 767 requirements_checker_.reset(new extensions::RequirementsChecker()); | 768 requirements_checker_.reset(new extensions::RequirementsChecker()); |
| 768 requirements_checker_->Check( | 769 requirements_checker_->Check( |
| 769 extension, | 770 extension, |
| 770 base::Bind(&ExtensionSettingsHandler::OnRequirementsChecked, | 771 base::Bind(&ExtensionSettingsHandler::OnRequirementsChecked, |
| 771 AsWeakPtr(), extension_id)); | 772 AsWeakPtr(), extension_id)); |
| 772 } else { | 773 } else { |
| 773 extension_service_->EnableExtension(extension_id); | 774 extension_service_->EnableExtension(extension_id); |
| 774 | 775 |
| 775 // Make sure any browser action contained within it is not hidden. | 776 // Make sure any browser action contained within it is not hidden. |
| 776 prefs->SetBrowserActionVisibility(extension, true); | 777 extensions::ExtensionActionAPI::SetBrowserActionVisibility( |
| 778 prefs, extension->id(), true); |
| 777 } | 779 } |
| 778 } else { | 780 } else { |
| 779 // Get managed user elevation for a specific extension id. The elevation | 781 // Get managed user elevation for a specific extension id. The elevation |
| 780 // will be removed automatically when |elevation| goes out of scope. | 782 // will be removed automatically when |elevation| goes out of scope. |
| 781 scoped_ptr<ScopedExtensionElevation> elevation = | 783 scoped_ptr<ScopedExtensionElevation> elevation = |
| 782 GetScopedElevation(extension_id); | 784 GetScopedElevation(extension_id); |
| 783 extension_service_->DisableExtension( | 785 extension_service_->DisableExtension( |
| 784 extension_id, Extension::DISABLE_USER_ACTION); | 786 extension_id, Extension::DISABLE_USER_ACTION); |
| 785 } | 787 } |
| 786 } | 788 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 return; | 877 return; |
| 876 | 878 |
| 877 prompt_.reset(new ExtensionInstallPrompt(web_contents())); | 879 prompt_.reset(new ExtensionInstallPrompt(web_contents())); |
| 878 prompt_->ReviewPermissions(this, extension); | 880 prompt_->ReviewPermissions(this, extension); |
| 879 } | 881 } |
| 880 | 882 |
| 881 void ExtensionSettingsHandler::HandleShowButtonMessage(const ListValue* args) { | 883 void ExtensionSettingsHandler::HandleShowButtonMessage(const ListValue* args) { |
| 882 const Extension* extension = GetActiveExtension(args); | 884 const Extension* extension = GetActiveExtension(args); |
| 883 if (!extension) | 885 if (!extension) |
| 884 return; | 886 return; |
| 885 extension_service_->extension_prefs()-> | 887 extensions::ExtensionActionAPI::SetBrowserActionVisibility( |
| 886 SetBrowserActionVisibility(extension, true); | 888 extension_service_->extension_prefs(), extension->id(), true); |
| 887 } | 889 } |
| 888 | 890 |
| 889 void ExtensionSettingsHandler::HandleAutoUpdateMessage(const ListValue* args) { | 891 void ExtensionSettingsHandler::HandleAutoUpdateMessage(const ListValue* args) { |
| 890 ExtensionUpdater* updater = extension_service_->updater(); | 892 ExtensionUpdater* updater = extension_service_->updater(); |
| 891 if (updater) { | 893 if (updater) { |
| 892 ExtensionUpdater::CheckParams params; | 894 ExtensionUpdater::CheckParams params; |
| 893 params.install_immediately = true; | 895 params.install_immediately = true; |
| 894 updater->CheckNow(params); | 896 updater->CheckNow(params); |
| 895 } | 897 } |
| 896 } | 898 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 std::vector<std::string> requirement_errors) { | 1098 std::vector<std::string> requirement_errors) { |
| 1097 if (requirement_errors.empty()) { | 1099 if (requirement_errors.empty()) { |
| 1098 extension_service_->EnableExtension(extension_id); | 1100 extension_service_->EnableExtension(extension_id); |
| 1099 } else { | 1101 } else { |
| 1100 ExtensionErrorReporter::GetInstance()->ReportError( | 1102 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1101 UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1103 UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1102 true /* be noisy */); | 1104 true /* be noisy */); |
| 1103 } | 1105 } |
| 1104 requirements_checker_.reset(); | 1106 requirements_checker_.reset(); |
| 1105 } | 1107 } |
| OLD | NEW |