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 | |
| 5 | #include "remoting/host/continue_window.h" |
| 6 | |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 7 | #include "remoting/base/string_resources.h" |
| 8 | #include "remoting/host/chromeos/message_box.h" |
| 9 | #include "ui/base/l10n/l10n_util.h" |
| 10 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 11 | namespace remoting { |
| 12 | |
| 13 | namespace { |
| 14 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 15 | class ContinueWindowAura : public ContinueWindow { |
| 16 | public: |
| 17 | ContinueWindowAura(); |
| 18 | ~ContinueWindowAura() override; |
| 19 | |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 20 | void OnMessageBoxResult(MessageBox::Result result); |
| 21 | |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 22 | protected: |
| 23 | // ContinueWindow interface. |
| 24 | void ShowUi() override; |
| 25 | void HideUi() override; |
| 26 | |
| 27 | private: |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 28 | scoped_ptr<MessageBox> message_box_; |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 29 | DISALLOW_COPY_AND_ASSIGN(ContinueWindowAura); |
| 30 | }; |
| 31 | |
| 32 | ContinueWindowAura::ContinueWindowAura() { |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 33 | message_box_.reset(new MessageBox( |
| 34 | l10n_util::GetStringUTF16(IDS_MODE_IT2ME), // title |
| 35 | l10n_util::GetStringUTF16(IDS_CONTINUE_PROMPT), // dialog label |
| 36 | l10n_util::GetStringUTF16(IDS_CONTINUE_BUTTON), // ok label |
| 37 | l10n_util::GetStringUTF16(IDS_STOP_SHARING_BUTTON), // cancel label |
| 38 | base::Bind(&ContinueWindowAura::OnMessageBoxResult, |
| 39 | base::Unretained(this)))); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | ContinueWindowAura::~ContinueWindowAura() { |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 43 | message_box_->Hide(); |
| 44 | } |
| 45 | |
| 46 | void ContinueWindowAura::OnMessageBoxResult(MessageBox::Result result) { |
| 47 | if (result == MessageBox::OK) { |
| 48 | ContinueSession(); |
| 49 | } else { |
| 50 | DisconnectSession(); |
| 51 | } |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void ContinueWindowAura::ShowUi() { |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 55 | message_box_->Show(); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void ContinueWindowAura::HideUi() { |
kelvinp | f469112 | 2014-11-04 23:27:03 | [diff] [blame^] | 59 | message_box_->Hide(); |
kelvinp | 561074cf | 2014-10-30 21:46:16 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | } // namespace |
| 63 | |
| 64 | // static |
| 65 | scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() { |
| 66 | return make_scoped_ptr(new ContinueWindowAura()); |
| 67 | } |
| 68 | |
| 69 | } // namespace remoting |