| 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/status/network_menu.h" | 5 #include "chrome/browser/chromeos/status/network_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" | 13 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/customization_document.h" | 15 #include "chrome/browser/chromeos/mobile_config.h" |
| 16 #include "chrome/browser/chromeos/options/network_config_view.h" | 16 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 17 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 17 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 18 #include "chrome/browser/chromeos/status/network_menu_icon.h" | 18 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
| 19 #include "chrome/browser/defaults.h" | 19 #include "chrome/browser/defaults.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/views/window.h" | 24 #include "chrome/browser/ui/views/window.h" |
| 25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 menu_items_.push_back( | 705 menu_items_.push_back( |
| 706 MenuItem(ui::MenuModel::TYPE_COMMAND, | 706 MenuItem(ui::MenuModel::TYPE_COMMAND, |
| 707 label, SkBitmap(), | 707 label, SkBitmap(), |
| 708 std::string(), FLAG_DISABLED)); | 708 std::string(), FLAG_DISABLED)); |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 const NetworkDevice* cellular_device = cros->FindCellularDevice(); | 712 const NetworkDevice* cellular_device = cros->FindCellularDevice(); |
| 713 if (cellular_device) { | 713 if (cellular_device) { |
| 714 // Add "View Account" with top up URL if we know that. | 714 // Add "View Account" with top up URL if we know that. |
| 715 ServicesCustomizationDocument* customization = | 715 MobileConfig* config = MobileConfig::GetInstance(); |
| 716 ServicesCustomizationDocument::GetInstance(); | 716 if (is_browser_mode && config->IsReady()) { |
| 717 if (is_browser_mode && customization->IsReady()) { | |
| 718 std::string carrier_id = cros->GetCellularHomeCarrierId(); | 717 std::string carrier_id = cros->GetCellularHomeCarrierId(); |
| 719 // If we don't have top up URL cached. | 718 // If we don't have top up URL cached. |
| 720 if (carrier_id != carrier_id_) { | 719 if (carrier_id != carrier_id_) { |
| 721 // Mark that we've checked this carrier ID. | 720 // Mark that we've checked this carrier ID. |
| 722 carrier_id_ = carrier_id; | 721 carrier_id_ = carrier_id; |
| 723 top_up_url_.clear(); | 722 top_up_url_.clear(); |
| 724 // Ignoring deal restrictions, use any carrier information available. | 723 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); |
| 725 const ServicesCustomizationDocument::CarrierDeal* deal = | 724 if (carrier && !carrier->top_up_url().empty()) |
| 726 customization->GetCarrierDeal(carrier_id, false); | 725 top_up_url_ = carrier->top_up_url(); |
| 727 if (deal && !deal->top_up_url().empty()) | |
| 728 top_up_url_ = deal->top_up_url(); | |
| 729 } | 726 } |
| 730 if (!top_up_url_.empty()) { | 727 if (!top_up_url_.empty()) { |
| 731 menu_items_.push_back(MenuItem( | 728 menu_items_.push_back(MenuItem( |
| 732 ui::MenuModel::TYPE_COMMAND, | 729 ui::MenuModel::TYPE_COMMAND, |
| 733 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_VIEW_ACCOUNT), | 730 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_VIEW_ACCOUNT), |
| 734 SkBitmap(), | 731 SkBitmap(), |
| 735 std::string(), FLAG_VIEW_ACCOUNT)); | 732 std::string(), FLAG_VIEW_ACCOUNT)); |
| 736 } | 733 } |
| 737 } | 734 } |
| 738 | 735 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 std::string page = StringPrintf( | 1093 std::string page = StringPrintf( |
| 1097 "%s?servicePath=%s&networkType=%d&networkName=%s", | 1094 "%s?servicePath=%s&networkType=%d&networkName=%s", |
| 1098 chrome::kInternetOptionsSubPage, | 1095 chrome::kInternetOptionsSubPage, |
| 1099 EscapeUrlEncodedData(network->service_path(), true).c_str(), | 1096 EscapeUrlEncodedData(network->service_path(), true).c_str(), |
| 1100 network->type(), | 1097 network->type(), |
| 1101 EscapeUrlEncodedData(network_name, false).c_str()); | 1098 EscapeUrlEncodedData(network_name, false).c_str()); |
| 1102 browser->ShowOptionsTab(page); | 1099 browser->ShowOptionsTab(page); |
| 1103 } | 1100 } |
| 1104 | 1101 |
| 1105 } // namespace chromeos | 1102 } // namespace chromeos |
| OLD | NEW |