diff options
author | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 03:35:17 +0000 |
---|---|---|
committer | dpolukhin@chromium.org <dpolukhin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-05 03:35:17 +0000 |
commit | fbc4e8b1bc3d8ee6f4c27ce43597d92c8c0bb92b (patch) | |
tree | 93621a98695e24354b8412b433da117c38c57340 | |
parent | 39e1c85f8e4b3a14d6826bed71f4b9b970753e29 (diff) | |
download | chromium_src-fbc4e8b1bc3d8ee6f4c27ce43597d92c8c0bb92b.zip chromium_src-fbc4e8b1bc3d8ee6f4c27ce43597d92c8c0bb92b.tar.gz chromium_src-fbc4e8b1bc3d8ee6f4c27ce43597d92c8c0bb92b.tar.bz2 |
Merge 84056 - GSM data roaming: connect UI and flimflam
BUG=chromium-os:12008
TEST=manual
Review URL: http://codereview.chromium.org/6929010
TBR=dpolukhin@chromium.org
Review URL: http://codereview.chromium.org/6931004
git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@84207 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 72 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h index 0f28a4b..a4e90c4 100644 --- a/chrome/browser/chromeos/cros/mock_network_library.h +++ b/chrome/browser/chromeos/cros/mock_network_library.h @@ -87,6 +87,7 @@ class MockNetworkLibrary : public NetworkLibrary { MOCK_METHOD0(RequestCellularScan, void()); MOCK_METHOD1(RequestCellularRegister, void(const std::string&)); + MOCK_METHOD1(SetCellularDataRoamingAllowed, void(bool)); MOCK_METHOD0(RequestNetworkScan, void(void)); MOCK_METHOD1(GetWifiAccessPoints, bool(WifiAccessPointVector*)); diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 351a7b5db..84c924c 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -14,9 +14,10 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/chromeos/network_login_observer.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/login/user_manager.h" +#include "chrome/browser/chromeos/network_login_observer.h" +#include "chrome/browser/chromeos/user_cros_settings_provider.h" #include "chrome/common/time_format.h" #include "content/browser/browser_thread.h" #include "grit/generated_resources.h" @@ -134,6 +135,7 @@ const char* kPaymentURLProperty = "Cellular.OlpUrl"; const char* kUsageURLProperty = "Cellular.UsageUrl"; const char* kCellularApnProperty = "Cellular.APN"; const char* kCellularLastGoodApnProperty = "Cellular.LastGoodAPN"; +const char* kCellularAllowRoamingProperty = "Cellular.AllowRoaming"; const char* kFavoriteProperty = "Favorite"; const char* kConnectableProperty = "Connectable"; const char* kAutoConnectProperty = "AutoConnect"; @@ -412,6 +414,7 @@ enum PropertyIndex { PROPERTY_INDEX_AUTO_CONNECT, PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES, PROPERTY_INDEX_CARRIER, + PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING, PROPERTY_INDEX_CELLULAR_APN, PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN, PROPERTY_INDEX_CERT_PATH, @@ -495,6 +498,7 @@ StringToEnum<PropertyIndex>::Pair property_index_table[] = { { kActiveProfileProperty, PROPERTY_INDEX_ACTIVE_PROFILE }, { kAutoConnectProperty, PROPERTY_INDEX_AUTO_CONNECT }, { kAvailableTechnologiesProperty, PROPERTY_INDEX_AVAILABLE_TECHNOLOGIES }, + { kCellularAllowRoamingProperty, PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING }, { kCellularApnProperty, PROPERTY_INDEX_CELLULAR_APN }, { kCellularLastGoodApnProperty, PROPERTY_INDEX_CELLULAR_LAST_GOOD_APN }, { kCarrierProperty, PROPERTY_INDEX_CARRIER }, @@ -845,7 +849,8 @@ NetworkDevice::NetworkDevice(const std::string& device_path) sim_lock_state_(SIM_UNKNOWN), sim_retries_left_(kDefaultSimUnlockRetriesCount), sim_pin_required_(SIM_PIN_REQUIRE_UNKNOWN), - PRL_version_(0) { + PRL_version_(0), + data_roaming_allowed_(false) { } bool NetworkDevice::ParseValue(int index, const Value* value) { @@ -918,6 +923,8 @@ bool NetworkDevice::ParseValue(int index, const Value* value) { return value->GetAsInteger(&PRL_version_); case PROPERTY_INDEX_SELECTED_NETWORK: return value->GetAsString(&selected_cellular_network_); + case PROPERTY_INDEX_CELLULAR_ALLOW_ROAMING: + return value->GetAsBoolean(&data_roaming_allowed_); default: break; } @@ -2415,6 +2422,19 @@ class NetworkLibraryImpl : public NetworkLibrary { // but not UI doesn't assume such notification so just ignore result. } + virtual void SetCellularDataRoamingAllowed(bool new_value) { + const NetworkDevice* cellular = FindCellularDevice(); + if (!cellular) { + NOTREACHED() << "Calling SetCellularDataRoamingAllowed method " + "w/o cellular device."; + return; + } + scoped_ptr<Value> value(Value::CreateBooleanValue(new_value)); + chromeos::SetNetworkDeviceProperty(cellular->device_path().c_str(), + kCellularAllowRoamingProperty, + value.get()); + } + ///////////////////////////////////////////////////////////////////////////// virtual void RequestNetworkScan() { @@ -3738,6 +3758,14 @@ class NetworkLibraryImpl : public NetworkLibrary { if (!device->ParseValue(index, value)) { LOG(WARNING) << "UpdateNetworkDeviceStatus: Error parsing: " << path << "." << key; + } else if (strcmp(key, kCellularAllowRoamingProperty) == 0) { + bool settings_value = + UserCrosSettingsProvider::cached_data_roaming_enabled(); + if (device->data_roaming_allowed() != settings_value) { + // Switch back to signed settings value. + SetCellularDataRoamingAllowed(settings_value); + return; + } } // Notify only observers on device property change. NotifyNetworkDeviceChanged(device); @@ -4218,6 +4246,7 @@ class NetworkLibraryStubImpl : public NetworkLibrary { virtual void UnblockPin(const std::string& puk, const std::string& new_pin) {} virtual void RequestCellularScan() {} virtual void RequestCellularRegister(const std::string& network_id) {} + virtual void SetCellularDataRoamingAllowed(bool new_value) {} virtual void RequestNetworkScan() {} virtual bool GetWifiAccessPoints(WifiAccessPointVector* result) { diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index ee471dc..9b9bdc1 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -219,6 +219,7 @@ class NetworkDevice { const CellularNetworkList& found_cellular_networks() const { return found_cellular_networks_; } + bool data_roaming_allowed() const { return data_roaming_allowed_; } private: bool ParseValue(int index, const Value* value); @@ -249,6 +250,7 @@ class NetworkDevice { int PRL_version_; std::string selected_cellular_network_; CellularNetworkList found_cellular_networks_; + bool data_roaming_allowed_; friend class NetworkLibraryImpl; DISALLOW_COPY_AND_ASSIGN(NetworkDevice); @@ -1049,6 +1051,9 @@ class NetworkLibrary { // Request a register in cellular network with |network_id|. virtual void RequestCellularRegister(const std::string& network_id) = 0; + // Change data roaming restriction for current cellular device. + virtual void SetCellularDataRoamingAllowed(bool new_value) = 0; + // Request a scan for new wifi networks. virtual void RequestNetworkScan() = 0; diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc index d0b9a4e..8286428 100644 --- a/chrome/browser/chromeos/user_cros_settings_provider.cc +++ b/chrome/browser/chromeos/user_cros_settings_provider.cc @@ -16,6 +16,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/login_library.h" +#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros_settings.h" #include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/browser/chromeos/login/ownership_service.h" @@ -220,6 +221,7 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { if (IsControlledBooleanSetting(path)) { bool bool_value = false; if (in_value->GetAsBoolean(&bool_value)) { + OnBooleanPropertyChange(path, bool_value); std::string value = bool_value ? kTrueIncantation : kFalseIncantation; SignedSettingsHelper::Get()->StartStorePropertyOp(path, value, this); UpdateCacheBool(path, bool_value, USE_VALUE_SUPPLIED); @@ -256,6 +258,36 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { } } + // Called right before boolean property is changed. + void OnBooleanPropertyChange(const std::string& path, bool new_value) { + if (path == kSignedDataRoamingEnabled) { + if (!CrosLibrary::Get()->EnsureLoaded()) + return; + + NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); + cros->SetCellularDataRoamingAllowed(new_value); + } + } + + // Called right after signed value was checked. + void OnBooleanPropertyRetrieve(const std::string& path, + bool value, + UseValue use_value) { + if (path == kSignedDataRoamingEnabled) { + if (!CrosLibrary::Get()->EnsureLoaded()) + return; + + NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); + const NetworkDevice* cellular = cros->FindCellularDevice(); + if (cellular) { + bool device_value = cellular->data_roaming_allowed(); + bool new_value = (use_value == USE_VALUE_SUPPLIED) ? value : false; + if (device_value != new_value) + cros->SetCellularDataRoamingAllowed(new_value); + } + } + } + void StartFetchingSetting(const std::string& name) { DCHECK(g_browser_process); PrefService* prefs = g_browser_process->local_state(); @@ -293,6 +325,8 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { else VLOG(1) << "Retrieved cros setting " << name << "=" << value; if (IsControlledBooleanSetting(name)) { + OnBooleanPropertyRetrieve(name, (value == kTrueIncantation), + fallback_to_default ? USE_VALUE_DEFAULT : USE_VALUE_SUPPLIED); UpdateCacheBool(name, (value == kTrueIncantation), fallback_to_default ? USE_VALUE_DEFAULT : USE_VALUE_SUPPLIED); } else if (IsControlledStringSetting(name)) { @@ -316,6 +350,7 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { if (IsControlledBooleanSetting(name)) { // For boolean settings we can just set safe (false) values // and continue as trusted. + OnBooleanPropertyRetrieve(name, false, USE_VALUE_SUPPLIED); UpdateCacheBool(name, false, USE_VALUE_SUPPLIED); } else { prefs->ClearPref((name + kTrustedSuffix).c_str()); |