kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 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 | |
Jinho Bang | 138fde3 | 2018-01-18 23:13:42 | [diff] [blame] | 5 | #include <memory> |
| 6 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 7 | #include "remoting/host/continue_window.h" |
| 8 | |
Sebastien Marchand | 6d0558fd | 2019-01-25 16:49:37 | [diff] [blame] | 9 | #include "base/bind.h" |
avi | c5960f3 | 2015-12-22 22:49:48 | [diff] [blame] | 10 | #include "base/macros.h" |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame] | 11 | #include "remoting/base/string_resources.h" |
| 12 | #include "remoting/host/chromeos/message_box.h" |
| 13 | #include "ui/base/l10n/l10n_util.h" |
| 14 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 15 | namespace remoting { |
| 16 | |
| 17 | namespace { |
| 18 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 19 | class ContinueWindowAura : public ContinueWindow { |
| 20 | public: |
| 21 | ContinueWindowAura(); |
| 22 | ~ContinueWindowAura() override; |
| 23 | |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame] | 24 | void OnMessageBoxResult(MessageBox::Result result); |
| 25 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 26 | protected: |
| 27 | // ContinueWindow interface. |
| 28 | void ShowUi() override; |
| 29 | void HideUi() override; |
| 30 | |
| 31 | private: |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 32 | std::unique_ptr<MessageBox> message_box_; |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 33 | DISALLOW_COPY_AND_ASSIGN(ContinueWindowAura); |
| 34 | }; |
| 35 | |
Chris Watkins | 6fe52aa | 2017-11-28 03:24:05 | [diff] [blame] | 36 | ContinueWindowAura::ContinueWindowAura() = default; |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 37 | |
Chris Watkins | 6fe52aa | 2017-11-28 03:24:05 | [diff] [blame] | 38 | ContinueWindowAura::~ContinueWindowAura() = default; |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame] | 39 | |
| 40 | void ContinueWindowAura::OnMessageBoxResult(MessageBox::Result result) { |
| 41 | if (result == MessageBox::OK) { |
| 42 | ContinueSession(); |
| 43 | } else { |
| 44 | DisconnectSession(); |
| 45 | } |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void ContinueWindowAura::ShowUi() { |
Jinho Bang | 138fde3 | 2018-01-18 23:13:42 | [diff] [blame] | 49 | message_box_ = std::make_unique<MessageBox>( |
kelvinp | 8607d9d | 2017-01-27 03:33:52 | [diff] [blame] | 50 | l10n_util::GetStringUTF16(IDS_MODE_IT2ME), // title |
| 51 | l10n_util::GetStringUTF16(IDS_CONTINUE_PROMPT), // dialog label |
| 52 | l10n_util::GetStringUTF16(IDS_CONTINUE_BUTTON), // ok label |
| 53 | l10n_util::GetStringUTF16(IDS_STOP_SHARING_BUTTON), // cancel label |
| 54 | base::Bind(&ContinueWindowAura::OnMessageBoxResult, |
| 55 | base::Unretained(this))); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void ContinueWindowAura::HideUi() { |
kelvinp | 8607d9d | 2017-01-27 03:33:52 | [diff] [blame] | 59 | message_box_.reset(); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | } // namespace |
| 63 | |
| 64 | // static |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 65 | std::unique_ptr<HostWindow> HostWindow::CreateContinueWindow() { |
Jinho Bang | 138fde3 | 2018-01-18 23:13:42 | [diff] [blame] | 66 | return std::make_unique<ContinueWindowAura>(); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | } // namespace remoting |