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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "components/pref_registry/pref_registry_syncable.h" | 65 #include "components/pref_registry/pref_registry_syncable.h" |
66 #include "content/public/browser/notification_service.h" | 66 #include "content/public/browser/notification_service.h" |
67 #include "content/public/browser/notification_source.h" | 67 #include "content/public/browser/notification_source.h" |
68 #include "content/public/browser/notification_types.h" | 68 #include "content/public/browser/notification_types.h" |
69 #include "content/public/browser/render_process_host.h" | 69 #include "content/public/browser/render_process_host.h" |
70 #include "content/public/browser/render_view_host.h" | 70 #include "content/public/browser/render_view_host.h" |
71 #include "content/public/browser/site_instance.h" | 71 #include "content/public/browser/site_instance.h" |
72 #include "content/public/browser/web_contents.h" | 72 #include "content/public/browser/web_contents.h" |
73 #include "content/public/browser/web_ui.h" | 73 #include "content/public/browser/web_ui.h" |
74 #include "content/public/browser/web_ui_data_source.h" | 74 #include "content/public/browser/web_ui_data_source.h" |
| 75 #include "extensions/browser/api/device_permissions_manager.h" |
75 #include "extensions/browser/app_window/app_window.h" | 76 #include "extensions/browser/app_window/app_window.h" |
76 #include "extensions/browser/app_window/app_window_registry.h" | 77 #include "extensions/browser/app_window/app_window_registry.h" |
77 #include "extensions/browser/blacklist_state.h" | 78 #include "extensions/browser/blacklist_state.h" |
78 #include "extensions/browser/extension_error.h" | 79 #include "extensions/browser/extension_error.h" |
79 #include "extensions/browser/extension_host.h" | 80 #include "extensions/browser/extension_host.h" |
80 #include "extensions/browser/extension_registry.h" | 81 #include "extensions/browser/extension_registry.h" |
81 #include "extensions/browser/extension_system.h" | 82 #include "extensions/browser/extension_system.h" |
82 #include "extensions/browser/lazy_background_task_queue.h" | 83 #include "extensions/browser/lazy_background_task_queue.h" |
83 #include "extensions/browser/management_policy.h" | 84 #include "extensions/browser/management_policy.h" |
84 #include "extensions/browser/pref_names.h" | 85 #include "extensions/browser/pref_names.h" |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 795 } |
795 | 796 |
796 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { | 797 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { |
797 extension_id_prompting_ = ""; | 798 extension_id_prompting_ = ""; |
798 } | 799 } |
799 | 800 |
800 void ExtensionSettingsHandler::ExtensionWarningsChanged() { | 801 void ExtensionSettingsHandler::ExtensionWarningsChanged() { |
801 MaybeUpdateAfterNotification(); | 802 MaybeUpdateAfterNotification(); |
802 } | 803 } |
803 | 804 |
804 // This is called when the user clicks "Revoke File Access." | 805 // This is called when the user clicks "Revoke File/Device Access." |
805 void ExtensionSettingsHandler::InstallUIProceed() { | 806 void ExtensionSettingsHandler::InstallUIProceed() { |
806 Profile* profile = Profile::FromWebUI(web_ui()); | 807 Profile* profile = Profile::FromWebUI(web_ui()); |
| 808 extensions::DevicePermissionsManager::Get(profile) |
| 809 ->Clear(extension_id_prompting_); |
807 apps::SavedFilesService::Get(profile)->ClearQueue( | 810 apps::SavedFilesService::Get(profile)->ClearQueue( |
808 extension_service_->GetExtensionById(extension_id_prompting_, true)); | 811 extension_service_->GetExtensionById(extension_id_prompting_, true)); |
809 apps::AppLoadService::Get(profile) | 812 apps::AppLoadService::Get(profile) |
810 ->RestartApplicationIfRunning(extension_id_prompting_); | 813 ->RestartApplicationIfRunning(extension_id_prompting_); |
811 extension_id_prompting_.clear(); | 814 extension_id_prompting_.clear(); |
812 } | 815 } |
813 | 816 |
814 void ExtensionSettingsHandler::InstallUIAbort(bool user_initiated) { | 817 void ExtensionSettingsHandler::InstallUIAbort(bool user_initiated) { |
815 extension_id_prompting_.clear(); | 818 extension_id_prompting_.clear(); |
816 } | 819 } |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 std::vector<base::FilePath> retained_file_paths; | 1175 std::vector<base::FilePath> retained_file_paths; |
1173 if (extension->permissions_data()->HasAPIPermission( | 1176 if (extension->permissions_data()->HasAPIPermission( |
1174 APIPermission::kFileSystem)) { | 1177 APIPermission::kFileSystem)) { |
1175 std::vector<apps::SavedFileEntry> retained_file_entries = | 1178 std::vector<apps::SavedFileEntry> retained_file_entries = |
1176 apps::SavedFilesService::Get(Profile::FromWebUI( | 1179 apps::SavedFilesService::Get(Profile::FromWebUI( |
1177 web_ui()))->GetAllFileEntries(extension_id_prompting_); | 1180 web_ui()))->GetAllFileEntries(extension_id_prompting_); |
1178 for (size_t i = 0; i < retained_file_entries.size(); ++i) { | 1181 for (size_t i = 0; i < retained_file_entries.size(); ++i) { |
1179 retained_file_paths.push_back(retained_file_entries[i].path); | 1182 retained_file_paths.push_back(retained_file_entries[i].path); |
1180 } | 1183 } |
1181 } | 1184 } |
| 1185 std::vector<base::string16> retained_device_messages; |
| 1186 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { |
| 1187 retained_device_messages = |
| 1188 extensions::DevicePermissionsManager::Get(Profile::FromWebUI(web_ui())) |
| 1189 ->GetPermissionMessageStrings(extension_id_prompting_); |
| 1190 } |
| 1191 |
1182 // The BrokerDelegate manages its own lifetime. | 1192 // The BrokerDelegate manages its own lifetime. |
1183 prompt_->ReviewPermissions( | 1193 prompt_->ReviewPermissions(new BrokerDelegate(AsWeakPtr()), |
1184 new BrokerDelegate(AsWeakPtr()), extension, retained_file_paths); | 1194 extension, |
| 1195 retained_file_paths, |
| 1196 retained_device_messages); |
1185 } | 1197 } |
1186 | 1198 |
1187 void ExtensionSettingsHandler::HandleShowButtonMessage( | 1199 void ExtensionSettingsHandler::HandleShowButtonMessage( |
1188 const base::ListValue* args) { | 1200 const base::ListValue* args) { |
1189 const Extension* extension = GetActiveExtension(args); | 1201 const Extension* extension = GetActiveExtension(args); |
1190 if (!extension) | 1202 if (!extension) |
1191 return; | 1203 return; |
1192 ExtensionActionAPI::SetBrowserActionVisibility( | 1204 ExtensionActionAPI::SetBrowserActionVisibility( |
1193 ExtensionPrefs::Get(extension_service_->profile()), | 1205 ExtensionPrefs::Get(extension_service_->profile()), |
1194 extension->id(), | 1206 extension->id(), |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 extension_service_->EnableExtension(extension_id); | 1452 extension_service_->EnableExtension(extension_id); |
1441 } else { | 1453 } else { |
1442 ExtensionErrorReporter::GetInstance()->ReportError( | 1454 ExtensionErrorReporter::GetInstance()->ReportError( |
1443 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1455 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
1444 true); // Be noisy. | 1456 true); // Be noisy. |
1445 } | 1457 } |
1446 requirements_checker_.reset(); | 1458 requirements_checker_.reset(); |
1447 } | 1459 } |
1448 | 1460 |
1449 } // namespace extensions | 1461 } // namespace extensions |
OLD | NEW |