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