Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/chromeos/status/data_promo_notification.cc

Issue 2435903002: Move tray code from ui/chromeos/network/ (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/login/helper.h" 12 #include "chrome/browser/chromeos/login/helper.h"
12 #include "chrome/browser/chromeos/mobile_config.h" 13 #include "chrome/browser/chromeos/mobile_config.h"
13 #include "chrome/browser/chromeos/net/network_state_notifier.h" 14 #include "chrome/browser/chromeos/net/network_state_notifier.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/ash/system_tray_client.h" 17 #include "chrome/browser/ui/ash/system_tray_client.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
(...skipping 11 matching lines...) Expand all
29 #include "chromeos/network/network_event_log.h" 30 #include "chromeos/network/network_event_log.h"
30 #include "chromeos/network/network_state.h" 31 #include "chromeos/network/network_state.h"
31 #include "chromeos/network/network_state_handler.h" 32 #include "chromeos/network/network_state_handler.h"
32 #include "components/prefs/pref_registry_simple.h" 33 #include "components/prefs/pref_registry_simple.h"
33 #include "components/prefs/pref_service.h" 34 #include "components/prefs/pref_service.h"
34 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
35 #include "extensions/browser/extension_registry.h" 36 #include "extensions/browser/extension_registry.h"
36 #include "third_party/cros_system_api/dbus/service_constants.h" 37 #include "third_party/cros_system_api/dbus/service_constants.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/chromeos/resources/grit/ui_chromeos_resources.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 {
46 46
47 namespace { 47 namespace {
48 48
49 const char kDataPromoNotificationId[] = "chrome://settings/internet/data_promo"; 49 const char kDataPromoNotificationId[] = "chrome://settings/internet/data_promo";
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 message = base::UTF8ToUTF16(deal_text + "\n\n") + message; 254 message = base::UTF8ToUTF16(deal_text + "\n\n") + message;
255 info_url = deal->info_url(); 255 info_url = deal->info_url();
256 if (info_url.empty() && carrier) 256 if (info_url.empty() && carrier)
257 info_url = carrier->top_up_url(); 257 info_url = carrier->top_up_url();
258 } else if (data_saver_prompt_shown || !ShouldShow3gPromoNotification()) { 258 } else if (data_saver_prompt_shown || !ShouldShow3gPromoNotification()) {
259 return; 259 return;
260 } 260 }
261 261
262 int icon_id; 262 int icon_id;
263 if (default_network->network_technology() == shill::kNetworkTechnologyLte) 263 if (default_network->network_technology() == shill::kNetworkTechnologyLte)
264 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; 264 icon_id = IDR_AURA_UBER_TRAY_NETWORK_NOTIFICATION_LTE;
265 else 265 else
266 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; 266 icon_id = IDR_AURA_UBER_TRAY_NETWORK_NOTIFICATION_3G;
267 const gfx::Image& icon = 267 const gfx::Image& icon =
268 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); 268 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
269 269
270 message_center::MessageCenter::Get()->AddNotification( 270 message_center::MessageCenter::Get()->AddNotification(
271 message_center::Notification::CreateSystemNotification( 271 message_center::Notification::CreateSystemNotification(
272 kDataPromoNotificationId, base::string16() /* title */, message, icon, 272 kDataPromoNotificationId, base::string16() /* title */, message, icon,
273 ash::system_notifier::kNotifierNetwork, 273 ash::system_notifier::kNotifierNetwork,
274 base::Bind(&NotificationClicked, default_network->guid(), info_url))); 274 base::Bind(&NotificationClicked, default_network->guid(), info_url)));
275 275
276 SetShow3gPromoNotification(false); 276 SetShow3gPromoNotification(false);
(...skipping 18 matching lines...) Expand all
295 extensions::ExtensionRegistry::EVERYTHING)) { 295 extensions::ExtensionRegistry::EVERYTHING)) {
296 // If extension is installed, disable future prompts. 296 // If extension is installed, disable future prompts.
297 SetDataSaverPromptsShown(kTimesToShowDataSaverPrompt); 297 SetDataSaverPromptsShown(kTimesToShowDataSaverPrompt);
298 return false; 298 return false;
299 } 299 }
300 300
301 base::string16 title = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_TITLE); 301 base::string16 title = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_TITLE);
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_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 content::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
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/network_state_notifier.cc ('k') | chrome/browser/chromeos/status/network_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698