| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/mobile/mobile_activator.h" | 5 #include "chrome/browser/chromeos/mobile/mobile_activator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 base::AutoLock create(config_lock_); | 121 base::AutoLock create(config_lock_); |
| 122 error_map_.clear(); | 122 error_map_.clear(); |
| 123 error_map_.insert(map.begin(), map.end()); | 123 error_map_.insert(map.begin(), map.end()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool CellularConfigDocument::LoadFromFile(const base::FilePath& config_path) { | 126 bool CellularConfigDocument::LoadFromFile(const base::FilePath& config_path) { |
| 127 std::string config; | 127 std::string config; |
| 128 if (!base::ReadFileToString(config_path, &config)) | 128 if (!base::ReadFileToString(config_path, &config)) |
| 129 return false; | 129 return false; |
| 130 | 130 |
| 131 scoped_ptr<base::Value> root = | 131 std::unique_ptr<base::Value> root = |
| 132 base::JSONReader::Read(config, base::JSON_ALLOW_TRAILING_COMMAS); | 132 base::JSONReader::Read(config, base::JSON_ALLOW_TRAILING_COMMAS); |
| 133 DCHECK(root.get() != NULL); | 133 DCHECK(root.get() != NULL); |
| 134 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { | 134 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { |
| 135 LOG(WARNING) << "Bad cellular config file"; | 135 LOG(WARNING) << "Bad cellular config file"; |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 base::DictionaryValue* root_dict = | 139 base::DictionaryValue* root_dict = |
| 140 static_cast<base::DictionaryValue*>(root.get()); | 140 static_cast<base::DictionaryValue*>(root.get()); |
| 141 if (!root_dict->GetString(kVersionField, &version_)) { | 141 if (!root_dict->GetString(kVersionField, &version_)) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 NetworkHandler::Get()->network_configuration_handler()->SetShillProperties( | 317 NetworkHandler::Get()->network_configuration_handler()->SetShillProperties( |
| 318 service_path_, auto_connect_property, | 318 service_path_, auto_connect_property, |
| 319 // Activation is triggered by the UI. | 319 // Activation is triggered by the UI. |
| 320 NetworkConfigurationObserver::SOURCE_USER_ACTION, | 320 NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 321 base::Bind(&base::DoNothing), network_handler::ErrorCallback()); | 321 base::Bind(&base::DoNothing), network_handler::ErrorCallback()); |
| 322 StartActivation(); | 322 StartActivation(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void MobileActivator::GetPropertiesFailure( | 325 void MobileActivator::GetPropertiesFailure( |
| 326 const std::string& error_name, | 326 const std::string& error_name, |
| 327 scoped_ptr<base::DictionaryValue> error_data) { | 327 std::unique_ptr<base::DictionaryValue> error_data) { |
| 328 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name, | 328 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name, |
| 329 service_path_); | 329 service_path_); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void MobileActivator::OnSetTransactionStatus(bool success) { | 332 void MobileActivator::OnSetTransactionStatus(bool success) { |
| 333 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 333 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 334 base::Bind(&MobileActivator::HandleSetTransactionStatus, | 334 base::Bind(&MobileActivator::HandleSetTransactionStatus, |
| 335 AsWeakPtr(), success)); | 335 AsWeakPtr(), success)); |
| 336 } | 336 } |
| 337 | 337 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 bool MobileActivator::RunningActivation() const { | 921 bool MobileActivator::RunningActivation() const { |
| 922 return !(state_ == PLAN_ACTIVATION_DONE || | 922 return !(state_ == PLAN_ACTIVATION_DONE || |
| 923 state_ == PLAN_ACTIVATION_ERROR || | 923 state_ == PLAN_ACTIVATION_ERROR || |
| 924 state_ == PLAN_ACTIVATION_PAGE_LOADING); | 924 state_ == PLAN_ACTIVATION_PAGE_LOADING); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void MobileActivator::HandleActivationFailure( | 927 void MobileActivator::HandleActivationFailure( |
| 928 const std::string& service_path, | 928 const std::string& service_path, |
| 929 PlanActivationState new_state, | 929 PlanActivationState new_state, |
| 930 const std::string& error_name, | 930 const std::string& error_name, |
| 931 scoped_ptr<base::DictionaryValue> error_data) { | 931 std::unique_ptr<base::DictionaryValue> error_data) { |
| 932 pending_activation_request_ = false; | 932 pending_activation_request_ = false; |
| 933 const NetworkState* network = GetNetworkState(service_path); | 933 const NetworkState* network = GetNetworkState(service_path); |
| 934 if (!network) { | 934 if (!network) { |
| 935 NET_LOG_ERROR("Cellular service no longer exists", service_path); | 935 NET_LOG_ERROR("Cellular service no longer exists", service_path); |
| 936 return; | 936 return; |
| 937 } | 937 } |
| 938 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1); | 938 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1); |
| 939 NET_LOG_ERROR("Failed to call Activate() on service", service_path); | 939 NET_LOG_ERROR("Failed to call Activate() on service", service_path); |
| 940 if (new_state == PLAN_ACTIVATION_OTASP) { | 940 if (new_state == PLAN_ACTIVATION_OTASP) { |
| 941 ChangeState(network, PLAN_ACTIVATION_DELAY_OTASP, std::string()); | 941 ChangeState(network, PLAN_ACTIVATION_DELAY_OTASP, std::string()); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 cellular_plan_payment_time_ = base::Time::Now(); | 1162 cellular_plan_payment_time_ = base::Time::Now(); |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 bool MobileActivator::HasRecentCellularPlanPayment() const { | 1165 bool MobileActivator::HasRecentCellularPlanPayment() const { |
| 1166 const int kRecentPlanPaymentHours = 6; | 1166 const int kRecentPlanPaymentHours = 6; |
| 1167 return (base::Time::Now() - | 1167 return (base::Time::Now() - |
| 1168 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours; | 1168 cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours; |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 } // namespace chromeos | 1171 } // namespace chromeos |
| OLD | NEW |