OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/developer_private/show_permissions_dialo
g_helper.h" | 5 #include "chrome/browser/extensions/api/developer_private/show_permissions_dialo
g_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "chrome/browser/apps/app_load_service.h" | 11 #include "chrome/browser/apps/app_load_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/apps/app_info_dialog.h" | 13 #include "chrome/browser/ui/apps/app_info_dialog.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "extensions/browser/api/device_permissions_manager.h" | 15 #include "extensions/browser/api/device_permissions_manager.h" |
| 16 #include "extensions/browser/api/file_system/saved_file_entry.h" |
16 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
18 #include "extensions/common/permissions/permissions_data.h" | 19 #include "extensions/common/permissions/permissions_data.h" |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 ShowPermissionsDialogHelper::ShowPermissionsDialogHelper( | 23 ShowPermissionsDialogHelper::ShowPermissionsDialogHelper( |
23 Profile* profile, | 24 Profile* profile, |
24 const base::Closure& on_complete) | 25 const base::Closure& on_complete) |
25 : profile_(profile), | 26 : profile_(profile), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 60 } |
60 | 61 |
61 void ShowPermissionsDialogHelper::ShowPermissionsDialog( | 62 void ShowPermissionsDialogHelper::ShowPermissionsDialog( |
62 content::WebContents* web_contents, | 63 content::WebContents* web_contents, |
63 const Extension* extension) { | 64 const Extension* extension) { |
64 extension_id_ = extension->id(); | 65 extension_id_ = extension->id(); |
65 prompt_.reset(new ExtensionInstallPrompt(web_contents)); | 66 prompt_.reset(new ExtensionInstallPrompt(web_contents)); |
66 std::vector<base::FilePath> retained_file_paths; | 67 std::vector<base::FilePath> retained_file_paths; |
67 if (extension->permissions_data()->HasAPIPermission( | 68 if (extension->permissions_data()->HasAPIPermission( |
68 APIPermission::kFileSystem)) { | 69 APIPermission::kFileSystem)) { |
69 std::vector<apps::SavedFileEntry> retained_file_entries = | 70 std::vector<SavedFileEntry> retained_file_entries = |
70 apps::SavedFilesService::Get(profile_) | 71 apps::SavedFilesService::Get(profile_)->GetAllFileEntries( |
71 ->GetAllFileEntries(extension_id_); | 72 extension_id_); |
72 for (const apps::SavedFileEntry& entry : retained_file_entries) | 73 for (const SavedFileEntry& entry : retained_file_entries) |
73 retained_file_paths.push_back(entry.path); | 74 retained_file_paths.push_back(entry.path); |
74 } | 75 } |
75 std::vector<base::string16> retained_device_messages; | 76 std::vector<base::string16> retained_device_messages; |
76 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { | 77 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { |
77 retained_device_messages = | 78 retained_device_messages = |
78 DevicePermissionsManager::Get(profile_) | 79 DevicePermissionsManager::Get(profile_) |
79 ->GetPermissionMessageStrings(extension_id_); | 80 ->GetPermissionMessageStrings(extension_id_); |
80 } | 81 } |
81 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( | 82 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( |
82 new ExtensionInstallPrompt::Prompt( | 83 new ExtensionInstallPrompt::Prompt( |
(...skipping 21 matching lines...) Expand all Loading... |
104 apps::SavedFilesService::Get(profile_)->ClearQueue(extension); | 105 apps::SavedFilesService::Get(profile_)->ClearQueue(extension); |
105 apps::AppLoadService::Get(profile_) | 106 apps::AppLoadService::Get(profile_) |
106 ->RestartApplicationIfRunning(extension_id_); | 107 ->RestartApplicationIfRunning(extension_id_); |
107 } | 108 } |
108 | 109 |
109 on_complete_.Run(); | 110 on_complete_.Run(); |
110 delete this; | 111 delete this; |
111 } | 112 } |
112 | 113 |
113 } // namespace extensions | 114 } // namespace extensions |
OLD | NEW |