| 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_connect.h" |
| 9 #include "ash/system/chromeos/network/network_observer.h" | 10 #include "ash/system/chromeos/network/network_observer.h" |
| 10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/login/helper.h" | 17 #include "chrome/browser/chromeos/login/helper.h" |
| 17 #include "chrome/browser/chromeos/mobile_config.h" | 18 #include "chrome/browser/chromeos/mobile_config.h" |
| 18 #include "chrome/browser/chromeos/options/network_connect.h" | |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/singleton_tabs.h" | 24 #include "chrome/browser/ui/singleton_tabs.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "chromeos/login/login_state.h" | 26 #include "chromeos/login/login_state.h" |
| 27 #include "chromeos/network/device_state.h" | 27 #include "chromeos/network/device_state.h" |
| 28 #include "chromeos/network/network_connection_handler.h" | 28 #include "chromeos/network/network_connection_handler.h" |
| 29 #include "chromeos/network/network_event_log.h" | 29 #include "chromeos/network/network_event_log.h" |
| 30 #include "chromeos/network/network_state.h" | 30 #include "chromeos/network/network_state.h" |
| 31 #include "chromeos/network/network_state_handler.h" | 31 #include "chromeos/network/network_state_handler.h" |
| 32 #include "grit/ash_strings.h" |
| 32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 33 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 34 #include "third_party/cros_system_api/dbus/service_constants.h" | 35 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
| 37 #include "ui/views/view.h" | 38 #include "ui/views/view.h" |
| 38 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 39 | 40 |
| 40 namespace chromeos { | 41 namespace chromeos { |
| 41 | 42 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 176 } |
| 176 | 177 |
| 177 void DataPromoNotification::NotificationLinkClicked( | 178 void DataPromoNotification::NotificationLinkClicked( |
| 178 ash::NetworkObserver::MessageType message_type, | 179 ash::NetworkObserver::MessageType message_type, |
| 179 size_t link_index) { | 180 size_t link_index) { |
| 180 const NetworkState* cellular = | 181 const NetworkState* cellular = |
| 181 NetworkHandler::Get()->network_state_handler()-> | 182 NetworkHandler::Get()->network_state_handler()-> |
| 182 FirstNetworkByType(flimflam::kTypeCellular); | 183 FirstNetworkByType(flimflam::kTypeCellular); |
| 183 std::string service_path = cellular ? cellular->path() : ""; | 184 std::string service_path = cellular ? cellular->path() : ""; |
| 184 if (message_type == ash::NetworkObserver::ERROR_OUT_OF_CREDITS) { | 185 if (message_type == ash::NetworkObserver::ERROR_OUT_OF_CREDITS) { |
| 185 network_connect::ShowNetworkSettings(service_path); | 186 ash::network_connect::ShowNetworkSettings(service_path); |
| 186 ash::Shell::GetInstance()->system_tray_notifier()-> | 187 ash::Shell::GetInstance()->system_tray_notifier()-> |
| 187 NotifyClearNetworkMessage(message_type); | 188 NotifyClearNetworkMessage(message_type); |
| 188 } | 189 } |
| 189 if (message_type != ash::NetworkObserver::MESSAGE_DATA_PROMO) | 190 if (message_type != ash::NetworkObserver::MESSAGE_DATA_PROMO) |
| 190 return; | 191 return; |
| 191 | 192 |
| 192 // If we have a deal info URL defined that means that there are | 193 // If we have a deal info URL defined that means that there are |
| 193 // two links in the bubble. Let the user close it manually then giving the | 194 // two links in the bubble. Let the user close it manually then giving the |
| 194 // ability to navigate to the second link. | 195 // ability to navigate to the second link. |
| 195 if (deal_info_url_.empty()) | 196 if (deal_info_url_.empty()) |
| 196 CloseNotification(); | 197 CloseNotification(); |
| 197 | 198 |
| 198 std::string deal_url_to_open; | 199 std::string deal_url_to_open; |
| 199 if (link_index == 0) { | 200 if (link_index == 0) { |
| 200 if (!deal_topup_url_.empty()) { | 201 if (!deal_topup_url_.empty()) { |
| 201 deal_url_to_open = deal_topup_url_; | 202 deal_url_to_open = deal_topup_url_; |
| 202 } else { | 203 } else { |
| 203 network_connect::ShowNetworkSettings(service_path); | 204 ash::network_connect::ShowNetworkSettings(service_path); |
| 204 return; | 205 return; |
| 205 } | 206 } |
| 206 } else if (link_index == 1) { | 207 } else if (link_index == 1) { |
| 207 deal_url_to_open = deal_info_url_; | 208 deal_url_to_open = deal_info_url_; |
| 208 } | 209 } |
| 209 | 210 |
| 210 if (!deal_url_to_open.empty()) { | 211 if (!deal_url_to_open.empty()) { |
| 211 Browser* browser = chrome::FindOrCreateTabbedBrowser( | 212 Browser* browser = chrome::FindOrCreateTabbedBrowser( |
| 212 ProfileManager::GetDefaultProfileOrOffTheRecord(), | 213 ProfileManager::GetDefaultProfileOrOffTheRecord(), |
| 213 chrome::HOST_DESKTOP_TYPE_ASH); | 214 chrome::HOST_DESKTOP_TYPE_ASH); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if (carrier_deal_promo_pref != kNotificationCountPrefDefault) | 304 if (carrier_deal_promo_pref != kNotificationCountPrefDefault) |
| 304 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); | 305 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); |
| 305 } | 306 } |
| 306 | 307 |
| 307 void DataPromoNotification::CloseNotification() { | 308 void DataPromoNotification::CloseNotification() { |
| 308 ash::Shell::GetInstance()->system_tray_notifier()->NotifyClearNetworkMessage( | 309 ash::Shell::GetInstance()->system_tray_notifier()->NotifyClearNetworkMessage( |
| 309 ash::NetworkObserver::MESSAGE_DATA_PROMO); | 310 ash::NetworkObserver::MESSAGE_DATA_PROMO); |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace chromeos | 313 } // namespace chromeos |
| OLD | NEW |