OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/extensions/device_permissions_dialog_controller.h" |
| 6 |
| 7 #include "chrome/grit/generated_resources.h" |
| 8 #include "extensions/strings/grit/extensions_strings.h" |
| 9 #include "ui/base/l10n/l10n_util.h" |
| 10 |
| 11 DevicePermissionsDialogController::DevicePermissionsDialogController( |
| 12 content::RenderFrameHost* owner, |
| 13 scoped_refptr<extensions::DevicePermissionsPrompt::Prompt> prompt) |
| 14 : ChooserController( |
| 15 owner, |
| 16 prompt->multiple() ? IDS_DEVICE_PERMISSIONS_PROMPT_MULTIPLE_SELECTION |
| 17 : IDS_DEVICE_PERMISSIONS_PROMPT_SINGLE_SELECTION, |
| 18 prompt->multiple() ? IDS_DEVICE_PERMISSIONS_PROMPT_MULTIPLE_SELECTION |
| 19 : IDS_DEVICE_PERMISSIONS_PROMPT_SINGLE_SELECTION), |
| 20 prompt_(prompt) { |
| 21 prompt_->SetObserver(this); |
| 22 } |
| 23 |
| 24 DevicePermissionsDialogController::~DevicePermissionsDialogController() { |
| 25 prompt_->SetObserver(nullptr); |
| 26 } |
| 27 |
| 28 bool DevicePermissionsDialogController::ShouldShowFootnoteView() const { |
| 29 return false; |
| 30 } |
| 31 |
| 32 bool DevicePermissionsDialogController::AllowMultipleSelection() const { |
| 33 return prompt_->multiple(); |
| 34 } |
| 35 |
| 36 base::string16 DevicePermissionsDialogController::GetNoOptionsText() const { |
| 37 return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); |
| 38 } |
| 39 |
| 40 base::string16 DevicePermissionsDialogController::GetOkButtonLabel() const { |
| 41 return l10n_util::GetStringUTF16(IDS_DEVICE_PERMISSIONS_DIALOG_SELECT); |
| 42 } |
| 43 |
| 44 size_t DevicePermissionsDialogController::NumOptions() const { |
| 45 return prompt_->GetDeviceCount(); |
| 46 } |
| 47 |
| 48 base::string16 DevicePermissionsDialogController::GetOption( |
| 49 size_t index) const { |
| 50 return prompt_->GetDeviceName(index); |
| 51 } |
| 52 |
| 53 void DevicePermissionsDialogController::RefreshOptions() {} |
| 54 |
| 55 base::string16 DevicePermissionsDialogController::GetStatus() const { |
| 56 return base::string16(); |
| 57 } |
| 58 |
| 59 void DevicePermissionsDialogController::Select( |
| 60 const std::vector<size_t>& indices) { |
| 61 for (size_t index : indices) |
| 62 prompt_->GrantDevicePermission(index); |
| 63 prompt_->Dismissed(); |
| 64 } |
| 65 |
| 66 void DevicePermissionsDialogController::Cancel() { |
| 67 prompt_->Dismissed(); |
| 68 } |
| 69 |
| 70 void DevicePermissionsDialogController::Close() { |
| 71 prompt_->Dismissed(); |
| 72 } |
| 73 |
| 74 void DevicePermissionsDialogController::OpenHelpCenterUrl() const {} |
| 75 |
| 76 void DevicePermissionsDialogController::OnDeviceAdded(size_t index) { |
| 77 if (view()) |
| 78 view()->OnOptionAdded(index); |
| 79 } |
| 80 |
| 81 void DevicePermissionsDialogController::OnDeviceRemoved(size_t index) { |
| 82 if (view()) |
| 83 view()->OnOptionRemoved(index); |
| 84 } |
OLD | NEW |