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

Side by Side Diff: athena/system/network_selector.cc

Issue 665803003: Revert of Support modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « athena/system/network_selector.h ('k') | athena/system/shutdown_dialog.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 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 "athena/system/network_selector.h" 5 #include "athena/system/network_selector.h"
6 6
7 #include "athena/screen/public/screen_manager.h"
8 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
10 #include "chromeos/network/network_configuration_handler.h" 9 #include "chromeos/network/network_configuration_handler.h"
11 #include "chromeos/network/network_connection_handler.h" 10 #include "chromeos/network/network_connection_handler.h"
12 #include "chromeos/network/network_handler.h" 11 #include "chromeos/network/network_handler.h"
13 #include "chromeos/network/network_profile_handler.h" 12 #include "chromeos/network/network_profile_handler.h"
14 #include "chromeos/network/network_state.h" 13 #include "chromeos/network/network_state.h"
15 #include "chromeos/network/network_state_handler.h" 14 #include "chromeos/network/network_state_handler.h"
16 #include "chromeos/network/network_state_handler_observer.h" 15 #include "chromeos/network/network_state_handler_observer.h"
17 #include "chromeos/network/network_type_pattern.h" 16 #include "chromeos/network/network_type_pattern.h"
(...skipping 14 matching lines...) Expand all
32 #include "ui/views/controls/button/blue_button.h" 31 #include "ui/views/controls/button/blue_button.h"
33 #include "ui/views/controls/button/button.h" 32 #include "ui/views/controls/button/button.h"
34 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
35 #include "ui/views/controls/label.h" 34 #include "ui/views/controls/label.h"
36 #include "ui/views/controls/scroll_view.h" 35 #include "ui/views/controls/scroll_view.h"
37 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" 36 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
38 #include "ui/views/controls/textfield/textfield.h" 37 #include "ui/views/controls/textfield/textfield.h"
39 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
40 #include "ui/views/layout/fill_layout.h" 39 #include "ui/views/layout/fill_layout.h"
41 #include "ui/views/widget/widget.h" 40 #include "ui/views/widget/widget.h"
42 #include "ui/views/window/dialog_delegate.h"
43 41
44 using chromeos::NetworkConfigurationHandler; 42 using chromeos::NetworkConfigurationHandler;
45 using chromeos::NetworkConnectionHandler; 43 using chromeos::NetworkConnectionHandler;
46 using chromeos::NetworkHandler; 44 using chromeos::NetworkHandler;
47 using chromeos::NetworkProfileHandler; 45 using chromeos::NetworkProfileHandler;
48 using chromeos::NetworkState; 46 using chromeos::NetworkState;
49 47
50 namespace { 48 namespace {
51 49
50 const int kBackgroundColor = SkColorSetARGB(0x7f, 0, 0, 0);
51
52 // The View for the user to enter the password for connceting to a network. This 52 // The View for the user to enter the password for connceting to a network. This
53 // view also shows an error message if the network connection fails. 53 // view also shows an error message if the network connection fails.
54 class PasswordView : public views::View, public views::ButtonListener { 54 class PasswordView : public views::View, public views::ButtonListener {
55 public: 55 public:
56 PasswordView(const ui::NetworkInfo& network, 56 PasswordView(const ui::NetworkInfo& network,
57 const base::Callback<void(bool)>& callback) 57 const base::Callback<void(bool)>& callback,
58 views::View* parent_container)
58 : network_(network), 59 : network_(network),
59 callback_(callback), 60 callback_(callback),
61 parent_container_(parent_container),
60 connect_(NULL), 62 connect_(NULL),
61 cancel_(NULL), 63 cancel_(NULL),
62 textfield_(NULL), 64 textfield_(NULL),
63 error_msg_(NULL), 65 error_msg_(NULL),
64 weak_ptr_(this) { 66 weak_ptr_(this) {
65 const int kHorizontal = 5; 67 const int kHorizontal = 5;
66 const int kVertical = 0; 68 const int kVertical = 0;
67 const int kPadding = 0; 69 const int kPadding = 0;
68 70
69 views::BoxLayout* layout = new views::BoxLayout( 71 views::BoxLayout* layout = new views::BoxLayout(
(...skipping 23 matching lines...) Expand all
93 cancel_ = new views::LabelButton(this, base::ASCIIToUTF16("Cancel")); 95 cancel_ = new views::LabelButton(this, base::ASCIIToUTF16("Cancel"));
94 cancel_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 96 cancel_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
95 container->AddChildView(cancel_); 97 container->AddChildView(cancel_);
96 98
97 AddChildView(container); 99 AddChildView(container);
98 } 100 }
99 101
100 virtual ~PasswordView() {} 102 virtual ~PasswordView() {}
101 103
102 private: 104 private:
103 void CloseDialog(bool successful) { callback_.Run(successful); } 105 void Close(bool successful) { callback_.Run(successful); }
104 106
105 void OnKnownError(const std::string& error_name, 107 void OnKnownError(const std::string& error_name,
106 scoped_ptr<base::DictionaryValue> error_data) { 108 scoped_ptr<base::DictionaryValue> error_data) {
107 std::string message; 109 std::string message;
108 if (!error_data->GetString(chromeos::network_handler::kDbusErrorMessage, 110 if (!error_data->GetString(chromeos::network_handler::kDbusErrorMessage,
109 &message)) 111 &message))
110 message = error_name; 112 message = error_name;
111 if (message.empty()) 113 if (message.empty())
112 message = std::string("Unknown error."); 114 message = std::string("Unknown error.");
113 if (!error_msg_) { 115 if (!error_msg_) {
114 error_msg_ = new views::Label(); 116 error_msg_ = new views::Label();
115 error_msg_->SetFontList( 117 error_msg_->SetFontList(
116 error_msg_->font_list().Derive(0, gfx::Font::BOLD)); 118 error_msg_->font_list().Derive(0, gfx::Font::BOLD));
117 error_msg_->SetEnabledColor(SK_ColorRED); 119 error_msg_->SetEnabledColor(SK_ColorRED);
118 } 120 }
119 error_msg_->SetText(base::UTF8ToUTF16(message)); 121 error_msg_->SetText(base::UTF8ToUTF16(message));
120 if (!error_msg_->parent()) { 122 if (!error_msg_->parent()) {
121 AddChildView(error_msg_); 123 AddChildView(error_msg_);
122 InvalidateLayout(); 124 InvalidateLayout();
123 GetWidget()->GetRootView()->Layout(); 125 parent_container_->Layout();
124 ScrollRectToVisible(error_msg_->bounds()); 126 ScrollRectToVisible(error_msg_->bounds());
125 } 127 }
126 connect_->SetEnabled(true); 128 connect_->SetEnabled(true);
127 } 129 }
128 130
129 void OnSetProfileSucceed(const base::string16& password) { 131 void OnSetProfileSucceed(const base::string16& password) {
130 base::DictionaryValue properties; 132 base::DictionaryValue properties;
131 properties.SetStringWithoutPathExpansion(shill::kPassphraseProperty, 133 properties.SetStringWithoutPathExpansion(shill::kPassphraseProperty,
132 textfield_->text()); 134 textfield_->text());
133 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 135 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
134 network_.service_path, 136 network_.service_path,
135 properties, 137 properties,
136 base::Bind(&PasswordView::OnSetPropertiesSucceed, 138 base::Bind(&PasswordView::OnSetPropertiesSucceed,
137 weak_ptr_.GetWeakPtr()), 139 weak_ptr_.GetWeakPtr()),
138 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr())); 140 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr()));
139 } 141 }
140 142
141 void OnSetPropertiesSucceed() { 143 void OnSetPropertiesSucceed() {
142 const bool check_error_state = false; 144 const bool check_error_state = false;
143 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork( 145 NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork(
144 network_.service_path, 146 network_.service_path,
145 base::Bind(&PasswordView::OnConnectionSucceed, weak_ptr_.GetWeakPtr()), 147 base::Bind(&PasswordView::OnConnectionSucceed, weak_ptr_.GetWeakPtr()),
146 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr()), 148 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr()),
147 check_error_state); 149 check_error_state);
148 } 150 }
149 151
150 void OnConnectionSucceed() { CloseDialog(true); } 152 void OnConnectionSucceed() { Close(true); }
151 153
152 // views::View: 154 // views::View:
153 virtual void ViewHierarchyChanged( 155 virtual void ViewHierarchyChanged(
154 const views::View::ViewHierarchyChangedDetails& details) override { 156 const views::View::ViewHierarchyChangedDetails& details) override {
155 if (details.is_add && details.child == this) 157 if (details.is_add && details.child == this)
156 textfield_->RequestFocus(); 158 textfield_->RequestFocus();
157 } 159 }
158 160
159 // views::ButtonListener: 161 // views::ButtonListener:
160 virtual void ButtonPressed(views::Button* sender, 162 virtual void ButtonPressed(views::Button* sender,
161 const ui::Event& event) override { 163 const ui::Event& event) override {
162 if (sender == connect_) { 164 if (sender == connect_) {
163 if (error_msg_) { 165 if (error_msg_) {
164 RemoveChildView(error_msg_); 166 RemoveChildView(error_msg_);
165 delete error_msg_; 167 delete error_msg_;
166 error_msg_ = NULL; 168 error_msg_ = NULL;
167 } 169 }
168 connect_->SetEnabled(false); 170 connect_->SetEnabled(false);
169 NetworkHandler::Get()->network_configuration_handler()->SetNetworkProfile( 171 NetworkHandler::Get()->network_configuration_handler()->SetNetworkProfile(
170 network_.service_path, 172 network_.service_path,
171 NetworkProfileHandler::GetSharedProfilePath(), 173 NetworkProfileHandler::GetSharedProfilePath(),
172 base::Bind(&PasswordView::OnSetProfileSucceed, 174 base::Bind(&PasswordView::OnSetProfileSucceed,
173 weak_ptr_.GetWeakPtr(), 175 weak_ptr_.GetWeakPtr(),
174 textfield_->text()), 176 textfield_->text()),
175 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr())); 177 base::Bind(&PasswordView::OnKnownError, weak_ptr_.GetWeakPtr()));
176 } else if (sender == cancel_) { 178 } else if (sender == cancel_) {
177 CloseDialog(false); 179 Close(false);
178 } else { 180 } else {
179 NOTREACHED(); 181 NOTREACHED();
180 } 182 }
181 } 183 }
182 184
183 ui::NetworkInfo network_; 185 ui::NetworkInfo network_;
184 base::Callback<void(bool)> callback_; 186 base::Callback<void(bool)> callback_;
187 views::View* parent_container_;
185 188
186 views::BlueButton* connect_; 189 views::BlueButton* connect_;
187 views::LabelButton* cancel_; 190 views::LabelButton* cancel_;
188 views::Textfield* textfield_; 191 views::Textfield* textfield_;
189 views::Label* error_msg_; 192 views::Label* error_msg_;
190 base::WeakPtrFactory<PasswordView> weak_ptr_; 193 base::WeakPtrFactory<PasswordView> weak_ptr_;
191 194
192 DISALLOW_COPY_AND_ASSIGN(PasswordView); 195 DISALLOW_COPY_AND_ASSIGN(PasswordView);
193 }; 196 };
194 197
195 // A View that represents a single row in the network list. This row also 198 // A View that represents a single row in the network list. This row also
196 // contains the View for taking password for password-protected networks. 199 // contains the View for taking password for password-protected networks.
197 class NetworkRow : public views::View { 200 class NetworkRow : public views::View {
198 public: 201 public:
199 NetworkRow(const ui::NetworkInfo& network) 202 NetworkRow(const ui::NetworkInfo& network, views::View* container)
200 : network_(network), weak_ptr_(this) { 203 : network_(network), container_(container), weak_ptr_(this) {
201 SetBorder(views::Border::CreateEmptyBorder(10, 5, 10, 5)); 204 SetBorder(views::Border::CreateEmptyBorder(10, 5, 10, 5));
202 SetLayoutManager( 205 SetLayoutManager(
203 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 10)); 206 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 10));
204 Update(network); 207 Update(network);
205 } 208 }
206 209
207 virtual ~NetworkRow() {} 210 virtual ~NetworkRow() {}
208 211
209 void Update(const ui::NetworkInfo& network) { 212 void Update(const ui::NetworkInfo& network) {
210 network_ = network; 213 network_ = network;
211 views::ImageView* icon = new views::ImageView(); 214 views::ImageView* icon = new views::ImageView();
212 icon->SetImage(network.image); 215 icon->SetImage(network.image);
213 icon->SetBounds(0, 0, network.image.width(), network.image.height()); 216 icon->SetBounds(0, 0, network.image.width(), network.image.height());
214 217
215 views::Label* label = new views::Label(network.label); 218 views::Label* label = new views::Label(network.label);
216 if (network.highlight) 219 if (network.highlight)
217 label->SetFontList(label->font_list().Derive(0, gfx::Font::BOLD)); 220 label->SetFontList(label->font_list().Derive(0, gfx::Font::BOLD));
218 AddChildView(icon); 221 AddChildView(icon);
219 AddChildView(label); 222 AddChildView(label);
220 if (password_view_) 223 if (password_view_)
221 AddChildView(password_view_.get()); 224 AddChildView(password_view_.get());
222 } 225 }
223 226
224 bool has_password_view() const { return password_view_; } 227 bool has_password_view() const { return password_view_; }
225 228
226 private: 229 private:
227 void OnPasswordComplete(bool successful) { 230 void OnPasswordComplete(bool successful) {
228 password_view_.reset(); 231 password_view_.reset();
229 InvalidateLayout(); 232 InvalidateLayout();
230 GetWidget()->GetRootView()->Layout(); 233 container_->Layout();
231 ScrollRectToVisible(GetContentsBounds()); 234 ScrollRectToVisible(GetContentsBounds());
232 } 235 }
233 236
234 void ShowPasswordView(const std::string& service_path) { 237 void ShowPasswordView(const std::string& service_path) {
235 const NetworkState* network = 238 const NetworkState* network =
236 NetworkHandler::Get()->network_state_handler()->GetNetworkState( 239 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
237 service_path); 240 service_path);
238 if (!network) 241 if (!network)
239 return; 242 return;
240 243
241 // If this is not a wifi network that needs a password, then ignore. 244 // If this is not a wifi network that needs a password, then ignore.
242 if (network->type() != shill::kTypeWifi || 245 if (network->type() != shill::kTypeWifi ||
243 network->security() == shill::kSecurityNone) { 246 network->security() == shill::kSecurityNone) {
244 return; 247 return;
245 } 248 }
246 249
247 password_view_.reset(new PasswordView( 250 password_view_.reset(new PasswordView(
248 network_, 251 network_,
249 base::Bind(&NetworkRow::OnPasswordComplete, weak_ptr_.GetWeakPtr()))); 252 base::Bind(&NetworkRow::OnPasswordComplete, weak_ptr_.GetWeakPtr()),
253 container_));
250 password_view_->set_owned_by_client(); 254 password_view_->set_owned_by_client();
251 AddChildView(password_view_.get()); 255 AddChildView(password_view_.get());
252 PreferredSizeChanged(); 256 PreferredSizeChanged();
253 GetWidget()->GetRootView()->Layout(); 257 container_->Layout();
254 ScrollRectToVisible(password_view_->bounds()); 258 ScrollRectToVisible(password_view_->bounds());
255 } 259 }
256 260
257 void OnNetworkConnectionError(const std::string& service_path, 261 void OnNetworkConnectionError(const std::string& service_path,
258 const std::string& error_name, 262 const std::string& error_name,
259 scoped_ptr<base::DictionaryValue> error_data) { 263 scoped_ptr<base::DictionaryValue> error_data) {
260 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled) 264 if (error_name == NetworkConnectionHandler::kErrorConnectCanceled)
261 return; 265 return;
262 if (error_name == shill::kErrorBadPassphrase || 266 if (error_name == shill::kErrorBadPassphrase ||
263 error_name == NetworkConnectionHandler::kErrorPassphraseRequired || 267 error_name == NetworkConnectionHandler::kErrorPassphraseRequired ||
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 303 }
300 304
301 virtual void OnGestureEvent(ui::GestureEvent* gesture) override { 305 virtual void OnGestureEvent(ui::GestureEvent* gesture) override {
302 if (gesture->type() != ui::ET_GESTURE_TAP) 306 if (gesture->type() != ui::ET_GESTURE_TAP)
303 return; 307 return;
304 ActivateNetwork(); 308 ActivateNetwork();
305 gesture->SetHandled(); 309 gesture->SetHandled();
306 } 310 }
307 311
308 ui::NetworkInfo network_; 312 ui::NetworkInfo network_;
313 views::View* container_;
309 scoped_ptr<views::View> password_view_; 314 scoped_ptr<views::View> password_view_;
310 base::WeakPtrFactory<NetworkRow> weak_ptr_; 315 base::WeakPtrFactory<NetworkRow> weak_ptr_;
311 316
312 DISALLOW_COPY_AND_ASSIGN(NetworkRow); 317 DISALLOW_COPY_AND_ASSIGN(NetworkRow);
313 }; 318 };
314 319
315 class NetworkSelector : public ui::NetworkListDelegate, 320 class NetworkSelector : public ui::NetworkListDelegate,
316 public chromeos::NetworkStateHandlerObserver, 321 public chromeos::NetworkStateHandlerObserver,
317 public views::DialogDelegate { 322 public ui::EventHandler {
318 public: 323 public:
319 NetworkSelector() 324 explicit NetworkSelector(aura::Window* container)
320 : scroll_content_(NULL), scroller_(NULL), network_list_(this) { 325 : background_view_(NULL),
326 scroll_content_(NULL),
327 scroller_(NULL),
328 network_list_(this) {
329 CreateWidget(container);
321 CreateNetworkList(); 330 CreateNetworkList();
322 CreateWidget();
323 331
324 NetworkHandler::Get()->network_state_handler()->RequestScan(); 332 NetworkHandler::Get()->network_state_handler()->RequestScan();
325 NetworkHandler::Get()->network_state_handler()->AddObserver(this, 333 NetworkHandler::Get()->network_state_handler()->AddObserver(this,
326 FROM_HERE); 334 FROM_HERE);
327 } 335 }
328 336
329 virtual ~NetworkSelector() { 337 virtual ~NetworkSelector() {
330 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, 338 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
331 FROM_HERE); 339 FROM_HERE);
332 } 340 }
333 341
334 private: 342 private:
335 void CreateWidget() { 343 void CreateWidget(aura::Window* container) {
336 // Same as CreateDialogWidgetWithBounds() with an empty |bounds|. 344 views::Widget::InitParams params;
337 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( 345 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
338 this, athena::ScreenManager::Get()->GetContext(), NULL); 346 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
339 widget->Show(); 347 params.activatable = views::Widget::InitParams::ACTIVATABLE_DEFAULT;
340 widget->CenterWindow(gfx::Size(400, 400)); 348 params.accept_events = true;
349 params.bounds = gfx::Rect(container->bounds().size());
350 params.parent = container;
351 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
352 widget_.reset(new views::Widget());
353 widget_->Init(params);
354 widget_->Show();
355
356 background_view_ = new views::View;
357 background_view_->set_background(
358 views::Background::CreateSolidBackground(kBackgroundColor));
359 background_view_->SetBorder(
360 views::Border::CreateEmptyBorder(100, 300, 300, 300));
361 background_view_->SetLayoutManager(new views::FillLayout());
362 background_view_->set_target_handler(this);
363
364 widget_->SetContentsView(background_view_);
341 } 365 }
342 366
343 void CreateNetworkList() { 367 void CreateNetworkList() {
344 const int kListHeight = 400; 368 const int kListHeight = 500;
345 scroller_ = new views::ScrollView(); 369 scroller_ = new views::ScrollView();
346 scroller_->set_background( 370 scroller_->set_background(
347 views::Background::CreateSolidBackground(SK_ColorWHITE)); 371 views::Background::CreateSolidBackground(SK_ColorWHITE));
372 scroller_->SetBounds(0, 0, 400, kListHeight);
348 373
349 scroll_content_ = new views::View; 374 scroll_content_ = new views::View;
350 scroll_content_->SetLayoutManager( 375 scroll_content_->SetLayoutManager(
351 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 376 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
352 scroller_->SetContents(scroll_content_); 377 scroller_->SetContents(scroll_content_);
353 378
354 scroller_->ClipHeightTo(kListHeight, kListHeight); 379 scroller_->ClipHeightTo(kListHeight, kListHeight);
355 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); 380 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
381 background_view_->AddChildView(scroller_);
382
383 background_view_->Layout();
356 384
357 network_list_.set_content_view(scroll_content_); 385 network_list_.set_content_view(scroll_content_);
358 } 386 }
359 387
360 void UpdateNetworkList() { network_list_.UpdateNetworkList(); } 388 void UpdateNetworkList() { network_list_.UpdateNetworkList(); }
361 389
390 void Close() { delete this; }
391
362 // ui::NetworkListDelegate: 392 // ui::NetworkListDelegate:
363 virtual views::View* CreateViewForNetwork( 393 virtual views::View* CreateViewForNetwork(
364 const ui::NetworkInfo& info) override { 394 const ui::NetworkInfo& info) override {
365 return new NetworkRow(info); 395 return new NetworkRow(info, background_view_);
366 } 396 }
367 397
368 virtual bool IsViewHovered(views::View* view) override { 398 virtual bool IsViewHovered(views::View* view) override {
369 return static_cast<NetworkRow*>(view)->has_password_view(); 399 return static_cast<NetworkRow*>(view)->has_password_view();
370 } 400 }
371 401
372 virtual chromeos::NetworkTypePattern GetNetworkTypePattern() const override { 402 virtual chromeos::NetworkTypePattern GetNetworkTypePattern() const override {
373 return chromeos::NetworkTypePattern::NonVirtual(); 403 return chromeos::NetworkTypePattern::NonVirtual();
374 } 404 }
375 405
(...skipping 16 matching lines...) Expand all
392 422
393 virtual void DefaultNetworkChanged( 423 virtual void DefaultNetworkChanged(
394 const chromeos::NetworkState* network) override {} 424 const chromeos::NetworkState* network) override {}
395 425
396 virtual void NetworkConnectionStateChanged( 426 virtual void NetworkConnectionStateChanged(
397 const chromeos::NetworkState* network) override {} 427 const chromeos::NetworkState* network) override {}
398 428
399 virtual void NetworkPropertiesUpdated( 429 virtual void NetworkPropertiesUpdated(
400 const chromeos::NetworkState* network) override {} 430 const chromeos::NetworkState* network) override {}
401 431
402 // views::DialogDelegate: 432 // ui::EventHandler:
403 virtual ui::ModalType GetModalType() const override { 433 virtual void OnMouseEvent(ui::MouseEvent* mouse) override {
404 return ui::MODAL_TYPE_SYSTEM; 434 CHECK_EQ(background_view_, mouse->target());
435 if (mouse->type() == ui::ET_MOUSE_PRESSED && !mouse->handled()) {
436 Close();
437 mouse->SetHandled();
438 }
405 } 439 }
406 virtual void DeleteDelegate() override { delete this; } 440
407 virtual views::Widget* GetWidget() override { return scroller_->GetWidget(); } 441 virtual void OnGestureEvent(ui::GestureEvent* gesture) override {
408 virtual const views::Widget* GetWidget() const override { 442 CHECK_EQ(background_view_, gesture->target());
409 return scroller_->GetWidget(); 443 if (gesture->type() == ui::ET_GESTURE_TAP && !gesture->handled()) {
444 Close();
445 gesture->SetHandled();
446 }
410 } 447 }
411 virtual views::View* GetContentsView() override { return scroller_; }
412 virtual int GetDialogButtons() const override { return ui::DIALOG_BUTTON_OK; }
413 virtual bool Close() override { return true; }
414 448
449 scoped_ptr<views::Widget> widget_;
450 views::View* background_view_;
415 views::View* scroll_content_; 451 views::View* scroll_content_;
416 views::ScrollView* scroller_; 452 views::ScrollView* scroller_;
417 453
418 views::View* connect_; 454 views::View* connect_;
419 455
420 ui::NetworkListView network_list_; 456 ui::NetworkListView network_list_;
421 457
422 DISALLOW_COPY_AND_ASSIGN(NetworkSelector); 458 DISALLOW_COPY_AND_ASSIGN(NetworkSelector);
423 }; 459 };
424 460
425 } // namespace 461 } // namespace
426 462
427 namespace athena { 463 namespace athena {
428 464
429 void CreateNetworkSelector() { 465 void CreateNetworkSelector(aura::Window* container) {
430 new NetworkSelector(); 466 new NetworkSelector(container);
431 } 467 }
432 468
433 } // namespace athena 469 } // namespace athena
OLDNEW
« no previous file with comments | « athena/system/network_selector.h ('k') | athena/system/shutdown_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698