Index: chrome/browser/chromeos/cros/network_library.cc |
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc |
index 98568d1611a22471bf29f8c2f34f3633045866cf..5137f639e3cde92bdb5b07fc101439cfdbab8ac7 100644 |
--- a/chrome/browser/chromeos/cros/network_library.cc |
+++ b/chrome/browser/chromeos/cros/network_library.cc |
@@ -21,13 +21,11 @@ |
#include "chrome/browser/chromeos/cros/network_library_impl_cros.h" |
#include "chrome/browser/chromeos/cros/network_library_impl_stub.h" |
#include "chrome/browser/net/browser_url_util.h" |
-#include "chrome/common/time_format.h" |
#include "chrome/common/net/x509_certificate_model.h" |
#include "content/public/browser/browser_thread.h" |
#include "grit/generated_resources.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
#include "ui/base/l10n/l10n_util.h" |
-#include "ui/base/text/bytes_formatting.h" |
using content::BrowserThread; |
@@ -747,145 +745,6 @@ void VirtualNetwork::MatchCertificatePattern(bool allow_enroll, |
// WirelessNetwork |
//////////////////////////////////////////////////////////////////////////////// |
-// CellularDataPlan |
- |
-CellularDataPlan::CellularDataPlan() |
- : plan_name("Unknown"), |
- plan_type(CELLULAR_DATA_PLAN_UNLIMITED), |
- plan_data_bytes(0), |
- data_bytes_used(0) { |
-} |
- |
-CellularDataPlan::CellularDataPlan(const CellularDataPlanInfo &plan) |
- : plan_name(plan.plan_name ? plan.plan_name : ""), |
- plan_type(plan.plan_type), |
- update_time(base::Time::FromInternalValue(plan.update_time)), |
- plan_start_time(base::Time::FromInternalValue(plan.plan_start_time)), |
- plan_end_time(base::Time::FromInternalValue(plan.plan_end_time)), |
- plan_data_bytes(plan.plan_data_bytes), |
- data_bytes_used(plan.data_bytes_used) { |
-} |
- |
-CellularDataPlan::~CellularDataPlan() {} |
- |
-string16 CellularDataPlan::GetPlanDesciption() const { |
- switch (plan_type) { |
- case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { |
- return l10n_util::GetStringFUTF16( |
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_UNLIMITED_DATA, |
- base::TimeFormatFriendlyDate(plan_start_time)); |
- break; |
- } |
- case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { |
- return l10n_util::GetStringFUTF16( |
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_DATA, |
- ui::FormatBytes(plan_data_bytes), |
- base::TimeFormatFriendlyDate(plan_start_time)); |
- } |
- case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { |
- return l10n_util::GetStringFUTF16( |
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_RECEIVED_FREE_DATA, |
- ui::FormatBytes(plan_data_bytes), |
- base::TimeFormatFriendlyDate(plan_start_time)); |
- default: |
- break; |
- } |
- } |
- return string16(); |
-} |
- |
-string16 CellularDataPlan::GetRemainingWarning() const { |
- if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { |
- // Time based plan. Show nearing expiration and data expiration. |
- if (remaining_time().InSeconds() <= chromeos::kCellularDataVeryLowSecs) { |
- return GetPlanExpiration(); |
- } |
- } else if (plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_PAID || |
- plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_BASE) { |
- // Metered plan. Show low data and out of data. |
- if (remaining_data() <= chromeos::kCellularDataVeryLowBytes) { |
- int64 remaining_mbytes = remaining_data() / (1024 * 1024); |
- return l10n_util::GetStringFUTF16( |
- IDS_NETWORK_DATA_REMAINING_MESSAGE, |
- UTF8ToUTF16(base::Int64ToString(remaining_mbytes))); |
- } |
- } |
- return string16(); |
-} |
- |
-string16 CellularDataPlan::GetDataRemainingDesciption() const { |
- int64 remaining_bytes = remaining_data(); |
- switch (plan_type) { |
- case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { |
- return l10n_util::GetStringUTF16( |
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNLIMITED); |
- } |
- case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { |
- return ui::FormatBytes(remaining_bytes); |
- } |
- case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { |
- return ui::FormatBytes(remaining_bytes); |
- } |
- default: |
- break; |
- } |
- return string16(); |
-} |
- |
-string16 CellularDataPlan::GetUsageInfo() const { |
- if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { |
- // Time based plan. Show nearing expiration and data expiration. |
- return GetPlanExpiration(); |
- } else if (plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_PAID || |
- plan_type == chromeos::CELLULAR_DATA_PLAN_METERED_BASE) { |
- // Metered plan. Show low data and out of data. |
- int64 remaining_bytes = remaining_data(); |
- if (remaining_bytes == 0) { |
- return l10n_util::GetStringUTF16( |
- IDS_NETWORK_DATA_NONE_AVAILABLE_MESSAGE); |
- } else if (remaining_bytes < 1024 * 1024) { |
- return l10n_util::GetStringUTF16( |
- IDS_NETWORK_DATA_LESS_THAN_ONE_MB_AVAILABLE_MESSAGE); |
- } else { |
- int64 remaining_mb = remaining_bytes / (1024 * 1024); |
- return l10n_util::GetStringFUTF16( |
- IDS_NETWORK_DATA_MB_AVAILABLE_MESSAGE, |
- UTF8ToUTF16(base::Int64ToString(remaining_mb))); |
- } |
- } |
- return string16(); |
-} |
- |
-std::string CellularDataPlan::GetUniqueIdentifier() const { |
- // A cellular plan is uniquely described by the union of name, type, |
- // start time, end time, and max bytes. |
- // So we just return a union of all these variables. |
- return plan_name + "|" + |
- base::Int64ToString(plan_type) + "|" + |
- base::Int64ToString(plan_start_time.ToInternalValue()) + "|" + |
- base::Int64ToString(plan_end_time.ToInternalValue()) + "|" + |
- base::Int64ToString(plan_data_bytes); |
-} |
- |
-base::TimeDelta CellularDataPlan::remaining_time() const { |
- base::TimeDelta time = plan_end_time - base::Time::Now(); |
- return time.InMicroseconds() < 0 ? base::TimeDelta() : time; |
-} |
- |
-int64 CellularDataPlan::remaining_minutes() const { |
- return remaining_time().InMinutes(); |
-} |
- |
-int64 CellularDataPlan::remaining_data() const { |
- int64 data = plan_data_bytes - data_bytes_used; |
- return data < 0 ? 0 : data; |
-} |
- |
-string16 CellularDataPlan::GetPlanExpiration() const { |
- return TimeFormat::TimeRemaining(remaining_time()); |
-} |
- |
-//////////////////////////////////////////////////////////////////////////////// |
// CellTower |
CellTower::CellTower() {} |