| 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/app_load_service.h" | 9 #include "apps/app_load_service.h" |
| 10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { | 76 if (extension->permissions_data()->HasAPIPermission(APIPermission::kUsb)) { |
| 77 retained_device_messages = | 77 retained_device_messages = |
| 78 DevicePermissionsManager::Get(profile_) | 78 DevicePermissionsManager::Get(profile_) |
| 79 ->GetPermissionMessageStrings(extension_id_); | 79 ->GetPermissionMessageStrings(extension_id_); |
| 80 } | 80 } |
| 81 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( | 81 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( |
| 82 new ExtensionInstallPrompt::Prompt( | 82 new ExtensionInstallPrompt::Prompt( |
| 83 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); | 83 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); |
| 84 prompt->set_retained_files(retained_file_paths); | 84 prompt->set_retained_files(retained_file_paths); |
| 85 prompt->set_retained_device_messages(retained_device_messages); | 85 prompt->set_retained_device_messages(retained_device_messages); |
| 86 prompt_->ShowDialog(this, extension, nullptr, std::move(prompt), | 86 // Unretained() is safe because this class manages its own lifetime and |
| 87 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 87 // deletes itself in OnInstallPromptDone(). |
| 88 prompt_->ShowDialog( |
| 89 base::Bind(&ShowPermissionsDialogHelper::OnInstallPromptDone, |
| 90 base::Unretained(this)), |
| 91 extension, nullptr, std::move(prompt), |
| 92 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
| 88 } | 93 } |
| 89 | 94 |
| 90 // This is called when the user clicks "Revoke File Access." | 95 void ShowPermissionsDialogHelper::OnInstallPromptDone( |
| 91 void ShowPermissionsDialogHelper::InstallUIProceed() { | 96 ExtensionInstallPrompt::Result result) { |
| 92 const Extension* extension = | 97 if (result == ExtensionInstallPrompt::Result::ACCEPTED) { |
| 93 ExtensionRegistry::Get(profile_)->GetExtensionById( | 98 // This is true when the user clicks "Revoke File Access." |
| 94 extension_id_, ExtensionRegistry::EVERYTHING); | 99 const Extension* extension = |
| 100 ExtensionRegistry::Get(profile_) |
| 101 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); |
| 95 | 102 |
| 96 if (extension) | 103 if (extension) |
| 97 apps::SavedFilesService::Get(profile_)->ClearQueue(extension); | 104 apps::SavedFilesService::Get(profile_)->ClearQueue(extension); |
| 98 apps::AppLoadService::Get(profile_) | 105 apps::AppLoadService::Get(profile_) |
| 99 ->RestartApplicationIfRunning(extension_id_); | 106 ->RestartApplicationIfRunning(extension_id_); |
| 107 } |
| 100 | 108 |
| 101 on_complete_.Run(); | 109 on_complete_.Run(); |
| 102 | |
| 103 delete this; | 110 delete this; |
| 104 } | 111 } |
| 105 | 112 |
| 106 void ShowPermissionsDialogHelper::InstallUIAbort(bool user_initiated) { | |
| 107 on_complete_.Run(); | |
| 108 | |
| 109 delete this; | |
| 110 } | |
| 111 | |
| 112 } // namespace extensions | 113 } // namespace extensions |
| OLD | NEW |