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/extensions/api/permissions/permissions_api.h" | 5 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 extension_->location() == Manifest::COMPONENT) { | 232 extension_->location() == Manifest::COMPONENT) { |
233 OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED); | 233 OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED); |
234 } else if (auto_confirm_for_tests == ABORT) { | 234 } else if (auto_confirm_for_tests == ABORT) { |
235 // Pretend the user clicked cancel. | 235 // Pretend the user clicked cancel. |
236 OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED); | 236 OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED); |
237 } else { | 237 } else { |
238 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); | 238 CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); |
239 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); | 239 install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents())); |
240 install_ui_->ShowDialog( | 240 install_ui_->ShowDialog( |
241 base::Bind(&PermissionsRequestFunction::OnInstallPromptDone, this), | 241 base::Bind(&PermissionsRequestFunction::OnInstallPromptDone, this), |
242 extension(), nullptr, | 242 extension(), nullptr, base::MakeUnique<ExtensionInstallPrompt::Prompt>( |
243 base::WrapUnique(new ExtensionInstallPrompt::Prompt( | 243 ExtensionInstallPrompt::PERMISSIONS_PROMPT), |
244 ExtensionInstallPrompt::PERMISSIONS_PROMPT)), | |
245 requested_permissions_->Clone(), | 244 requested_permissions_->Clone(), |
246 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 245 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
247 } | 246 } |
248 | 247 |
249 return true; | 248 return true; |
250 } | 249 } |
251 | 250 |
252 void PermissionsRequestFunction::OnInstallPromptDone( | 251 void PermissionsRequestFunction::OnInstallPromptDone( |
253 ExtensionInstallPrompt::Result result) { | 252 ExtensionInstallPrompt::Result result) { |
254 if (result == ExtensionInstallPrompt::Result::ACCEPTED) { | 253 if (result == ExtensionInstallPrompt::Result::ACCEPTED) { |
255 PermissionsUpdater perms_updater(GetProfile()); | 254 PermissionsUpdater perms_updater(GetProfile()); |
256 perms_updater.AddPermissions(extension(), *requested_permissions_); | 255 perms_updater.AddPermissions(extension(), *requested_permissions_); |
257 | 256 |
258 results_ = Request::Results::Create(true); | 257 results_ = Request::Results::Create(true); |
259 } | 258 } |
260 | 259 |
261 SendResponse(true); | 260 SendResponse(true); |
262 Release(); // Balanced in RunAsync(). | 261 Release(); // Balanced in RunAsync(). |
263 } | 262 } |
264 | 263 |
265 } // namespace extensions | 264 } // namespace extensions |
OLD | NEW |