Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: remoting/host/host_user_interface.cc

Issue 13212009: Made DesktopEnvironment responsible for creation of the disconnect window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Mac Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_user_interface.h ('k') | remoting/host/host_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/host_user_interface.h" 5 #include "remoting/host/host_user_interface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "remoting/host/chromoting_host.h" 8 #include "remoting/host/chromoting_host.h"
9 #include "remoting/host/disconnect_window.h"
10 #include "remoting/host/local_input_monitor.h"
11 9
12 namespace remoting { 10 namespace remoting {
13 11
14 HostUserInterface::HostUserInterface( 12 HostUserInterface::HostUserInterface(
15 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 13 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
16 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 14 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
17 const UiStrings& ui_strings) 15 const UiStrings& ui_strings)
18 : host_(NULL), 16 : host_(NULL),
19 network_task_runner_(network_task_runner), 17 network_task_runner_(network_task_runner),
20 ui_task_runner_(ui_task_runner), 18 ui_task_runner_(ui_task_runner),
21 ui_strings_(ui_strings), 19 ui_strings_(ui_strings),
22 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 20 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
23 weak_ptr_(weak_factory_.GetWeakPtr()) { 21 weak_ptr_(weak_factory_.GetWeakPtr()) {
24 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 22 DCHECK(ui_task_runner_->BelongsToCurrentThread());
25 } 23 }
26 24
27 HostUserInterface::~HostUserInterface() { 25 HostUserInterface::~HostUserInterface() {
28 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 26 DCHECK(ui_task_runner_->BelongsToCurrentThread());
29
30 disconnect_window_->Hide();
31 } 27 }
32 28
33 void HostUserInterface::Init() { 29 void HostUserInterface::Init() {
34 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 30 DCHECK(ui_task_runner_->BelongsToCurrentThread());
35
36 disconnect_window_ = DisconnectWindow::Create(&ui_strings());
37 } 31 }
38 32
39 void HostUserInterface::Start(ChromotingHost* host, 33 void HostUserInterface::Start(ChromotingHost* host,
40 const base::Closure& disconnect_callback) { 34 const base::Closure& disconnect_callback) {
41 DCHECK(network_task_runner_->BelongsToCurrentThread()); 35 DCHECK(network_task_runner_->BelongsToCurrentThread());
42 DCHECK(host_ == NULL); 36 DCHECK(host_ == NULL);
43 37
44 host_ = host; 38 host_ = host;
45 disconnect_callback_ = disconnect_callback; 39 disconnect_callback_ = disconnect_callback;
46 host_->AddStatusObserver(this); 40 host_->AddStatusObserver(this);
(...skipping 28 matching lines...) Expand all
75 69
76 // Host status observers must be removed on the network thread, so 70 // Host status observers must be removed on the network thread, so
77 // it must happen here instead of in the destructor. 71 // it must happen here instead of in the destructor.
78 host_->RemoveStatusObserver(this); 72 host_->RemoveStatusObserver(this);
79 host_ = NULL; 73 host_ = NULL;
80 } 74 }
81 75
82 void HostUserInterface::OnDisconnectCallback() { 76 void HostUserInterface::OnDisconnectCallback() {
83 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 77 DCHECK(ui_task_runner_->BelongsToCurrentThread());
84 78
85 disconnect_window_->Hide();
86 DisconnectSession(); 79 DisconnectSession();
87 } 80 }
88 81
89 base::SingleThreadTaskRunner* HostUserInterface::network_task_runner() const { 82 base::SingleThreadTaskRunner* HostUserInterface::network_task_runner() const {
90 return network_task_runner_; 83 return network_task_runner_;
91 } 84 }
92 85
93 base::SingleThreadTaskRunner* HostUserInterface::ui_task_runner() const { 86 base::SingleThreadTaskRunner* HostUserInterface::ui_task_runner() const {
94 return ui_task_runner_; 87 return ui_task_runner_;
95 } 88 }
96 89
97 void HostUserInterface::DisconnectSession() const { 90 void HostUserInterface::DisconnectSession() const {
98 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 91 DCHECK(ui_task_runner_->BelongsToCurrentThread());
99 92
100 disconnect_callback_.Run(); 93 disconnect_callback_.Run();
101 } 94 }
102 95
103 void HostUserInterface::ProcessOnClientAuthenticated( 96 void HostUserInterface::ProcessOnClientAuthenticated(
104 const std::string& username) { 97 const std::string& username) {
105 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 98 DCHECK(ui_task_runner_->BelongsToCurrentThread());
106
107 if (!disconnect_window_->Show(
108 base::Bind(&HostUserInterface::OnDisconnectCallback, weak_ptr_),
109 username)) {
110 LOG(ERROR) << "Failed to show the disconnect window.";
111 DisconnectSession();
112 return;
113 }
114 } 99 }
115 100
116 void HostUserInterface::ProcessOnClientDisconnected() { 101 void HostUserInterface::ProcessOnClientDisconnected() {
117 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 102 DCHECK(ui_task_runner_->BelongsToCurrentThread());
118
119 disconnect_window_->Hide();
120 } 103 }
121 104
122 } // namespace remoting 105 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_user_interface.h ('k') | remoting/host/host_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698