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 {
CP_BACKGROUND = 0,
CP_DEFAULT,
CP_HOME_CARD,
CP_VIRTUAL_KEYBOARD,
CP_DEBUG,
CP_VIRTUAL_KEYBOARD,
};
} // namespace athena
......
......@@ -30,6 +30,7 @@
'../../skia/skia.gyp:skia',
'../../ui/accessibility/accessibility.gyp:ax_gen',
'../../ui/app_list/app_list.gyp:app_list',
'../../ui/chromeos/ui_chromeos.gyp:ui_chromeos',
'../../ui/keyboard/keyboard.gyp:keyboard',
'../../ui/views/views.gyp:views',
'../../url/url.gyp:url_lib',
......@@ -44,6 +45,8 @@
'athena_launcher.h',
'debug/debug_window.cc',
'debug/debug_window.h',
'debug/network_selector.cc',
'debug/network_selector.h',
'url_search_provider.cc',
'url_search_provider.h',
'athena_main.cc',
......
include_rules = [
"+athena/resources",
"+chromeos",
"+third_party/cros_system_api/dbus/service_constants.h",
"+ui/aura",
"+ui/chromeos",
"+ui/gfx",
"+ui/views",
]
......@@ -5,6 +5,7 @@
#include "athena/main/debug/debug_window.h"
#include "athena/common/container_priorities.h"
#include "athena/main/debug/network_selector.h"
#include "athena/resources/athena_resources.h"
#include "athena/screen/public/screen_manager.h"
#include "base/bind.h"
......@@ -153,6 +154,33 @@ class NetworkStatus : public chromeos::NetworkStateHandlerObserver {
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 {
public:
DebugWidget() : container_(NULL), widget_(NULL) {
......@@ -171,6 +199,7 @@ class DebugWidget {
void CreateContainer() {
athena::ScreenManager::ContainerParams params("DebugContainer",
athena::CP_DEBUG);
params.can_activate_children = true;
container_ = athena::ScreenManager::Get()->CreateContainer(params);
}
......@@ -179,12 +208,14 @@ class DebugWidget {
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.accept_events = false;
params.accept_events = true;
params.bounds = gfx::Rect(200, 0, 100, 105);
params.parent = container_;
widget_ = new views::Widget();
widget_->Init(params);
event_handler_.reset(new DetailViewHandler(container_));
const int kHorizontalSpacing = 10;
const int kBorderVerticalSpacing = 3;
const int kBetweenChildSpacing = 10;
......@@ -198,6 +229,7 @@ class DebugWidget {
container->set_background(
views::Background::CreateSolidBackground(kBackgroundColor));
container->SetBorder(views::Border::CreateSolidBorder(1, kBackgroundColor));
container->set_target_handler(event_handler_.get());
widget_->SetContentsView(container);
widget_->StackAtTop();
widget_->Show();
......@@ -244,6 +276,7 @@ class DebugWidget {
views::Widget* widget_;
scoped_ptr<PowerStatus> power_status_;
scoped_ptr<NetworkStatus> network_status_;
scoped_ptr<ui::EventHandler> event_handler_;
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 @@
'../../content/content_resources.gyp:content_resources',
'../../extensions/shell/app_shell.gyp:app_shell_pak',
'../../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',
],
'actions': [{
......@@ -25,6 +27,8 @@
'<(SHARED_INTERMEDIATE_DIR)/ash/resources/ash_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_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',
],
'pak_output': '<(PRODUCT_DIR)/athena_resources.pak',
......
......@@ -641,7 +641,7 @@ bool NetworkIconImpl::UpdateCellularState(const NetworkState* network) {
bool NetworkIconImpl::UpdatePortalState(const NetworkState* network) {
bool behind_captive_portal = false;
if (network) {
if (network && NetworkPortalDetector::IsInitialized()) {
NetworkPortalDetector::CaptivePortalState state =
NetworkPortalDetector::Get()->GetCaptivePortalState(network->guid());
behind_captive_portal =
......
......@@ -8,6 +8,7 @@
#include <string>
#include "base/strings/string16.h"
#include "ui/chromeos/ui_chromeos_export.h"
#include "ui/gfx/image/image_skia.h"
namespace gfx {
......@@ -18,7 +19,7 @@ namespace ui {
// Includes information necessary about a network for displaying the appropriate
// UI to the user.
struct NetworkInfo {
struct UI_CHROMEOS_EXPORT NetworkInfo {
NetworkInfo();
NetworkInfo(const std::string& path);
~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