Clarify and update GN build flags docs.
[chromium-blink-merge.git] / remoting / host / it2me / it2me_confirmation_dialog_chromeos.cc
blob603df550d16ff188a4eaa9ab02a0135012cbab5f
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.
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"
16 namespace remoting {
18 class It2MeConfirmationDialogChromeOS : public It2MeConfirmationDialog {
19 public:
20 It2MeConfirmationDialogChromeOS();
21 ~It2MeConfirmationDialogChromeOS() override;
23 // It2MeConfirmationDialog implementation.
24 void Show(const ResultCallback& callback) override;
26 private:
27 // Handles result from |message_box_|.
28 void OnMessageBoxResult(MessageBox::Result result);
30 scoped_ptr<MessageBox> message_box_;
31 ResultCallback callback_;
33 DISALLOW_COPY_AND_ASSIGN(It2MeConfirmationDialogChromeOS);
36 It2MeConfirmationDialogChromeOS::It2MeConfirmationDialogChromeOS() {}
38 It2MeConfirmationDialogChromeOS::~It2MeConfirmationDialogChromeOS() {}
40 void It2MeConfirmationDialogChromeOS::Show(const ResultCallback& callback) {
41 callback_ = callback;
43 message_box_.reset(new MessageBox(
44 l10n_util::GetStringUTF16(IDS_MODE_IT2ME),
45 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_MESSAGE),
46 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_CONFIRM),
47 l10n_util::GetStringUTF16(IDS_SHARE_CONFIRM_DIALOG_DECLINE),
48 base::Bind(&It2MeConfirmationDialogChromeOS::OnMessageBoxResult,
49 base::Unretained(this))));
51 message_box_->Show();
54 void It2MeConfirmationDialogChromeOS::OnMessageBoxResult(
55 MessageBox::Result result) {
56 message_box_->Hide();
57 base::ResetAndReturn(&callback_).Run(result == MessageBox::OK ?
58 Result::OK : Result::CANCEL);
61 scoped_ptr<It2MeConfirmationDialog> It2MeConfirmationDialogFactory::Create() {
62 return scoped_ptr<It2MeConfirmationDialog>(
63 new It2MeConfirmationDialogChromeOS());
66 } // namespace remoting