Commit f706d3dc authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Replace chrome://network implementation with networkConfig API

This CL does the following:
* Moves chrome://network resources into their own directory
* Separates 'requestNetworkInfo' into two separate methods:
** NetworkUI.getNetworkLog
** networkConfig.getNetworks
* Moves networkConfig methods into their own module
** networkConfig emulates a subset of the chrome.networkingPrivate extension API
** This module will later also be used by the internet options JS code

BUG=366365
For c/b/browser_resources.grd:

R=armansito@chromium.org, pneubeck@chromium.org, xiyuan@chromium.org
TBR=sky@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273007 0039d316-1c4b-4281-b951-d872f2087c98
parent df68cbbe
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<structure name="IDR_OOBE_ENROLLMENT_CSS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.css" flattenhtml="true" type="chrome_html" /> <structure name="IDR_OOBE_ENROLLMENT_CSS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.css" flattenhtml="true" type="chrome_html" />
<structure name="IDR_OOBE_ENROLLMENT_JS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.js" flattenhtml="true" type="chrome_html" /> <structure name="IDR_OOBE_ENROLLMENT_JS" file="resources\chromeos\login\oobe_screen_oauth_enrollment.js" flattenhtml="true" type="chrome_html" />
<structure name="IDR_KEYBOARD_UTILS_JS" file="resources\chromeos\keyboard\keyboard_utils.js" flattenhtml="true" type="chrome_html" /> <structure name="IDR_KEYBOARD_UTILS_JS" file="resources\chromeos\keyboard\keyboard_utils.js" flattenhtml="true" type="chrome_html" />
<structure name="IDR_NETWORK_CONFIG_JS" file="resources\chromeos\network\network_config.js" flattenhtml="true" type="chrome_html" />
</if> </if>
<structure name="IDR_READER_OUT_OF_DATE_HTML" file="resources\reader_out_of_date.html" flattenhtml="true" type="chrome_html" /> <structure name="IDR_READER_OUT_OF_DATE_HTML" file="resources\reader_out_of_date.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_SSL_ROAD_BLOCK_HTML" file="resources\ssl\roadblock.html" flattenhtml="true" type="chrome_html" /> <structure name="IDR_SSL_ROAD_BLOCK_HTML" file="resources\ssl\roadblock.html" flattenhtml="true" type="chrome_html" />
...@@ -374,9 +375,9 @@ ...@@ -374,9 +375,9 @@
<include name="IDR_IDENTITY_INTERNALS_JS" file="resources\identity_internals.js" type="BINDATA" /> <include name="IDR_IDENTITY_INTERNALS_JS" file="resources\identity_internals.js" type="BINDATA" />
</if> </if>
<if expr="chromeos"> <if expr="chromeos">
<include name="IDR_NETWORK_HTML" file="resources\chromeos\network.html" type="BINDATA" /> <include name="IDR_NETWORK_UI_HTML" file="resources\chromeos\network_ui\network_ui.html" type="BINDATA" />
<include name="IDR_NETWORK_JS" file="resources\chromeos\network.js" type="BINDATA" /> <include name="IDR_NETWORK_UI_JS" file="resources\chromeos\network_ui\network_ui.js" type="BINDATA" />
<include name="IDR_NETWORK_CSS" file="resources\chromeos\network.css" type="BINDATA" /> <include name="IDR_NETWORK_UI_CSS" file="resources\chromeos\network_ui\network_ui.css" type="BINDATA" />
</if> </if>
<if expr="_google_chrome"> <if expr="_google_chrome">
<include name="IDR_PREF_HASH_SEED_BIN" file="resources\settings_internal\pref_hash_seed.bin" type="BINDATA" /> <include name="IDR_PREF_HASH_SEED_BIN" file="resources\settings_internal\pref_hash_seed.bin" type="BINDATA" />
......
...@@ -303,7 +303,7 @@ bool NetworkingPrivateGetNetworksFunction::RunAsync() { ...@@ -303,7 +303,7 @@ bool NetworkingPrivateGetNetworksFunction::RunAsync() {
params->filter.limit ? *params->filter.limit : kDefaultNetworkListLimit; params->filter.limit ? *params->filter.limit : kDefaultNetworkListLimit;
scoped_ptr<base::ListValue> network_properties_list = scoped_ptr<base::ListValue> network_properties_list =
chromeos::network_util::TranslateNetworkListToONC( chromeos::network_util::TranslateNetworkListToONC(
pattern, configured_only, visible_only, limit); pattern, configured_only, visible_only, limit, false /* debugging */);
SetResult(network_properties_list.release()); SetResult(network_properties_list.release());
SendResponse(true); SendResponse(true);
return true; return true;
...@@ -326,7 +326,8 @@ bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() { ...@@ -326,7 +326,8 @@ bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() {
const bool visible_only = true; const bool visible_only = true;
scoped_ptr<base::ListValue> network_properties_list = scoped_ptr<base::ListValue> network_properties_list =
chromeos::network_util::TranslateNetworkListToONC( chromeos::network_util::TranslateNetworkListToONC(
pattern, configured_only, visible_only, kDefaultNetworkListLimit); pattern, configured_only, visible_only, kDefaultNetworkListLimit,
false /* debugging */);
SetResult(network_properties_list.release()); SetResult(network_properties_list.release());
SendResponse(true); SendResponse(true);
return true; return true;
......
// 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.
'use strict';
/**
* @fileoverview This object provides a similar API to chrome.networkingPrivate.
* It simulates the extension callback model by storing callbacks in a member
* object and invoking them when the corresponding method is called by Chrome in
* response to a chrome.send call.
*/
var networkConfig = {
/**
* Return the property associated with a key (which may reference a
* sub-object).
*
* @param {Object} properties The object containing the network properties.
* @param {string} key The ONC key for the property. May refer to a nested
* propety, e.g. 'WiFi.Security'.
* @return {*} The value associated with the property.
*/
getValueFromProperties: function(properties, key) {
if (!key) {
console.error('Empty key');
return undefined;
}
var dot = key.indexOf('.');
if (dot > 0) {
var key1 = key.substring(0, dot);
var key2 = key.substring(dot + 1);
var subobject = properties[key1];
if (subobject)
return this.getValueFromProperties(subobject, key2);
}
return properties[key];
},
/**
* Generate a unique id for 'callback' and store it for future retrieval.
*
* @param {function} callback The associated callback.
* @return {integer} The id of the callback.
* @private
*/
callbackId: 1,
callbackMap: {},
storeCallback_: function(callback) {
var id = this.callbackId++;
this.callbackMap[id] = callback;
return id;
},
/**
* Retrieve the callback associated with |id| and remove it from the map.
*
* @param {integer} id The id of the callback.
* @return {function} The associated callback.
* @private
*/
retrieveCallback_: function(id) {
var callback = this.callbackMap[id];
delete this.callbackMap[id];
return callback;
},
/**
* Callback invoked by Chrome.
*
* @param {Array} args A list of arguments passed to the callback. The first
* entry must be the callbackId passed to chrome.send.
*/
chromeCallbackSuccess: function(args) {
var callbackId = args.shift();
var callback = this.retrieveCallback_(callbackId);
this.lastError = '';
if (callback)
callback.apply(null, args);
else
console.error('Callback not found for id: ' + callbackId);
},
/**
* Error Callback invoked by Chrome. Sets lastError and logs to the console.
*
* @param {Args} args A list of arguments. The first entry must be the
* callbackId passed to chrome.send.
*/
lastError: '',
chromeCallbackError: function(args) {
var callbackId = args.shift();
this.lastError = args.shift();
console.error('Callback error: "' + this.lastError);
// We still invoke the callback, but with null args. The callback should
// check this.lastError and handle that.
var callback = this.retrieveCallback_(callbackId);
if (callback)
callback.apply(null, null);
},
/**
* Implement networkingPrivate.getProperties. See networking_private.json.
*
* @param {string} guid The guid identifying the network.
* @param {function()} callback The callback to call on completion.
*/
getProperties: function(guid, callback) {
var callbackId = this.storeCallback_(callback);
chrome.send('networkConfig.getProperties', [callbackId, guid]);
},
/**
* Implement networkingPrivate.getNetworks. See networking_private.json.
*
* @param {string} guid The guid identifying the network.
* @param {function()} callback The callback to call on completion.
*/
getNetworks: function(filter, callback) {
var callbackId = this.storeCallback_(callback);
chrome.send('networkConfig.getNetworks', [callbackId, filter]);
}
};
...@@ -50,17 +50,13 @@ ...@@ -50,17 +50,13 @@
} }
.state-table-expand-button { .state-table-expand-button {
background-color: #f0f0f0; background-color: #fff;
border: 1px solid; border: none;
border-color: #a0a0a0; height: 20px;
height: 12px; margin: 0;
margin: 4px; outline: none;
padding: 0; padding: 0;
width: 12px; width: 20px;
}
.state-table-expand-button-expanded {
background-color: #b0b0b0;
} }
.state-table-expanded-cell { .state-table-expanded-cell {
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title id="network" i18n-content="titleText"></title> <title id="network" i18n-content="titleText"></title>
<link rel="stylesheet" href="chrome://network/network.css"> <link rel="stylesheet" href="chrome://network/network_ui.css">
<script src="chrome://resources/js/load_time_data.js"></script> <script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script> <script src="chrome://resources/js/util.js"></script>
<script src="chrome://network/strings.js"></script> <script src="chrome://network/strings.js"></script>
<script src="chrome://network/network.js"></script> <script src="chrome://network/network_config.js"></script>
<script src="chrome://network/network_ui.js"></script>
</head> </head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> <body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<p i18n-content="autoRefreshText"></p> <p i18n-content="autoRefreshText"></p>
...@@ -34,13 +35,10 @@ ...@@ -34,13 +35,10 @@
<table id="network-state-table" class="state-table"> <table id="network-state-table" class="state-table">
<tr class="state-table-header"> <tr class="state-table-header">
<td></td> <td></td>
<td>Path</td>
<td>GUID</td> <td>GUID</td>
<td>Name</td> <td>Name</td>
<td>Type</td> <td>Type</td>
<td>State</td> <td>State</td>
<td>Profile</td>
<td>Connect</td>
<td>Error</td> <td>Error</td>
<td>Security</td> <td>Security</td>
<td>Technology</td> <td>Technology</td>
...@@ -54,7 +52,6 @@ ...@@ -54,7 +52,6 @@
<table id="favorite-state-table" class="state-table"> <table id="favorite-state-table" class="state-table">
<tr class="state-table-header"> <tr class="state-table-header">
<td></td> <td></td>
<td>Path</td>
<td>GUID</td> <td>GUID</td>
<td>Name</td> <td>Name</td>
<td>Type</td> <td>Type</td>
......
...@@ -7,6 +7,7 @@ include_rules = [ ...@@ -7,6 +7,7 @@ include_rules = [
"+sync/internal_api/public/events", "+sync/internal_api/public/events",
# Other libraries. # Other libraries.
"+components/onc",
"+device/bluetooth", "+device/bluetooth",
"+device/nfc", "+device/nfc",
"+third_party/angle", # For ANGLE version. "+third_party/angle", # For ANGLE version.
......
// 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.
#include "chrome/browser/ui/webui/chromeos/network_config_message_handler.h"
#include <string>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/values.h"
#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_utils.h"
#include "chromeos/network/shill_property_util.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/web_ui.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
namespace {
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path) {
const FavoriteState* network =
NetworkHandler::Get()->network_state_handler()->GetFavoriteStateFromGuid(
guid);
if (!network)
return false;
*service_path = network->path();
return true;
}
} // namespace
NetworkConfigMessageHandler::NetworkConfigMessageHandler()
: weak_ptr_factory_(this) {
}
NetworkConfigMessageHandler::~NetworkConfigMessageHandler() {
}
void NetworkConfigMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"networkConfig.getNetworks",
base::Bind(&NetworkConfigMessageHandler::GetNetworks,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"networkConfig.getProperties",
base::Bind(&NetworkConfigMessageHandler::GetProperties,
base::Unretained(this)));
}
void NetworkConfigMessageHandler::GetNetworks(
const base::ListValue* arg_list) const {
int callback_id = 0;
const base::DictionaryValue* filter = NULL;
if (!arg_list->GetInteger(0, &callback_id) ||
!arg_list->GetDictionary(1, &filter)) {
NOTREACHED();
}
std::string type = ::onc::network_type::kAllTypes;
bool visible_only = false;
bool configured_only = false;
int limit = 1000;
filter->GetString("type", &type);
NetworkTypePattern pattern = onc::NetworkTypePatternFromOncType(type);
filter->GetBoolean("visible", &visible_only);
filter->GetBoolean("configured", &configured_only);
filter->GetInteger("limit", &limit);
base::ListValue return_arg_list;
return_arg_list.AppendInteger(callback_id);
scoped_ptr<base::ListValue> network_properties_list =
chromeos::network_util::TranslateNetworkListToONC(
pattern, configured_only, visible_only, limit,
true /* debugging_properties */);
return_arg_list.Append(network_properties_list.release());
InvokeCallback(return_arg_list);
}
void NetworkConfigMessageHandler::GetProperties(
const base::ListValue* arg_list) {
int callback_id = 0;
std::string guid;
if (!arg_list->GetInteger(0, &callback_id) ||
!arg_list->GetString(1, &guid)) {
NOTREACHED();
}
std::string service_path;
if (!GetServicePathFromGuid(guid, &service_path)) {
scoped_ptr<base::DictionaryValue> error_data;
ErrorCallback(callback_id, "Error.InvalidNetworkGuid", error_data.Pass());
return;
}
NetworkHandler::Get()->managed_network_configuration_handler()->GetProperties(
service_path,
base::Bind(&NetworkConfigMessageHandler::GetPropertiesSuccess,
weak_ptr_factory_.GetWeakPtr(), callback_id),
base::Bind(&NetworkConfigMessageHandler::ErrorCallback,
weak_ptr_factory_.GetWeakPtr(), callback_id));
}
void NetworkConfigMessageHandler::GetPropertiesSuccess(
int callback_id,
const std::string& service_path,
const base::DictionaryValue& dictionary) const {
base::ListValue return_arg_list;
return_arg_list.AppendInteger(callback_id);
base::DictionaryValue* network_properties = dictionary.DeepCopy();
network_properties->SetStringWithoutPathExpansion(
::onc::network_config::kGUID, service_path);
return_arg_list.Append(network_properties);
InvokeCallback(return_arg_list);
}
void NetworkConfigMessageHandler::InvokeCallback(
const base::ListValue& arg_list) const {
web_ui()->CallJavascriptFunction(
"networkConfig.chromeCallbackSuccess", arg_list);
}
void NetworkConfigMessageHandler::ErrorCallback(
int callback_id,
const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) const {
LOG(ERROR) << "NetworkConfigMessageHandler Error: " << error_name;
base::ListValue arg_list;
arg_list.AppendInteger(callback_id);
arg_list.AppendString(error_name);
web_ui()->CallJavascriptFunction(
"networkConfig.chromeCallbackError", arg_list);
}
} // namespace chromeos
// 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_CONFIG_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_CONFIG_MESSAGE_HANDLER_H_
#include <string>
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace base {
class DictionaryValue;
class ListValue;
}
namespace chromeos {
// This class provides support for network configuration from WebUI components.
// It implements network_config.js which is a drop-in replacement for the
// networkingPrivate extention API. TODO(stevenjb): Implement the remaining
// networkingPrivate methods as needed.
class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
public:
NetworkConfigMessageHandler();
virtual ~NetworkConfigMessageHandler();
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
private:
// WebUI::RegisterMessageCallback callbacks. These callbacks collect the
// requested information and call the associated JS method. The first
// argument in |arg_list| is always the callback id which is passed back
// to the callback method.
void GetNetworks(const base::ListValue* arg_list) const;
void GetProperties(const base::ListValue* arg_list);
void GetPropertiesSuccess(int callback_id,
const std::string& service_path,
const base::DictionaryValue& dictionary) const;
void InvokeCallback(const base::ListValue& arg_list) const;
void ErrorCallback(int callback_id,
const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) const;
base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkConfigMessageHandler);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_CONFIG_MESSAGE_HANDLER_H_
...@@ -8,14 +8,11 @@ ...@@ -8,14 +8,11 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/json/json_string_value_serializer.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/network_config_message_handler.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_event_log.h" #include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h" #include "content/public/browser/web_contents.h"
#include "chromeos/network/network_state_handler.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h" #include "content/public/browser/web_ui_message_handler.h"
...@@ -26,111 +23,40 @@ namespace chromeos { ...@@ -26,111 +23,40 @@ namespace chromeos {
namespace { namespace {
const char kStringsJsFile[] = "strings.js"; const int kMaxLogEvents = 1000;
const char kRequestNetworkInfoCallback[] = "requestNetworkInfo";
const char kNetworkEventLogTag[] = "networkEventLog";
const char kNetworkStateTag[] = "networkStates";
const char kFavoriteStateTag[] = "favoriteStates";
const char kOnNetworkInfoReceivedFunction[] = "NetworkUI.onNetworkInfoReceived";
class NetworkMessageHandler : public content::WebUIMessageHandler { class NetworkUIMessageHandler : public content::WebUIMessageHandler {
public: public:
NetworkMessageHandler(); NetworkUIMessageHandler() {}
virtual ~NetworkMessageHandler(); virtual ~NetworkUIMessageHandler() {}
// WebUIMessageHandler implementation. // WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE; virtual void RegisterMessages() OVERRIDE {
web_ui()->RegisterMessageCallback(
"NetworkUI.getNetworkLog",
base::Bind(&NetworkUIMessageHandler::GetNetworkLog,
base::Unretained(this)));
}
private: private:
void CollectNetworkInfo(const base::ListValue* value) const; void GetNetworkLog(const base::ListValue* value) const {
std::string GetNetworkEventLog() const; base::StringValue data(chromeos::network_event_log::GetAsString(
void GetNetworkState(base::DictionaryValue* output) const; chromeos::network_event_log::NEWEST_FIRST,
void GetFavoriteState(base::DictionaryValue* output) const; "json",
void RespondToPage(const base::DictionaryValue& value) const; chromeos::network_event_log::LOG_LEVEL_DEBUG,
kMaxLogEvents));
DISALLOW_COPY_AND_ASSIGN(NetworkMessageHandler); web_ui()->CallJavascriptFunction("NetworkUI.getNetworkLogCallback", data);
};
NetworkMessageHandler::NetworkMessageHandler() {
}
NetworkMessageHandler::~NetworkMessageHandler() {
}
void NetworkMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
kRequestNetworkInfoCallback,
base::Bind(&NetworkMessageHandler::CollectNetworkInfo,
base::Unretained(this)));
}
void NetworkMessageHandler::CollectNetworkInfo(
const base::ListValue* value) const {
base::DictionaryValue data;
data.SetString(kNetworkEventLogTag, GetNetworkEventLog());
base::DictionaryValue* networkState = new base::DictionaryValue;
GetNetworkState(networkState);
data.Set(kNetworkStateTag, networkState);
base::DictionaryValue* favoriteState = new base::DictionaryValue;
GetFavoriteState(favoriteState);
data.Set(kFavoriteStateTag, favoriteState);
RespondToPage(data);
}
void NetworkMessageHandler::RespondToPage(
const base::DictionaryValue& value) const {
web_ui()->CallJavascriptFunction(kOnNetworkInfoReceivedFunction, value);
}
std::string NetworkMessageHandler::GetNetworkEventLog() const {
std::string format = "json";
return chromeos::network_event_log::GetAsString(
chromeos::network_event_log::NEWEST_FIRST,
format,
chromeos::network_event_log::LOG_LEVEL_DEBUG,
0);
}
void NetworkMessageHandler::GetNetworkState(
base::DictionaryValue* output) const {
chromeos::NetworkStateHandler* handler =
chromeos::NetworkHandler::Get()->network_state_handler();
chromeos::NetworkStateHandler::NetworkStateList network_list;
handler->GetNetworkList(&network_list);
for (chromeos::NetworkStateHandler::NetworkStateList::const_iterator it =
network_list.begin();
it != network_list.end();
++it) {
base::DictionaryValue* properties = new base::DictionaryValue;
(*it)->GetStateProperties(properties);
output->Set((*it)->path(), properties);
} }
}
void NetworkMessageHandler::GetFavoriteState( DISALLOW_COPY_AND_ASSIGN(NetworkUIMessageHandler);
base::DictionaryValue* output) const { };
chromeos::NetworkStateHandler* handler =
chromeos::NetworkHandler::Get()->network_state_handler();
chromeos::NetworkStateHandler::FavoriteStateList favorite_list;
handler->GetFavoriteList(&favorite_list);
for (chromeos::NetworkStateHandler::FavoriteStateList::const_iterator it =
favorite_list.begin();
it != favorite_list.end();
++it) {
base::DictionaryValue* properties = new base::DictionaryValue;
(*it)->GetStateProperties(properties);
output->Set((*it)->path(), properties);
}
}
} // namespace } // namespace
NetworkUI::NetworkUI(content::WebUI* web_ui) NetworkUI::NetworkUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) { : content::WebUIController(web_ui) {
web_ui->AddMessageHandler(new NetworkMessageHandler()); web_ui->AddMessageHandler(new NetworkConfigMessageHandler());
web_ui->AddMessageHandler(new NetworkUIMessageHandler());
content::WebUIDataSource* html = content::WebUIDataSource* html =
content::WebUIDataSource::Create(chrome::kChromeUINetworkHost); content::WebUIDataSource::Create(chrome::kChromeUINetworkHost);
...@@ -149,14 +75,14 @@ NetworkUI::NetworkUI(content::WebUI* web_ui) ...@@ -149,14 +75,14 @@ NetworkUI::NetworkUI(content::WebUI* web_ui)
html->AddLocalizedString("logLevelTimeDetailText", html->AddLocalizedString("logLevelTimeDetailText",
IDS_NETWORK_LOG_LEVEL_TIME_DETAIL); IDS_NETWORK_LOG_LEVEL_TIME_DETAIL);
html->AddLocalizedString("logEntryFormat", IDS_NETWORK_LOG_ENTRY); html->AddLocalizedString("logEntryFormat", IDS_NETWORK_LOG_ENTRY);
html->SetJsonPath(kStringsJsFile); html->SetJsonPath("strings.js");
html->AddResourcePath("network_config.js", IDR_NETWORK_CONFIG_JS);
html->AddResourcePath("network.css", IDR_NETWORK_CSS); html->AddResourcePath("network_ui.css", IDR_NETWORK_UI_CSS);
html->AddResourcePath("network.js", IDR_NETWORK_JS); html->AddResourcePath("network_ui.js", IDR_NETWORK_UI_JS);
html->SetDefaultResource(IDR_NETWORK_HTML); html->SetDefaultResource(IDR_NETWORK_UI_HTML);
Profile* profile = Profile::FromWebUI(web_ui); content::WebUIDataSource::Add(
content::WebUIDataSource::Add(profile, html); web_ui->GetWebContents()->GetBrowserContext(), html);
} }
NetworkUI::~NetworkUI() { NetworkUI::~NetworkUI() {
......
...@@ -2091,6 +2091,8 @@ ...@@ -2091,6 +2091,8 @@
'browser/ui/webui/chromeos/mobile_setup_ui.h', 'browser/ui/webui/chromeos/mobile_setup_ui.h',
'browser/ui/webui/chromeos/network_ui.cc', 'browser/ui/webui/chromeos/network_ui.cc',
'browser/ui/webui/chromeos/network_ui.h', 'browser/ui/webui/chromeos/network_ui.h',
'browser/ui/webui/chromeos/network_config_message_handler.cc',
'browser/ui/webui/chromeos/network_config_message_handler.h',
'browser/ui/webui/chromeos/nfc_debug_ui.cc', 'browser/ui/webui/chromeos/nfc_debug_ui.cc',
'browser/ui/webui/chromeos/nfc_debug_ui.h', 'browser/ui/webui/chromeos/nfc_debug_ui.h',
'browser/ui/webui/chromeos/power_ui.cc', 'browser/ui/webui/chromeos/power_ui.cc',
......
...@@ -209,6 +209,7 @@ void NetworkConfigurationHandler::GetProperties( ...@@ -209,6 +209,7 @@ void NetworkConfigurationHandler::GetProperties(
const std::string& service_path, const std::string& service_path,
const network_handler::DictionaryResultCallback& callback, const network_handler::DictionaryResultCallback& callback,
const network_handler::ErrorCallback& error_callback) const { const network_handler::ErrorCallback& error_callback) const {
NET_LOG_USER("GetProperties", service_path);
DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
dbus::ObjectPath(service_path), dbus::ObjectPath(service_path),
base::Bind(&GetPropertiesCallback, base::Bind(&GetPropertiesCallback,
......
...@@ -167,7 +167,8 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC( ...@@ -167,7 +167,8 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC(
NetworkTypePattern pattern, NetworkTypePattern pattern,
bool configured_only, bool configured_only,
bool visible_only, bool visible_only,
int limit) { int limit,
bool debugging_properties) {
NetworkStateHandler::FavoriteStateList favorite_states; NetworkStateHandler::FavoriteStateList favorite_states;
NetworkHandler::Get()->network_state_handler()->GetFavoriteListByType( NetworkHandler::Get()->network_state_handler()->GetFavoriteListByType(
pattern, configured_only, visible_only, limit, &favorite_states); pattern, configured_only, visible_only, limit, &favorite_states);
...@@ -179,6 +180,14 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC( ...@@ -179,6 +180,14 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC(
++it) { ++it) {
scoped_ptr<base::DictionaryValue> onc_dictionary = scoped_ptr<base::DictionaryValue> onc_dictionary =
TranslateFavoriteStateToONC(*it); TranslateFavoriteStateToONC(*it);
if (debugging_properties) {
onc_dictionary->SetString("profile_path", (*it)->profile_path());
std::string onc_source = (*it)->ui_data().GetONCSourceAsString();
if (!onc_source.empty())
onc_dictionary->SetString("onc_source", onc_source);
}
network_properties_list->Append(onc_dictionary.release()); network_properties_list->Append(onc_dictionary.release());
} }
return network_properties_list.Pass(); return network_properties_list.Pass();
......
...@@ -100,12 +100,14 @@ CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC( ...@@ -100,12 +100,14 @@ CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC(
// |configured_only|, and |visible_only| to NetworkStateHandler:: // |configured_only|, and |visible_only| to NetworkStateHandler::
// GetNetworkListByType(). Translates the result into a list of ONC // GetNetworkListByType(). Translates the result into a list of ONC
// dictionaries using TranslateShillServiceToONCPart. |limit| is used to limit // dictionaries using TranslateShillServiceToONCPart. |limit| is used to limit
// the number of results. // the number of results. If |debugging_properties| is true then also include
// additional debugging properties (used in release code for chrome://network).
CHROMEOS_EXPORT scoped_ptr<base::ListValue> TranslateNetworkListToONC( CHROMEOS_EXPORT scoped_ptr<base::ListValue> TranslateNetworkListToONC(
NetworkTypePattern pattern, NetworkTypePattern pattern,
bool configured_only, bool configured_only,
bool visible_only, bool visible_only,
int limit); int limit,
bool debugging_properties);
} // namespace network_util } // namespace network_util
} // namespace chromeos } // namespace chromeos
......
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