OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/i18n/icu_encoding_detection.h" | 10 #include "base/i18n/icu_encoding_detection.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "chrome/browser/chromeos/cros/cros_library.h" | 22 #include "chrome/browser/chromeos/cros/cros_library.h" |
23 #include "chrome/browser/chromeos/login/user_manager.h" | 23 #include "chrome/browser/chromeos/login/user_manager.h" |
24 #include "chrome/browser/chromeos/network_login_observer.h" | 24 #include "chrome/browser/chromeos/network_login_observer.h" |
25 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 25 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
26 #include "chrome/common/time_format.h" | 26 #include "chrome/common/time_format.h" |
27 #include "content/browser/browser_thread.h" | 27 #include "content/browser/browser_thread.h" |
28 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. | 28 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/text/bytes_formatting.h" |
31 | 32 |
32 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
33 // Implementation notes. | 34 // Implementation notes. |
34 // NetworkLibraryImpl manages a series of classes that describe network devices | 35 // NetworkLibraryImpl manages a series of classes that describe network devices |
35 // and services: | 36 // and services: |
36 // | 37 // |
37 // NetworkDevice: e.g. ethernet, wifi modem, cellular modem | 38 // NetworkDevice: e.g. ethernet, wifi modem, cellular modem |
38 // device_map_: canonical map<path,NetworkDevice*> for devices | 39 // device_map_: canonical map<path,NetworkDevice*> for devices |
39 // | 40 // |
40 // Network: a network service ("network"). | 41 // Network: a network service ("network"). |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 switch (plan_type) { | 1524 switch (plan_type) { |
1524 case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { | 1525 case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { |
1525 return l10n_util::GetStringFUTF16( | 1526 return l10n_util::GetStringFUTF16( |
1526 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_UNLIMITED_DATA, | 1527 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_UNLIMITED_DATA, |
1527 base::TimeFormatFriendlyDate(plan_start_time)); | 1528 base::TimeFormatFriendlyDate(plan_start_time)); |
1528 break; | 1529 break; |
1529 } | 1530 } |
1530 case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { | 1531 case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { |
1531 return l10n_util::GetStringFUTF16( | 1532 return l10n_util::GetStringFUTF16( |
1532 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_DATA, | 1533 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_DATA, |
1533 FormatBytes(plan_data_bytes, | 1534 ui::FormatBytes(plan_data_bytes), |
1534 GetByteDisplayUnits(plan_data_bytes), | |
1535 true), | |
1536 base::TimeFormatFriendlyDate(plan_start_time)); | 1535 base::TimeFormatFriendlyDate(plan_start_time)); |
1537 } | 1536 } |
1538 case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { | 1537 case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { |
1539 return l10n_util::GetStringFUTF16( | 1538 return l10n_util::GetStringFUTF16( |
1540 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_RECEIVED_FREE_DATA, | 1539 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_RECEIVED_FREE_DATA, |
1541 FormatBytes(plan_data_bytes, | 1540 ui::FormatBytes(plan_data_bytes), |
1542 GetByteDisplayUnits(plan_data_bytes), | |
1543 true), | |
1544 base::TimeFormatFriendlyDate(plan_start_time)); | 1541 base::TimeFormatFriendlyDate(plan_start_time)); |
1545 default: | 1542 default: |
1546 break; | 1543 break; |
1547 } | 1544 } |
1548 } | 1545 } |
1549 return string16(); | 1546 return string16(); |
1550 } | 1547 } |
1551 | 1548 |
1552 string16 CellularDataPlan::GetRemainingWarning() const { | 1549 string16 CellularDataPlan::GetRemainingWarning() const { |
1553 if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { | 1550 if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { |
(...skipping 15 matching lines...) Expand all Loading... |
1569 } | 1566 } |
1570 | 1567 |
1571 string16 CellularDataPlan::GetDataRemainingDesciption() const { | 1568 string16 CellularDataPlan::GetDataRemainingDesciption() const { |
1572 int64 remaining_bytes = remaining_data(); | 1569 int64 remaining_bytes = remaining_data(); |
1573 switch (plan_type) { | 1570 switch (plan_type) { |
1574 case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { | 1571 case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: { |
1575 return l10n_util::GetStringUTF16( | 1572 return l10n_util::GetStringUTF16( |
1576 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNLIMITED); | 1573 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNLIMITED); |
1577 } | 1574 } |
1578 case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { | 1575 case chromeos::CELLULAR_DATA_PLAN_METERED_PAID: { |
1579 return FormatBytes(remaining_bytes, | 1576 return ui::FormatBytes(remaining_bytes); |
1580 GetByteDisplayUnits(remaining_bytes), | |
1581 true); | |
1582 } | 1577 } |
1583 case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { | 1578 case chromeos::CELLULAR_DATA_PLAN_METERED_BASE: { |
1584 return FormatBytes(remaining_bytes, | 1579 return ui::FormatBytes(remaining_bytes); |
1585 GetByteDisplayUnits(remaining_bytes), | |
1586 true); | |
1587 } | 1580 } |
1588 default: | 1581 default: |
1589 break; | 1582 break; |
1590 } | 1583 } |
1591 return string16(); | 1584 return string16(); |
1592 } | 1585 } |
1593 | 1586 |
1594 string16 CellularDataPlan::GetUsageInfo() const { | 1587 string16 CellularDataPlan::GetUsageInfo() const { |
1595 if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { | 1588 if (plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) { |
1596 // Time based plan. Show nearing expiration and data expiration. | 1589 // Time based plan. Show nearing expiration and data expiration. |
(...skipping 3473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5070 return new NetworkLibraryStubImpl(); | 5063 return new NetworkLibraryStubImpl(); |
5071 else | 5064 else |
5072 return new NetworkLibraryImpl(); | 5065 return new NetworkLibraryImpl(); |
5073 } | 5066 } |
5074 | 5067 |
5075 } // namespace chromeos | 5068 } // namespace chromeos |
5076 | 5069 |
5077 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 5070 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
5078 // won't be deleted until it's last InvokeLater is run. | 5071 // won't be deleted until it's last InvokeLater is run. |
5079 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); | 5072 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); |
OLD | NEW |