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 "ash/common/system/system_notifier.h" |
8 #include "ash/resources/grit/ash_resources.h" | 8 #include "ash/resources/grit/ash_resources.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/user_metrics.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/login/helper.h" | 13 #include "chrome/browser/chromeos/login/helper.h" |
13 #include "chrome/browser/chromeos/mobile_config.h" | 14 #include "chrome/browser/chromeos/mobile_config.h" |
14 #include "chrome/browser/chromeos/net/network_state_notifier.h" | 15 #include "chrome/browser/chromeos/net/network_state_notifier.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/ash/system_tray_client.h" | 18 #include "chrome/browser/ui/ash/system_tray_client.h" |
18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
21 #include "chrome/browser/ui/singleton_tabs.h" | 22 #include "chrome/browser/ui/singleton_tabs.h" |
22 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
24 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
25 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
26 #include "chromeos/login/login_state.h" | 27 #include "chromeos/login/login_state.h" |
27 #include "chromeos/network/device_state.h" | 28 #include "chromeos/network/device_state.h" |
28 #include "chromeos/network/network_connect.h" | 29 #include "chromeos/network/network_connect.h" |
29 #include "chromeos/network/network_connection_handler.h" | 30 #include "chromeos/network/network_connection_handler.h" |
30 #include "chromeos/network/network_event_log.h" | 31 #include "chromeos/network/network_event_log.h" |
31 #include "chromeos/network/network_state.h" | 32 #include "chromeos/network/network_state.h" |
32 #include "chromeos/network/network_state_handler.h" | 33 #include "chromeos/network/network_state_handler.h" |
33 #include "components/prefs/pref_registry_simple.h" | 34 #include "components/prefs/pref_registry_simple.h" |
34 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
35 #include "content/public/browser/user_metrics.h" | |
36 #include "extensions/browser/extension_registry.h" | 36 #include "extensions/browser/extension_registry.h" |
37 #include "third_party/cros_system_api/dbus/service_constants.h" | 37 #include "third_party/cros_system_api/dbus/service_constants.h" |
38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
40 #include "ui/message_center/message_center.h" | 40 #include "ui/message_center/message_center.h" |
41 #include "ui/message_center/notification.h" | 41 #include "ui/message_center/notification.h" |
42 #include "ui/views/view.h" | 42 #include "ui/views/view.h" |
43 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
44 | 44 |
45 namespace chromeos { | 45 namespace chromeos { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 return deal; | 164 return deal; |
165 } | 165 } |
166 | 166 |
167 void NotificationClicked(const std::string& network_id, | 167 void NotificationClicked(const std::string& network_id, |
168 const std::string& info_url) { | 168 const std::string& info_url) { |
169 if (!info_url.empty()) { | 169 if (!info_url.empty()) { |
170 chrome::ScopedTabbedBrowserDisplayer displayer( | 170 chrome::ScopedTabbedBrowserDisplayer displayer( |
171 ProfileManager::GetPrimaryUserProfile()); | 171 ProfileManager::GetPrimaryUserProfile()); |
172 chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); | 172 chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); |
173 if (info_url == kDataSaverExtensionUrl) | 173 if (info_url == kDataSaverExtensionUrl) |
174 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Clicked")); | 174 base::RecordAction(base::UserMetricsAction("DataSaverPrompt_Clicked")); |
175 } else { | 175 } else { |
176 SystemTrayClient::Get()->ShowNetworkSettings(network_id); | 176 SystemTrayClient::Get()->ShowNetworkSettings(network_id); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 } // namespace | 180 } // namespace |
181 | 181 |
182 //////////////////////////////////////////////////////////////////////////////// | 182 //////////////////////////////////////////////////////////////////////////////// |
183 // DataPromoNotification | 183 // DataPromoNotification |
184 | 184 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 base::string16 message = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_MESSAGE); | 302 base::string16 message = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_MESSAGE); |
303 const gfx::Image& icon = | 303 const gfx::Image& icon = |
304 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 304 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
305 IDR_AURA_UBER_TRAY_NETWORK_NOTIFICATION_DATASAVER); | 305 IDR_AURA_UBER_TRAY_NETWORK_NOTIFICATION_DATASAVER); |
306 | 306 |
307 message_center::MessageCenter::Get()->AddNotification( | 307 message_center::MessageCenter::Get()->AddNotification( |
308 message_center::Notification::CreateSystemNotification( | 308 message_center::Notification::CreateSystemNotification( |
309 kDataSaverNotificationId, title, message, icon, | 309 kDataSaverNotificationId, title, message, icon, |
310 ash::system_notifier::kNotifierNetwork, | 310 ash::system_notifier::kNotifierNetwork, |
311 base::Bind(&NotificationClicked, "", kDataSaverExtensionUrl))); | 311 base::Bind(&NotificationClicked, "", kDataSaverExtensionUrl))); |
312 content::RecordAction(base::UserMetricsAction("DataSaverPrompt_Shown")); | 312 base::RecordAction(base::UserMetricsAction("DataSaverPrompt_Shown")); |
313 | 313 |
314 if (DataSaverSwitchDemoMode()) { | 314 if (DataSaverSwitchDemoMode()) { |
315 SetDataSaverPromptsShown(0); // demo mode resets times shown counts. | 315 SetDataSaverPromptsShown(0); // demo mode resets times shown counts. |
316 SetShow3gPromoNotification(true); | 316 SetShow3gPromoNotification(true); |
317 } else { | 317 } else { |
318 SetDataSaverPromptsShown(times_shown + 1); | 318 SetDataSaverPromptsShown(times_shown + 1); |
319 } | 319 } |
320 | 320 |
321 return true; | 321 return true; |
322 } | 322 } |
323 | 323 |
324 } // namespace chromeos | 324 } // namespace chromeos |
OLD | NEW |