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/common/system/system_notifier.h" |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chromeos/login/helper.h" | 11 #include "chrome/browser/chromeos/login/helper.h" |
11 #include "chrome/browser/chromeos/mobile_config.h" | 12 #include "chrome/browser/chromeos/mobile_config.h" |
| 13 #include "chrome/browser/chromeos/net/network_state_notifier.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/ash/system_tray_client.h" |
14 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 19 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
17 #include "chrome/browser/ui/singleton_tabs.h" | 20 #include "chrome/browser/ui/singleton_tabs.h" |
18 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
19 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
20 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
21 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
22 #include "chromeos/login/login_state.h" | 25 #include "chromeos/login/login_state.h" |
23 #include "chromeos/network/device_state.h" | 26 #include "chromeos/network/device_state.h" |
| 27 #include "chromeos/network/network_connect.h" |
24 #include "chromeos/network/network_connection_handler.h" | 28 #include "chromeos/network/network_connection_handler.h" |
25 #include "chromeos/network/network_event_log.h" | 29 #include "chromeos/network/network_event_log.h" |
26 #include "chromeos/network/network_state.h" | 30 #include "chromeos/network/network_state.h" |
27 #include "chromeos/network/network_state_handler.h" | 31 #include "chromeos/network/network_state_handler.h" |
28 #include "components/prefs/pref_registry_simple.h" | 32 #include "components/prefs/pref_registry_simple.h" |
29 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
30 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
31 #include "extensions/browser/extension_registry.h" | 35 #include "extensions/browser/extension_registry.h" |
32 #include "third_party/cros_system_api/dbus/service_constants.h" | 36 #include "third_party/cros_system_api/dbus/service_constants.h" |
33 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/chromeos/network/network_connect.h" | |
36 #include "ui/chromeos/network/network_state_notifier.h" | |
37 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" | 39 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" |
38 #include "ui/message_center/message_center.h" | 40 #include "ui/message_center/message_center.h" |
39 #include "ui/message_center/notification.h" | 41 #include "ui/message_center/notification.h" |
40 #include "ui/views/view.h" | 42 #include "ui/views/view.h" |
41 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
42 | 44 |
43 namespace chromeos { | 45 namespace chromeos { |
44 | 46 |
45 namespace { | 47 namespace { |
46 | 48 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const std::string locale = g_browser_process->GetApplicationLocale(); | 157 const std::string locale = g_browser_process->GetApplicationLocale(); |
156 std::string deal_text = deal->GetLocalizedString(locale, | 158 std::string deal_text = deal->GetLocalizedString(locale, |
157 "notification_text"); | 159 "notification_text"); |
158 NET_LOG_DEBUG("Carrier Deal Found", deal_text); | 160 NET_LOG_DEBUG("Carrier Deal Found", deal_text); |
159 if (deal_text.empty()) | 161 if (deal_text.empty()) |
160 return NULL; | 162 return NULL; |
161 } | 163 } |
162 return deal; | 164 return deal; |
163 } | 165 } |
164 | 166 |
165 void NotificationClicked(const std::string& service_path, | 167 void NotificationClicked(const std::string& network_id, |
166 const std::string& info_url) { | 168 const std::string& info_url) { |
167 if (!info_url.empty()) { | 169 if (!info_url.empty()) { |
168 chrome::ScopedTabbedBrowserDisplayer displayer( | 170 chrome::ScopedTabbedBrowserDisplayer displayer( |
169 ProfileManager::GetPrimaryUserProfile()); | 171 ProfileManager::GetPrimaryUserProfile()); |
170 chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); | 172 chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); |
171 if (info_url == kDataSaverExtensionUrl) | 173 if (info_url == kDataSaverExtensionUrl) |
172 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Clicked")); | 174 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Clicked")); |
173 } else { | 175 } else { |
174 ui::NetworkConnect::Get()->ShowNetworkSettingsForPath(service_path); | 176 SystemTrayClient::Get()->ShowNetworkSettings(network_id); |
175 } | 177 } |
176 } | 178 } |
177 | 179 |
178 } // namespace | 180 } // namespace |
179 | 181 |
180 //////////////////////////////////////////////////////////////////////////////// | 182 //////////////////////////////////////////////////////////////////////////////// |
181 // DataPromoNotification | 183 // DataPromoNotification |
182 | 184 |
183 DataPromoNotification::DataPromoNotification() | 185 DataPromoNotification::DataPromoNotification() |
184 : notifications_shown_(false), | 186 : notifications_shown_(false), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (default_network->network_technology() == shill::kNetworkTechnologyLte) | 263 if (default_network->network_technology() == shill::kNetworkTechnologyLte) |
262 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; | 264 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; |
263 else | 265 else |
264 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; | 266 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; |
265 const gfx::Image& icon = | 267 const gfx::Image& icon = |
266 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); | 268 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); |
267 | 269 |
268 message_center::MessageCenter::Get()->AddNotification( | 270 message_center::MessageCenter::Get()->AddNotification( |
269 message_center::Notification::CreateSystemNotification( | 271 message_center::Notification::CreateSystemNotification( |
270 kDataPromoNotificationId, base::string16() /* title */, message, icon, | 272 kDataPromoNotificationId, base::string16() /* title */, message, icon, |
271 ui::NetworkStateNotifier::kNotifierNetwork, | 273 ash::system_notifier::kNotifierNetwork, |
272 base::Bind(&NotificationClicked, default_network->path(), info_url))); | 274 base::Bind(&NotificationClicked, default_network->guid(), info_url))); |
273 | 275 |
274 SetShow3gPromoNotification(false); | 276 SetShow3gPromoNotification(false); |
275 if (carrier_deal_promo_pref != kNotificationCountPrefDefault) | 277 if (carrier_deal_promo_pref != kNotificationCountPrefDefault) |
276 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); | 278 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); |
277 } | 279 } |
278 | 280 |
279 bool DataPromoNotification::ShowDataSaverNotification() { | 281 bool DataPromoNotification::ShowDataSaverNotification() { |
280 if (!DataSaverSwitchEnabled()) | 282 if (!DataSaverSwitchEnabled()) |
281 return false; | 283 return false; |
282 | 284 |
(...skipping 15 matching lines...) Expand all Loading... |
298 | 300 |
299 base::string16 title = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_TITLE); | 301 base::string16 title = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_TITLE); |
300 base::string16 message = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_MESSAGE); | 302 base::string16 message = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_MESSAGE); |
301 const gfx::Image& icon = | 303 const gfx::Image& icon = |
302 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 304 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
303 IDR_AURA_UBER_TRAY_NOTIFICATION_DATASAVER); | 305 IDR_AURA_UBER_TRAY_NOTIFICATION_DATASAVER); |
304 | 306 |
305 message_center::MessageCenter::Get()->AddNotification( | 307 message_center::MessageCenter::Get()->AddNotification( |
306 message_center::Notification::CreateSystemNotification( | 308 message_center::Notification::CreateSystemNotification( |
307 kDataSaverNotificationId, title, message, icon, | 309 kDataSaverNotificationId, title, message, icon, |
308 ui::NetworkStateNotifier::kNotifierNetwork, | 310 ash::system_notifier::kNotifierNetwork, |
309 base::Bind(&NotificationClicked, "", kDataSaverExtensionUrl))); | 311 base::Bind(&NotificationClicked, "", kDataSaverExtensionUrl))); |
310 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Shown")); | 312 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Shown")); |
311 | 313 |
312 if (DataSaverSwitchDemoMode()) { | 314 if (DataSaverSwitchDemoMode()) { |
313 SetDataSaverPromptsShown(0); // demo mode resets times shown counts. | 315 SetDataSaverPromptsShown(0); // demo mode resets times shown counts. |
314 SetShow3gPromoNotification(true); | 316 SetShow3gPromoNotification(true); |
315 } else { | 317 } else { |
316 SetDataSaverPromptsShown(times_shown + 1); | 318 SetDataSaverPromptsShown(times_shown + 1); |
317 } | 319 } |
318 | 320 |
319 return true; | 321 return true; |
320 } | 322 } |
321 | 323 |
322 } // namespace chromeos | 324 } // namespace chromeos |
OLD | NEW |