| 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_button.h" | 5 #include "chrome/browser/chromeos/status/network_menu_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chromeos/cros/cros_library.h" | 18 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 19 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 19 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 20 #include "chrome/browser/chromeos/login/helper.h" | 20 #include "chrome/browser/chromeos/login/helper.h" |
| 21 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 22 #include "chrome/browser/chromeos/options/network_config_view.h" | 22 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 23 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 23 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 24 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
| 24 #include "chrome/browser/chromeos/view_ids.h" | 25 #include "chrome/browser/chromeos/view_ids.h" |
| 25 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 31 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 SetIntegerLocalPref(prefs::kCarrierDealPromoShown, value); | 91 SetIntegerLocalPref(prefs::kCarrierDealPromoShown, value); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace | 94 } // namespace |
| 94 | 95 |
| 95 namespace chromeos { | 96 namespace chromeos { |
| 96 | 97 |
| 97 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
| 98 // NetworkMenuButton | 99 // NetworkMenuButton |
| 99 | 100 |
| 100 NetworkMenuButton::NetworkMenuButton( | 101 NetworkMenuButton::NetworkMenuButton(StatusAreaButton::Delegate* delegate) |
| 101 StatusAreaButton::Delegate* delegate, | |
| 102 StatusAreaViewChromeos::ScreenMode screen_mode) | |
| 103 : StatusAreaButton(delegate, this), | 102 : StatusAreaButton(delegate, this), |
| 104 mobile_data_bubble_(NULL), | 103 mobile_data_bubble_(NULL), |
| 105 is_browser_mode_(false), | |
| 106 check_for_promo_(true), | 104 check_for_promo_(true), |
| 107 was_sim_locked_(false), | 105 was_sim_locked_(false), |
| 108 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 106 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 109 set_id(VIEW_ID_STATUS_BUTTON_NETWORK_MENU); | 107 set_id(VIEW_ID_STATUS_BUTTON_NETWORK_MENU); |
| 110 is_browser_mode_ = (screen_mode == StatusAreaViewChromeos::BROWSER_MODE); | 108 network_menu_.reset(new NetworkMenu(this)); |
| 111 network_menu_.reset(new NetworkMenu(this, is_browser_mode_)); | |
| 112 network_icon_.reset( | 109 network_icon_.reset( |
| 113 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)); | 110 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)); |
| 114 | 111 |
| 115 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 112 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 116 OnNetworkManagerChanged(network_library); | 113 OnNetworkManagerChanged(network_library); |
| 117 network_library->AddNetworkManagerObserver(this); | 114 network_library->AddNetworkManagerObserver(this); |
| 118 network_library->AddCellularDataPlanObserver(this); | 115 network_library->AddCellularDataPlanObserver(this); |
| 119 const NetworkDevice* cellular = network_library->FindCellularDevice(); | 116 const NetworkDevice* cellular = network_library->FindCellularDevice(); |
| 120 if (cellular) { | 117 if (cellular) { |
| 121 cellular_device_path_ = cellular->device_path(); | 118 cellular_device_path_ = cellular->device_path(); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 357 } |
| 361 cellular_device_path_ = new_cellular_device_path; | 358 cellular_device_path_ = new_cellular_device_path; |
| 362 } | 359 } |
| 363 } | 360 } |
| 364 | 361 |
| 365 void NetworkMenuButton::ShowOptionalMobileDataPromoNotification( | 362 void NetworkMenuButton::ShowOptionalMobileDataPromoNotification( |
| 366 NetworkLibrary* cros) { | 363 NetworkLibrary* cros) { |
| 367 // Display one-time notification for non-Guest users on first use | 364 // Display one-time notification for non-Guest users on first use |
| 368 // of Mobile Data connection or if there's a carrier deal defined | 365 // of Mobile Data connection or if there's a carrier deal defined |
| 369 // show that even if user has already seen generic promo. | 366 // show that even if user has already seen generic promo. |
| 370 if (is_browser_mode_ && !UserManager::Get()->IsLoggedInAsGuest() && | 367 if (StatusAreaViewChromeos::IsBrowserMode() && |
| 368 !UserManager::Get()->IsLoggedInAsGuest() && |
| 371 check_for_promo_ && BrowserList::GetLastActive() && | 369 check_for_promo_ && BrowserList::GetLastActive() && |
| 372 cros->cellular_connected() && !cros->ethernet_connected() && | 370 cros->cellular_connected() && !cros->ethernet_connected() && |
| 373 !cros->wifi_connected()) { | 371 !cros->wifi_connected()) { |
| 374 std::string deal_text; | 372 std::string deal_text; |
| 375 int carrier_deal_promo_pref = -1; | 373 int carrier_deal_promo_pref = -1; |
| 376 const MobileConfig::CarrierDeal* deal = NULL; | 374 const MobileConfig::CarrierDeal* deal = NULL; |
| 377 const MobileConfig::Carrier* carrier = GetCarrier(cros); | 375 const MobileConfig::Carrier* carrier = GetCarrier(cros); |
| 378 if (carrier) | 376 if (carrier) |
| 379 deal = GetCarrierDeal(carrier); | 377 deal = GetCarrierDeal(carrier); |
| 380 if (deal) { | 378 if (deal) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); | 447 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); |
| 450 } | 448 } |
| 451 } | 449 } |
| 452 | 450 |
| 453 void NetworkMenuButton::SetTooltipAndAccessibleName(const string16& label) { | 451 void NetworkMenuButton::SetTooltipAndAccessibleName(const string16& label) { |
| 454 SetTooltipText(label); | 452 SetTooltipText(label); |
| 455 SetAccessibleName(label); | 453 SetAccessibleName(label); |
| 456 } | 454 } |
| 457 | 455 |
| 458 } // namespace chromeos | 456 } // namespace chromeos |
| OLD | NEW |