Commit 45f0b3a2 authored by sadrul@chromium.org's avatar sadrul@chromium.org

athena: Add a network-selector widget.

The widget allows selecting a network to connect to. It also has basic support
for connecting to password protected networks.

BUG=387199
R=derat@chromium.org, oshima@chromium.org

Review URL: https://codereview.chromium.org/425783003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286142 0039d316-1c4b-4281-b951-d872f2087c98
parent 17cd0c71
...@@ -11,8 +11,8 @@ enum ContainerPriorities { ...@@ -11,8 +11,8 @@ enum ContainerPriorities {
CP_BACKGROUND = 0, CP_BACKGROUND = 0,
CP_DEFAULT, CP_DEFAULT,
CP_HOME_CARD, CP_HOME_CARD,
CP_VIRTUAL_KEYBOARD,
CP_DEBUG, CP_DEBUG,
CP_VIRTUAL_KEYBOARD,
}; };
} // namespace athena } // namespace athena
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
'../../skia/skia.gyp:skia', '../../skia/skia.gyp:skia',
'../../ui/accessibility/accessibility.gyp:ax_gen', '../../ui/accessibility/accessibility.gyp:ax_gen',
'../../ui/app_list/app_list.gyp:app_list', '../../ui/app_list/app_list.gyp:app_list',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos',
'../../ui/keyboard/keyboard.gyp:keyboard', '../../ui/keyboard/keyboard.gyp:keyboard',
'../../ui/views/views.gyp:views', '../../ui/views/views.gyp:views',
'../../url/url.gyp:url_lib', '../../url/url.gyp:url_lib',
...@@ -44,6 +45,8 @@ ...@@ -44,6 +45,8 @@
'athena_launcher.h', 'athena_launcher.h',
'debug/debug_window.cc', 'debug/debug_window.cc',
'debug/debug_window.h', 'debug/debug_window.h',
'debug/network_selector.cc',
'debug/network_selector.h',
'url_search_provider.cc', 'url_search_provider.cc',
'url_search_provider.h', 'url_search_provider.h',
'athena_main.cc', 'athena_main.cc',
......
include_rules = [ include_rules = [
"+athena/resources", "+athena/resources",
"+chromeos", "+chromeos",
"+third_party/cros_system_api/dbus/service_constants.h",
"+ui/aura", "+ui/aura",
"+ui/chromeos",
"+ui/gfx", "+ui/gfx",
"+ui/views", "+ui/views",
] ]
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "athena/main/debug/debug_window.h" #include "athena/main/debug/debug_window.h"
#include "athena/common/container_priorities.h" #include "athena/common/container_priorities.h"
#include "athena/main/debug/network_selector.h"
#include "athena/resources/athena_resources.h" #include "athena/resources/athena_resources.h"
#include "athena/screen/public/screen_manager.h" #include "athena/screen/public/screen_manager.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -153,6 +154,33 @@ class NetworkStatus : public chromeos::NetworkStateHandlerObserver { ...@@ -153,6 +154,33 @@ class NetworkStatus : public chromeos::NetworkStateHandlerObserver {
base::Closure closure_; base::Closure closure_;
}; };
// Processes user input to show the detailed network-list.
class DetailViewHandler : public ui::EventHandler {
public:
explicit DetailViewHandler(aura::Window* container) : container_(container) {}
virtual ~DetailViewHandler() {}
private:
// ui::EventHandler:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
if (event->type() == ui::ET_MOUSE_PRESSED) {
debug::CreateNetworkSelector(container_);
event->SetHandled();
}
}
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
if (event->type() == ui::ET_GESTURE_TAP) {
debug::CreateNetworkSelector(container_);
event->SetHandled();
}
}
aura::Window* container_;
DISALLOW_COPY_AND_ASSIGN(DetailViewHandler);
};
class DebugWidget { class DebugWidget {
public: public:
DebugWidget() : container_(NULL), widget_(NULL) { DebugWidget() : container_(NULL), widget_(NULL) {
...@@ -171,6 +199,7 @@ class DebugWidget { ...@@ -171,6 +199,7 @@ class DebugWidget {
void CreateContainer() { void CreateContainer() {
athena::ScreenManager::ContainerParams params("DebugContainer", athena::ScreenManager::ContainerParams params("DebugContainer",
athena::CP_DEBUG); athena::CP_DEBUG);
params.can_activate_children = true;
container_ = athena::ScreenManager::Get()->CreateContainer(params); container_ = athena::ScreenManager::Get()->CreateContainer(params);
} }
...@@ -179,12 +208,14 @@ class DebugWidget { ...@@ -179,12 +208,14 @@ class DebugWidget {
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.accept_events = false; params.accept_events = true;
params.bounds = gfx::Rect(200, 0, 100, 105); params.bounds = gfx::Rect(200, 0, 100, 105);
params.parent = container_; params.parent = container_;
widget_ = new views::Widget(); widget_ = new views::Widget();
widget_->Init(params); widget_->Init(params);
event_handler_.reset(new DetailViewHandler(container_));
const int kHorizontalSpacing = 10; const int kHorizontalSpacing = 10;
const int kBorderVerticalSpacing = 3; const int kBorderVerticalSpacing = 3;
const int kBetweenChildSpacing = 10; const int kBetweenChildSpacing = 10;
...@@ -198,6 +229,7 @@ class DebugWidget { ...@@ -198,6 +229,7 @@ class DebugWidget {
container->set_background( container->set_background(
views::Background::CreateSolidBackground(kBackgroundColor)); views::Background::CreateSolidBackground(kBackgroundColor));
container->SetBorder(views::Border::CreateSolidBorder(1, kBackgroundColor)); container->SetBorder(views::Border::CreateSolidBorder(1, kBackgroundColor));
container->set_target_handler(event_handler_.get());
widget_->SetContentsView(container); widget_->SetContentsView(container);
widget_->StackAtTop(); widget_->StackAtTop();
widget_->Show(); widget_->Show();
...@@ -244,6 +276,7 @@ class DebugWidget { ...@@ -244,6 +276,7 @@ class DebugWidget {
views::Widget* widget_; views::Widget* widget_;
scoped_ptr<PowerStatus> power_status_; scoped_ptr<PowerStatus> power_status_;
scoped_ptr<NetworkStatus> network_status_; scoped_ptr<NetworkStatus> network_status_;
scoped_ptr<ui::EventHandler> event_handler_;
DISALLOW_COPY_AND_ASSIGN(DebugWidget); DISALLOW_COPY_AND_ASSIGN(DebugWidget);
}; };
......
This diff is collapsed.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
#define ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
namespace aura {
class Window;
}
namespace debug {
void CreateNetworkSelector(aura::Window* window);
} // namespace debug
#endif // ATHENA_MAIN_DEBUG_NETWORK_SELECTOR_H_
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
'../../content/content_resources.gyp:content_resources', '../../content/content_resources.gyp:content_resources',
'../../extensions/shell/app_shell.gyp:app_shell_pak', '../../extensions/shell/app_shell.gyp:app_shell_pak',
'../../third_party/WebKit/public/blink_resources.gyp:blink_resources', '../../third_party/WebKit/public/blink_resources.gyp:blink_resources',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos_resources',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos_strings',
'../../webkit/webkit_resources.gyp:webkit_strings', '../../webkit/webkit_resources.gyp:webkit_strings',
], ],
'actions': [{ 'actions': [{
...@@ -25,6 +27,8 @@ ...@@ -25,6 +27,8 @@
'<(SHARED_INTERMEDIATE_DIR)/ash/resources/ash_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/ash/resources/ash_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/chromeos/resources/ui_chromeos_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/chromeos/strings/ui_chromeos_strings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak',
], ],
'pak_output': '<(PRODUCT_DIR)/athena_resources.pak', 'pak_output': '<(PRODUCT_DIR)/athena_resources.pak',
......
...@@ -641,7 +641,7 @@ bool NetworkIconImpl::UpdateCellularState(const NetworkState* network) { ...@@ -641,7 +641,7 @@ bool NetworkIconImpl::UpdateCellularState(const NetworkState* network) {
bool NetworkIconImpl::UpdatePortalState(const NetworkState* network) { bool NetworkIconImpl::UpdatePortalState(const NetworkState* network) {
bool behind_captive_portal = false; bool behind_captive_portal = false;
if (network) { if (network && NetworkPortalDetector::IsInitialized()) {
NetworkPortalDetector::CaptivePortalState state = NetworkPortalDetector::CaptivePortalState state =
NetworkPortalDetector::Get()->GetCaptivePortalState(network->guid()); NetworkPortalDetector::Get()->GetCaptivePortalState(network->guid());
behind_captive_portal = behind_captive_portal =
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "ui/chromeos/ui_chromeos_export.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
namespace gfx { namespace gfx {
...@@ -18,7 +19,7 @@ namespace ui { ...@@ -18,7 +19,7 @@ namespace ui {
// Includes information necessary about a network for displaying the appropriate // Includes information necessary about a network for displaying the appropriate
// UI to the user. // UI to the user.
struct NetworkInfo { struct UI_CHROMEOS_EXPORT NetworkInfo {
NetworkInfo(); NetworkInfo();
NetworkInfo(const std::string& path); NetworkInfo(const std::string& path);
~NetworkInfo(); ~NetworkInfo();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment