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_devices_service.h" |
8 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
9 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
10 #include "base/base64.h" | 11 #include "base/base64.h" |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/location.h" | 15 #include "base/location.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 790 } |
790 | 791 |
791 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { | 792 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { |
792 extension_id_prompting_ = ""; | 793 extension_id_prompting_ = ""; |
793 } | 794 } |
794 | 795 |
795 void ExtensionSettingsHandler::ExtensionWarningsChanged() { | 796 void ExtensionSettingsHandler::ExtensionWarningsChanged() { |
796 MaybeUpdateAfterNotification(); | 797 MaybeUpdateAfterNotification(); |
797 } | 798 } |
798 | 799 |
799 // This is called when the user clicks "Revoke File Access." | 800 // This is called when the user clicks "Revoke File/Device Access." |
800 void ExtensionSettingsHandler::InstallUIProceed() { | 801 void ExtensionSettingsHandler::InstallUIProceed() { |
801 Profile* profile = Profile::FromWebUI(web_ui()); | 802 Profile* profile = Profile::FromWebUI(web_ui()); |
| 803 apps::SavedDevicesService::Get(profile)->Clear(extension_id_prompting_); |
802 apps::SavedFilesService::Get(profile)->ClearQueue( | 804 apps::SavedFilesService::Get(profile)->ClearQueue( |
803 extension_service_->GetExtensionById(extension_id_prompting_, true)); | 805 extension_service_->GetExtensionById(extension_id_prompting_, true)); |
804 apps::AppLoadService::Get(profile) | 806 apps::AppLoadService::Get(profile) |
805 ->RestartApplicationIfRunning(extension_id_prompting_); | 807 ->RestartApplicationIfRunning(extension_id_prompting_); |
806 extension_id_prompting_.clear(); | 808 extension_id_prompting_.clear(); |
807 } | 809 } |
808 | 810 |
809 void ExtensionSettingsHandler::InstallUIAbort(bool user_initiated) { | 811 void ExtensionSettingsHandler::InstallUIAbort(bool user_initiated) { |
810 extension_id_prompting_.clear(); | 812 extension_id_prompting_.clear(); |
811 } | 813 } |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 std::vector<base::FilePath> retained_file_paths; | 1157 std::vector<base::FilePath> retained_file_paths; |
1156 if (extension->permissions_data()->HasAPIPermission( | 1158 if (extension->permissions_data()->HasAPIPermission( |
1157 APIPermission::kFileSystem)) { | 1159 APIPermission::kFileSystem)) { |
1158 std::vector<apps::SavedFileEntry> retained_file_entries = | 1160 std::vector<apps::SavedFileEntry> retained_file_entries = |
1159 apps::SavedFilesService::Get(Profile::FromWebUI( | 1161 apps::SavedFilesService::Get(Profile::FromWebUI( |
1160 web_ui()))->GetAllFileEntries(extension_id_prompting_); | 1162 web_ui()))->GetAllFileEntries(extension_id_prompting_); |
1161 for (size_t i = 0; i < retained_file_entries.size(); ++i) { | 1163 for (size_t i = 0; i < retained_file_entries.size(); ++i) { |
1162 retained_file_paths.push_back(retained_file_entries[i].path); | 1164 retained_file_paths.push_back(retained_file_entries[i].path); |
1163 } | 1165 } |
1164 } | 1166 } |
| 1167 std::vector<base::string16> retained_device_messages; |
| 1168 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { |
| 1169 retained_device_messages = |
| 1170 apps::SavedDevicesService::Get(Profile::FromWebUI(web_ui())) |
| 1171 ->GetPermissionMessageStrings(extension_id_prompting_); |
| 1172 } |
| 1173 |
1165 // The BrokerDelegate manages its own lifetime. | 1174 // The BrokerDelegate manages its own lifetime. |
1166 prompt_->ReviewPermissions( | 1175 prompt_->ReviewPermissions(new BrokerDelegate(AsWeakPtr()), |
1167 new BrokerDelegate(AsWeakPtr()), extension, retained_file_paths); | 1176 extension, |
| 1177 retained_file_paths, |
| 1178 retained_device_messages); |
1168 } | 1179 } |
1169 | 1180 |
1170 void ExtensionSettingsHandler::HandleShowButtonMessage( | 1181 void ExtensionSettingsHandler::HandleShowButtonMessage( |
1171 const base::ListValue* args) { | 1182 const base::ListValue* args) { |
1172 const Extension* extension = GetActiveExtension(args); | 1183 const Extension* extension = GetActiveExtension(args); |
1173 if (!extension) | 1184 if (!extension) |
1174 return; | 1185 return; |
1175 ExtensionActionAPI::SetBrowserActionVisibility( | 1186 ExtensionActionAPI::SetBrowserActionVisibility( |
1176 ExtensionPrefs::Get(extension_service_->profile()), | 1187 ExtensionPrefs::Get(extension_service_->profile()), |
1177 extension->id(), | 1188 extension->id(), |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 extension_service_->EnableExtension(extension_id); | 1427 extension_service_->EnableExtension(extension_id); |
1417 } else { | 1428 } else { |
1418 ExtensionErrorReporter::GetInstance()->ReportError( | 1429 ExtensionErrorReporter::GetInstance()->ReportError( |
1419 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1430 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
1420 true); // Be noisy. | 1431 true); // Be noisy. |
1421 } | 1432 } |
1422 requirements_checker_.reset(); | 1433 requirements_checker_.reset(); |
1423 } | 1434 } |
1424 | 1435 |
1425 } // namespace extensions | 1436 } // namespace extensions |
OLD | NEW |