| 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/status/data_promo_notification.h" | 5 #include "chrome/browser/chromeos/status/data_promo_notification.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/system/chromeos/network/network_observer.h" | 9 #include "ash/system/chromeos/network/network_observer.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 17 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
| 18 #include "chrome/browser/chromeos/login/helper.h" | 18 #include "chrome/browser/chromeos/login/helper.h" |
| 19 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 20 #include "chrome/browser/chromeos/mobile_config.h" | 19 #include "chrome/browser/chromeos/mobile_config.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chromeos/login/login_state.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/views/view.h" | 30 #include "ui/views/view.h" |
| 31 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Time in milliseconds to delay showing of promo | 35 // Time in milliseconds to delay showing of promo |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 void DataPromoNotification::RegisterPrefs(PrefRegistrySimple* registry) { | 131 void DataPromoNotification::RegisterPrefs(PrefRegistrySimple* registry) { |
| 132 // Carrier deal notification shown count defaults to 0. | 132 // Carrier deal notification shown count defaults to 0. |
| 133 registry->RegisterIntegerPref(prefs::kCarrierDealPromoShown, 0); | 133 registry->RegisterIntegerPref(prefs::kCarrierDealPromoShown, 0); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void DataPromoNotification::ShowOptionalMobileDataPromoNotification( | 136 void DataPromoNotification::ShowOptionalMobileDataPromoNotification( |
| 137 NetworkLibrary* cros, | 137 NetworkLibrary* cros, |
| 138 views::View* host, | 138 views::View* host, |
| 139 ash::NetworkTrayDelegate* listener) { | 139 ash::NetworkTrayDelegate* listener) { |
| 140 // Display one-time notification for non-Guest users on first use | 140 // Display one-time notification for regular users on first use |
| 141 // of Mobile Data connection or if there's a carrier deal defined | 141 // of Mobile Data connection or if there's a carrier deal defined |
| 142 // show that even if user has already seen generic promo. | 142 // show that even if user has already seen generic promo. |
| 143 if (UserManager::Get()->IsUserLoggedIn() && | 143 if (LoginState::Get()->IsUserAuthenticated() && |
| 144 !UserManager::Get()->IsLoggedInAsGuest() && | |
| 145 check_for_promo_ && | 144 check_for_promo_ && |
| 146 cros->cellular_connected() && !cros->ethernet_connected() && | 145 cros->cellular_connected() && !cros->ethernet_connected() && |
| 147 !cros->wifi_connected() && !cros->wimax_connected()) { | 146 !cros->wifi_connected() && !cros->wimax_connected()) { |
| 148 std::string deal_text; | 147 std::string deal_text; |
| 149 int carrier_deal_promo_pref = kNotificationCountPrefDefault; | 148 int carrier_deal_promo_pref = kNotificationCountPrefDefault; |
| 150 const MobileConfig::CarrierDeal* deal = NULL; | 149 const MobileConfig::CarrierDeal* deal = NULL; |
| 151 const MobileConfig::Carrier* carrier = GetCarrier(cros); | 150 const MobileConfig::Carrier* carrier = GetCarrier(cros); |
| 152 if (carrier) | 151 if (carrier) |
| 153 deal = GetCarrierDeal(carrier); | 152 deal = GetCarrierDeal(carrier); |
| 154 deal_info_url_.clear(); | 153 deal_info_url_.clear(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); | 200 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); |
| 202 } | 201 } |
| 203 } | 202 } |
| 204 | 203 |
| 205 void DataPromoNotification::CloseNotification() { | 204 void DataPromoNotification::CloseNotification() { |
| 206 ash::Shell::GetInstance()->system_tray_notifier()->NotifyClearNetworkMessage( | 205 ash::Shell::GetInstance()->system_tray_notifier()->NotifyClearNetworkMessage( |
| 207 ash::NetworkObserver::MESSAGE_DATA_PROMO); | 206 ash::NetworkObserver::MESSAGE_DATA_PROMO); |
| 208 } | 207 } |
| 209 | 208 |
| 210 } // namespace chromeos | 209 } // namespace chromeos |
| OLD | NEW |