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

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

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