OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/continue_window.h" | 5 #include "remoting/host/continue_window.h" |
6 | 6 |
7 #include "remoting/base/string_resources.h" | |
8 #include "remoting/host/chromeos/message_box.h" | |
9 #include "ui/base/l10n/l10n_util.h" | |
10 | |
7 namespace remoting { | 11 namespace remoting { |
8 | 12 |
9 namespace { | 13 namespace { |
10 | 14 |
11 // A place holder implementation for the ContinueWindow on | |
12 // ChromeOS. Remote assistance on Chrome OS is currently under a flag so it is | |
13 // secure to leave it unimplemented for now. | |
14 class ContinueWindowAura : public ContinueWindow { | 15 class ContinueWindowAura : public ContinueWindow { |
15 public: | 16 public: |
16 ContinueWindowAura(); | 17 ContinueWindowAura(); |
17 ~ContinueWindowAura() override; | 18 ~ContinueWindowAura() override; |
18 | 19 |
20 void OnMessageBoxResult(MessageBox::Result result); | |
21 | |
19 protected: | 22 protected: |
20 // ContinueWindow interface. | 23 // ContinueWindow interface. |
21 void ShowUi() override; | 24 void ShowUi() override; |
22 void HideUi() override; | 25 void HideUi() override; |
23 | 26 |
24 private: | 27 private: |
28 scoped_refptr<MessageBox> message_box_; | |
29 base::WeakPtrFactory<ContinueWindowAura> weak_factory_; | |
30 | |
25 DISALLOW_COPY_AND_ASSIGN(ContinueWindowAura); | 31 DISALLOW_COPY_AND_ASSIGN(ContinueWindowAura); |
26 }; | 32 }; |
27 | 33 |
28 ContinueWindowAura::ContinueWindowAura() { | 34 ContinueWindowAura::ContinueWindowAura() : weak_factory_(this) { |
35 message_box_ = new MessageBox( | |
36 l10n_util::GetStringUTF16(IDS_CONTINUE_PROMPT), // dialog label | |
37 l10n_util::GetStringUTF16(IDS_CONTINUE_BUTTON), // ok label | |
38 l10n_util::GetStringUTF16(IDS_STOP_SHARING_BUTTON), // cancel label | |
39 base::Bind(&ContinueWindowAura::OnMessageBoxResult, | |
40 weak_factory_.GetWeakPtr())); | |
29 } | 41 } |
30 | 42 |
31 ContinueWindowAura::~ContinueWindowAura() { | 43 ContinueWindowAura::~ContinueWindowAura() { |
44 message_box_->Hide(); | |
45 } | |
46 | |
47 void ContinueWindowAura::OnMessageBoxResult(MessageBox::Result result) { | |
48 if (result == MessageBox::OK) { | |
49 ContinueSession(); | |
50 } else { | |
51 DisconnectSession(); | |
52 } | |
32 } | 53 } |
33 | 54 |
34 void ContinueWindowAura::ShowUi() { | 55 void ContinueWindowAura::ShowUi() { |
35 // TODO(kelvinp): Implement this on Chrome OS (See crbug.com/424908). | 56 message_box_->Show(); |
36 NOTIMPLEMENTED(); | |
37 } | 57 } |
38 | 58 |
39 void ContinueWindowAura::HideUi() { | 59 void ContinueWindowAura::HideUi() { |
dcaiafa
2014/10/31 18:05:49
Why not call message_box_->Hide() here?
kelvinp
2014/10/31 21:12:53
HideUi() is called by ContinueSession which is cal
| |
40 // TODO(kelvinp): Implement this on Chrome OS (See crbug.com/424908). | |
41 NOTIMPLEMENTED(); | |
42 } | 60 } |
43 | 61 |
44 } // namespace | 62 } // namespace |
45 | 63 |
46 // static | 64 // static |
47 scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() { | 65 scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() { |
48 return make_scoped_ptr(new ContinueWindowAura()); | 66 return make_scoped_ptr(new ContinueWindowAura()); |
49 } | 67 } |
50 | 68 |
51 } // namespace remoting | 69 } // namespace remoting |
OLD | NEW |