Commit 2b488d2c authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Remove additional dependencies from InternetOptionsHandler

Removes UIData from NetworkState.

BUG=279351

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282821 0039d316-1c4b-4281-b951-d872f2087c98
parent c8329ff4
...@@ -91,16 +91,6 @@ cr.define('options.network', function() { ...@@ -91,16 +91,6 @@ cr.define('options.network', function() {
*/ */
var defaultIcons_ = {}; var defaultIcons_ = {};
/**
* Contains the current logged in user type, which is one of 'none',
* 'regular', 'owner', 'guest', 'retail-mode', 'public-account',
* 'locally-managed', and 'kiosk-app', or empty string if the data has not
* been set.
* @type {string}
* @private
*/
var loggedInUserType_ = '';
/** /**
* Returns the display name for 'network'. * Returns the display name for 'network'.
* @param {Object} data The network data dictionary. * @param {Object} data The network data dictionary.
...@@ -465,7 +455,7 @@ cr.define('options.network', function() { ...@@ -465,7 +455,7 @@ cr.define('options.network', function() {
var label = enableDataRoaming_ ? 'disableDataRoaming' : var label = enableDataRoaming_ ? 'disableDataRoaming' :
'enableDataRoaming'; 'enableDataRoaming';
var disabled = loggedInUserType_ != 'owner'; var disabled = !loadTimeData.getValue('loggedInAsOwner');
var entry = {label: loadTimeData.getString(label), var entry = {label: loadTimeData.getString(label),
data: {}}; data: {}};
if (disabled) { if (disabled) {
...@@ -941,14 +931,6 @@ cr.define('options.network', function() { ...@@ -941,14 +931,6 @@ cr.define('options.network', function() {
defaultIcons_ = Object.create(data); defaultIcons_ = Object.create(data);
}; };
/**
* Sets the current logged in user type.
* @param {string} userType Current logged in user type.
*/
NetworkList.updateLoggedInUserType = function(userType) {
loggedInUserType_ = String(userType);
};
/** /**
* Chrome callback for updating network controls. * Chrome callback for updating network controls.
* @param {Object} data Description of available network devices and their * @param {Object} data Description of available network devices and their
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -44,7 +43,6 @@ ...@@ -44,7 +43,6 @@
#include "chromeos/network/network_profile_handler.h" #include "chromeos/network/network_profile_handler.h"
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_ui_data.h"
#include "chromeos/network/network_util.h" #include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_signature.h" #include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_translator.h" #include "chromeos/network/onc/onc_translator.h"
...@@ -103,8 +101,6 @@ const char kUpdateConnectionDataFunction[] = ...@@ -103,8 +101,6 @@ const char kUpdateConnectionDataFunction[] =
"options.internet.DetailsInternetPage.updateConnectionData"; "options.internet.DetailsInternetPage.updateConnectionData";
const char kUpdateCarrierFunction[] = const char kUpdateCarrierFunction[] =
"options.internet.DetailsInternetPage.updateCarrier"; "options.internet.DetailsInternetPage.updateCarrier";
const char kUpdateLoggedInUserTypeFunction[] =
"options.network.NetworkList.updateLoggedInUserType";
const char kUpdateSecurityTabFunction[] = const char kUpdateSecurityTabFunction[] =
"options.internet.DetailsInternetPage.updateSecurityTab"; "options.internet.DetailsInternetPage.updateSecurityTab";
...@@ -185,14 +181,6 @@ const char kTagWimaxAvailable[] = "wimaxAvailable"; ...@@ -185,14 +181,6 @@ const char kTagWimaxAvailable[] = "wimaxAvailable";
const char kTagWimaxEnabled[] = "wimaxEnabled"; const char kTagWimaxEnabled[] = "wimaxEnabled";
const char kTagWiredList[] = "wiredList"; const char kTagWiredList[] = "wiredList";
const char kTagWirelessList[] = "wirelessList"; const char kTagWirelessList[] = "wirelessList";
const char kTagLoggedInUserNone[] = "none";
const char kTagLoggedInUserRegular[] = "regular";
const char kTagLoggedInUserOwner[] = "owner";
const char kTagLoggedInUserGuest[] = "guest";
const char kTagLoggedInUserRetailMode[] = "retail-mode";
const char kTagLoggedInUserPublicAccount[] = "public-account";
const char kTagLoggedInUserLocallyManaged[] = "locally-managed";
const char kTagLoggedInUserKioskApp[] = "kiosk-app";
const int kPreferredPriority = 1; const int kPreferredPriority = 1;
...@@ -225,29 +213,6 @@ void SetNetworkProperty(const std::string& service_path, ...@@ -225,29 +213,6 @@ void SetNetworkProperty(const std::string& service_path,
base::Bind(&ShillError, "SetNetworkProperty")); base::Bind(&ShillError, "SetNetworkProperty"));
} }
std::string LoggedInUserTypeToJSString(LoginState::LoggedInUserType type) {
switch (type) {
case LoginState::LOGGED_IN_USER_NONE:
return kTagLoggedInUserNone;
case LoginState::LOGGED_IN_USER_REGULAR:
return kTagLoggedInUserRegular;
case LoginState::LOGGED_IN_USER_OWNER:
return kTagLoggedInUserOwner;
case LoginState::LOGGED_IN_USER_GUEST:
return kTagLoggedInUserGuest;
case LoginState::LOGGED_IN_USER_RETAIL_MODE:
return kTagLoggedInUserRetailMode;
case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
return kTagLoggedInUserPublicAccount;
case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
return kTagLoggedInUserLocallyManaged;
case LoginState::LOGGED_IN_USER_KIOSK_APP:
return kTagLoggedInUserKioskApp;
}
NOTREACHED();
return std::string();
}
// Builds a dictionary with network information and an icon used for the // Builds a dictionary with network information and an icon used for the
// NetworkList on the settings page. Ownership of the returned pointer is // NetworkList on the settings page. Ownership of the returned pointer is
// transferred to the caller. // transferred to the caller.
...@@ -541,8 +506,11 @@ void PopulateCellularDetails(const NetworkState* cellular, ...@@ -541,8 +506,11 @@ void PopulateCellularDetails(const NetworkState* cellular,
cellular->device_path()); cellular->device_path());
if (device) { if (device) {
const base::DictionaryValue& device_properties = device->properties(); const base::DictionaryValue& device_properties = device->properties();
const NetworkPropertyUIData cellular_property_ui_data( ::onc::ONCSource onc_source;
cellular->ui_data().onc_source()); NetworkHandler::Get()->managed_network_configuration_handler()->
FindPolicyByGUID(LoginState::Get()->primary_user_hash(),
cellular->guid(), &onc_source);
const NetworkPropertyUIData cellular_property_ui_data(onc_source);
SetValueDictionary(dictionary, SetValueDictionary(dictionary,
kTagSimCardLockEnabled, kTagSimCardLockEnabled,
new base::FundamentalValue(device->sim_lock_enabled()), new base::FundamentalValue(device->sim_lock_enabled()),
...@@ -577,20 +545,17 @@ void PopulateCellularDetails(const NetworkState* cellular, ...@@ -577,20 +545,17 @@ void PopulateCellularDetails(const NetworkState* cellular,
kTagProviderApnList, kTagProviderApnList,
apn_list_value, apn_list_value,
cellular_property_ui_data); cellular_property_ui_data);
if (CommandLine::ForCurrentProcess()->HasSwitch( const base::ListValue* supported_carriers;
chromeos::switches::kEnableCarrierSwitching)) { if (device_properties.GetListWithoutPathExpansion(
const base::ListValue* supported_carriers; shill::kSupportedCarriersProperty, &supported_carriers)) {
if (device_properties.GetListWithoutPathExpansion( dictionary->Set(kTagCarriers, supported_carriers->DeepCopy());
shill::kSupportedCarriersProperty, &supported_carriers)) { dictionary->SetInteger(
dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); kTagCurrentCarrierIndex,
dictionary->SetInteger( FindCurrentCarrierIndex(supported_carriers, device));
kTagCurrentCarrierIndex, } else {
FindCurrentCarrierIndex(supported_carriers, device)); // In case of any error, set the current carrier tag to -1 indicating
} else { // to the JS code to fallback to a single carrier.
// In case of any error, set the current carrier tag to -1 indicating dictionary->SetInteger(kTagCurrentCarrierIndex, -1);
// to the JS code to fallback to a single carrier.
dictionary->SetInteger(kTagCurrentCarrierIndex, -1);
}
} }
} }
...@@ -747,7 +712,6 @@ InternetOptionsHandler::InternetOptionsHandler() ...@@ -747,7 +712,6 @@ InternetOptionsHandler::InternetOptionsHandler()
registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
LoginState::Get()->AddObserver(this);
} }
InternetOptionsHandler::~InternetOptionsHandler() { InternetOptionsHandler::~InternetOptionsHandler() {
...@@ -755,8 +719,6 @@ InternetOptionsHandler::~InternetOptionsHandler() { ...@@ -755,8 +719,6 @@ InternetOptionsHandler::~InternetOptionsHandler() {
NetworkHandler::Get()->network_state_handler()->RemoveObserver( NetworkHandler::Get()->network_state_handler()->RemoveObserver(
this, FROM_HERE); this, FROM_HERE);
} }
if (LoginState::Get()->IsInitialized())
LoginState::Get()->RemoveObserver(this);
} }
void InternetOptionsHandler::GetLocalizedValues( void InternetOptionsHandler::GetLocalizedValues(
...@@ -764,9 +726,14 @@ void InternetOptionsHandler::GetLocalizedValues( ...@@ -764,9 +726,14 @@ void InternetOptionsHandler::GetLocalizedValues(
DCHECK(localized_strings); DCHECK(localized_strings);
internet_options_strings::RegisterLocalizedStrings(localized_strings); internet_options_strings::RegisterLocalizedStrings(localized_strings);
// TODO(stevenjb): Find a better way to populate initial data before
// InitializePage() gets called.
std::string owner; std::string owner;
chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
localized_strings->SetString("ownerUserId", base::UTF8ToUTF16(owner)); localized_strings->SetString("ownerUserId", base::UTF8ToUTF16(owner));
bool logged_in_as_owner = LoginState::Get()->GetLoggedInUserType() ==
LoginState::LOGGED_IN_USER_OWNER;
localized_strings->SetBoolean("loggedInAsOwner", logged_in_as_owner);
base::DictionaryValue* network_dictionary = new base::DictionaryValue; base::DictionaryValue* network_dictionary = new base::DictionaryValue;
FillNetworkInfo(network_dictionary); FillNetworkInfo(network_dictionary);
...@@ -785,7 +752,6 @@ void InternetOptionsHandler::InitializePage() { ...@@ -785,7 +752,6 @@ void InternetOptionsHandler::InitializePage() {
dictionary); dictionary);
NetworkHandler::Get()->network_state_handler()->RequestScan(); NetworkHandler::Get()->network_state_handler()->RequestScan();
RefreshNetworkData(); RefreshNetworkData();
UpdateLoggedInUserType();
} }
void InternetOptionsHandler::RegisterMessages() { void InternetOptionsHandler::RegisterMessages() {
...@@ -1124,18 +1090,6 @@ void InternetOptionsHandler::NetworkPropertiesUpdated( ...@@ -1124,18 +1090,6 @@ void InternetOptionsHandler::NetworkPropertiesUpdated(
UpdateConnectionData(network->path()); UpdateConnectionData(network->path());
} }
void InternetOptionsHandler::LoggedInStateChanged() {
UpdateLoggedInUserType();
}
void InternetOptionsHandler::UpdateLoggedInUserType() {
if (!web_ui())
return;
base::StringValue login_type(
LoggedInUserTypeToJSString(LoginState::Get()->GetLoggedInUserType()));
web_ui()->CallJavascriptFunction(kUpdateLoggedInUserTypeFunction, login_type);
}
void InternetOptionsHandler::Observe( void InternetOptionsHandler::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/options/options_ui.h" #include "chrome/browser/ui/webui/options/options_ui.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/network_state_handler_observer.h" #include "chromeos/network/network_state_handler_observer.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
...@@ -40,7 +39,6 @@ namespace options { ...@@ -40,7 +39,6 @@ namespace options {
class InternetOptionsHandler class InternetOptionsHandler
: public ::options::OptionsPageUIHandler, : public ::options::OptionsPageUIHandler,
public chromeos::NetworkStateHandlerObserver, public chromeos::NetworkStateHandlerObserver,
public chromeos::LoginState::Observer,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
InternetOptionsHandler(); InternetOptionsHandler();
...@@ -97,9 +95,6 @@ class InternetOptionsHandler ...@@ -97,9 +95,6 @@ class InternetOptionsHandler
virtual void NetworkPropertiesUpdated( virtual void NetworkPropertiesUpdated(
const chromeos::NetworkState* network) OVERRIDE; const chromeos::NetworkState* network) OVERRIDE;
// chromeos::LoginState::Observer
virtual void LoggedInStateChanged() OVERRIDE;
// Updates the logged in user type. // Updates the logged in user type.
void UpdateLoggedInUserType(); void UpdateLoggedInUserType();
......
...@@ -102,15 +102,6 @@ bool NetworkState::PropertyChanged(const std::string& key, ...@@ -102,15 +102,6 @@ bool NetworkState::PropertyChanged(const std::string& key,
return GetStringValue(key, value, &security_); return GetStringValue(key, value, &security_);
} else if (key == shill::kEapMethodProperty) { } else if (key == shill::kEapMethodProperty) {
return GetStringValue(key, value, &eap_method_); return GetStringValue(key, value, &eap_method_);
} else if (key == shill::kUIDataProperty) {
scoped_ptr<NetworkUIData> new_ui_data =
shill_property_util::GetUIDataFromValue(value);
if (!new_ui_data) {
NET_LOG_ERROR("Failed to parse " + key, path());
return false;
}
ui_data_ = *new_ui_data;
return true;
} else if (key == shill::kNetworkTechnologyProperty) { } else if (key == shill::kNetworkTechnologyProperty) {
return GetStringValue(key, value, &network_technology_); return GetStringValue(key, value, &network_technology_);
} else if (key == shill::kDeviceProperty) { } else if (key == shill::kDeviceProperty) {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/values.h" #include "base/values.h"
#include "chromeos/network/managed_state.h" #include "chromeos/network/managed_state.h"
#include "chromeos/network/network_ui_data.h"
#include "components/onc/onc_constants.h" #include "components/onc/onc_constants.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -63,7 +62,6 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState { ...@@ -63,7 +62,6 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// Returns |connection_state_| if visible, kStateDisconnect otherwise. // Returns |connection_state_| if visible, kStateDisconnect otherwise.
std::string connection_state() const; std::string connection_state() const;
const NetworkUIData& ui_data() const { return ui_data_; }
const base::DictionaryValue& proxy_config() const { return proxy_config_; } const base::DictionaryValue& proxy_config() const { return proxy_config_; }
// IPConfig Properties. These require an extra call to ShillIPConfigClient, // IPConfig Properties. These require an extra call to ShillIPConfigClient,
...@@ -156,10 +154,6 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState { ...@@ -156,10 +154,6 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// when a connection attempt is initiated. // when a connection attempt is initiated.
std::string last_error_; std::string last_error_;
// This is convenient to keep cached for now, but shouldn't be necessary;
// avoid using it if possible.
NetworkUIData ui_data_;
// IPConfig properties. // IPConfig properties.
// Note: These do not correspond to actual Shill.Service properties // Note: These do not correspond to actual Shill.Service properties
// but are derived from the service's corresponding IPConfig object. // but are derived from the service's corresponding IPConfig object.
......
...@@ -175,9 +175,6 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC( ...@@ -175,9 +175,6 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC(
onc_dictionary->SetBoolean("visible", (*it)->visible()); onc_dictionary->SetBoolean("visible", (*it)->visible());
onc_dictionary->SetString("profile_path", (*it)->profile_path()); onc_dictionary->SetString("profile_path", (*it)->profile_path());
onc_dictionary->SetString("service_path", (*it)->path()); onc_dictionary->SetString("service_path", (*it)->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());
......
...@@ -93,6 +93,7 @@ CHROMEOS_EXPORT bool ParseCellularScanResults( ...@@ -93,6 +93,7 @@ CHROMEOS_EXPORT bool ParseCellularScanResults(
// Retrieves the ONC state dictionary for |network| using GetStateProperties. // Retrieves the ONC state dictionary for |network| using GetStateProperties.
// This includes properties from the corresponding NetworkState if it exists. // This includes properties from the corresponding NetworkState if it exists.
// Assumed to be called from the primary user profile.
CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC( CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
const NetworkState* network); const NetworkState* network);
......
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