OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 "base/bind.h" |
| 6 #include "base/callback_helpers.h" |
| 7 #include "base/location.h" |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "remoting/base/string_resources.h" |
| 12 #include "remoting/host/chromeos/message_box.h" |
| 13 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
| 14 #include "ui/base/l10n/l10n_util.h" |
| 15 |
| 16 namespace remoting { |
| 17 |
| 18 class It2MeConfirmationDialogChromeOS : public It2MeConfirmationDialog { |
| 19 public: |
| 20 It2MeConfirmationDialogChromeOS(); |
| 21 ~It2MeConfirmationDialogChromeOS() override; |
| 22 |
| 23 void Show(const ResultCallback& callback) override; |
| 24 |
| 25 private: |
| 26 void OnMessageBoxResult(MessageBox::Result result); |
| 27 |
| 28 scoped_ptr<MessageBox> message_box_; |
| 29 ResultCallback callback_; |
| 30 }; |
| 31 |
| 32 It2MeConfirmationDialogChromeOS::It2MeConfirmationDialogChromeOS() {} |
| 33 |
| 34 It2MeConfirmationDialogChromeOS::~It2MeConfirmationDialogChromeOS() {} |
| 35 |
| 36 void It2MeConfirmationDialogChromeOS::Show(const ResultCallback& callback) { |
| 37 callback_ = callback; |
| 38 |
| 39 message_box_.reset(new MessageBox( |
| 40 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_MESSAGE), |
| 41 base::string16(), |
| 42 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_CONFIRM), |
| 43 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_DECLINE), |
| 44 base::Bind(&It2MeConfirmationDialogChromeOS::OnMessageBoxResult, |
| 45 base::Unretained(this)))); |
| 46 |
| 47 message_box_->Show(); |
| 48 } |
| 49 |
| 50 void It2MeConfirmationDialogChromeOS::OnMessageBoxResult( |
| 51 MessageBox::Result result) { |
| 52 static_assert( |
| 53 Result::OK == static_cast<Result>(MessageBox::Result::OK) && |
| 54 Result::CANCEL == static_cast<Result>(MessageBox::Result::CANCEL), |
| 55 "MessageBox::Result and Result must declare the same values."); |
| 56 base::ResetAndReturn(&callback_).Run(static_cast<Result>(result)); |
| 57 } |
| 58 |
| 59 scoped_ptr<It2MeConfirmationDialog> It2MeConfirmationDialogFactory::Create() { |
| 60 return scoped_ptr<It2MeConfirmationDialog>( |
| 61 new It2MeConfirmationDialogChromeOS()); |
| 62 } |
| 63 |
| 64 } // namespace remoting |
OLD | NEW |