15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/status/data_promo_notification.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ash/resources/grit/ash_resources.h"
83551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "ash/system/chromeos/network/network_connect.h"
9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ash/system/system_notifier.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_registry_simple.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h"
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_process.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/login/helper.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/mobile_config.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_list.h"
200f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
213551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/ui/singleton_tabs.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h"
236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "chrome/grit/generated_resources.h"
24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/login/login_state.h"
253551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chromeos/network/device_state.h"
263551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chromeos/network/network_connection_handler.h"
273551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chromeos/network/network_event_log.h"
283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chromeos/network/network_state.h"
293551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chromeos/network/network_state_handler.h"
303551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "third_party/cros_system_api/dbus/service_constants.h"
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/resource/resource_bundle.h"
333551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "ui/message_center/message_center.h"
343551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "ui/message_center/notification.h"
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/view.h"
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/widget/widget.h"
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)namespace chromeos {
393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const int kNotificationCountPrefDefault = -1;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool GetBooleanPref(const char* pref_name) {
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Profile* profile = ProfileManager::GetPrimaryUserProfile();
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PrefService* prefs = profile->GetPrefs();
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return prefs->GetBoolean(pref_name);
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int GetIntegerLocalPref(const char* pref_name) {
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PrefService* prefs = g_browser_process->local_state();
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return prefs->GetInteger(pref_name);
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetBooleanPref(const char* pref_name, bool value) {
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Profile* profile = ProfileManager::GetPrimaryUserProfile();
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PrefService* prefs = profile->GetPrefs();
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  prefs->SetBoolean(pref_name, value);
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetIntegerLocalPref(const char* pref_name, int value) {
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PrefService* prefs = g_browser_process->local_state();
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  prefs->SetInteger(pref_name, value);
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
663551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// Returns prefs::kShow3gPromoNotification or false if no active browser.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ShouldShow3gPromoNotification() {
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return GetBooleanPref(prefs::kShow3gPromoNotification);
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetShow3gPromoNotification(bool value) {
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SetBooleanPref(prefs::kShow3gPromoNotification, value);
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns prefs::kCarrierDealPromoShown which is number of times
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// carrier deal notification has been shown to users on this machine.
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int GetCarrierDealPromoShown() {
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return GetIntegerLocalPref(prefs::kCarrierDealPromoShown);
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetCarrierDealPromoShown(int value) {
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SetIntegerLocalPref(prefs::kCarrierDealPromoShown, value);
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const chromeos::MobileConfig::Carrier* GetCarrier(
863551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    const NetworkState* cellular) {
873551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      GetDeviceState(cellular->device_path());
893551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::string carrier_id = device ? device->home_provider_id() : "";
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (carrier_id.empty()) {
913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    NET_LOG_ERROR("Empty carrier ID for cellular network",
923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                  device ? device->path(): "No device");
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return NULL;
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance();
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!config->IsReady())
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return NULL;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return config->GetCarrier(carrier_id);
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const chromeos::MobileConfig::CarrierDeal* GetCarrierDeal(
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const chromeos::MobileConfig::Carrier* carrier) {
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const chromeos::MobileConfig::CarrierDeal* deal = carrier->GetDefaultDeal();
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (deal) {
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Check deal for validity.
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    int carrier_deal_promo_pref = GetCarrierDealPromoShown();
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (carrier_deal_promo_pref >= deal->notification_count())
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return NULL;
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const std::string locale = g_browser_process->GetApplicationLocale();
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string deal_text = deal->GetLocalizedString(locale,
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                                     "notification_text");
1143551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    NET_LOG_DEBUG("Carrier Deal Found", deal_text);
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    if (deal_text.empty())
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return NULL;
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return deal;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1213551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void NotificationClicked(const std::string& service_path,
1223551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                         const std::string& info_url) {
1233551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (info_url.empty())
1243551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    ash::network_connect::ShowNetworkSettings(service_path);
1253551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetPrimaryUserProfile(),
1283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      chrome::HOST_DESKTOP_TYPE_ASH);
1290f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  chrome::ShowSingletonTab(displayer.browser(), GURL(info_url));
1303551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1323551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}  // namespace
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////////
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// DataPromoNotification
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)DataPromoNotification::DataPromoNotification()
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : check_for_promo_(true),
139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      weak_ptr_factory_(this) {
1403551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)DataPromoNotification::~DataPromoNotification() {
1443551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (NetworkHandler::IsInitialized()) {
1453551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    NetworkHandler::Get()->network_state_handler()->RemoveObserver(
1463551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)        this, FROM_HERE);
1473551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  }
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void DataPromoNotification::RegisterPrefs(PrefRegistrySimple* registry) {
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Carrier deal notification shown count defaults to 0.
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  registry->RegisterIntegerPref(prefs::kCarrierDealPromoShown, 0);
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1553551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void DataPromoNotification::NetworkPropertiesUpdated(
1563551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    const NetworkState* network) {
15768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  if (!network || network->type() != shill::kTypeCellular)
1583551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return;
1593551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  ShowOptionalMobileDataPromoNotification();
1603551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
1613551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1623551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void DataPromoNotification::DefaultNetworkChanged(const NetworkState* network) {
1633551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // Call NetworkPropertiesUpdated in case the Cellular network became the
1643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // default network.
1653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  NetworkPropertiesUpdated(network);
1663551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
1673551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1683551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void DataPromoNotification::ShowOptionalMobileDataPromoNotification() {
1693551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // Display a one-time notification for authenticated users on first use
1703551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // of Mobile Data connection or if there is a carrier deal defined
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // show that even if user has already seen generic promo.
1723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (!check_for_promo_ || !LoginState::Get()->IsUserAuthenticated())
1733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return;
1743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const NetworkState* default_network =
1753551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
17668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  if (!default_network || default_network->type() != shill::kTypeCellular)
1773551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return;
1783551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  // When requesting a network connection, do not show the notification.
1793551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (NetworkHandler::Get()->network_connection_handler()->
1803551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      HasPendingConnectRequest())
1813551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return;
1823551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1833551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  int carrier_deal_promo_pref = kNotificationCountPrefDefault;
1843551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const MobileConfig::CarrierDeal* deal = NULL;
1853551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const MobileConfig::Carrier* carrier = GetCarrier(default_network);
1863551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (carrier)
1873551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    deal = GetCarrierDeal(carrier);
1883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::string16 message =
1901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      l10n_util::GetStringUTF16(IDS_3G_NOTIFICATION_MESSAGE);
1913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::string info_url;
1923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (deal) {
1933551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    carrier_deal_promo_pref = GetCarrierDealPromoShown();
1943551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    const std::string locale = g_browser_process->GetApplicationLocale();
1953551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    std::string deal_text =
1963551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)        deal->GetLocalizedString(locale, "notification_text");
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    message = base::UTF8ToUTF16(deal_text + "\n\n") + message;
1983551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    info_url = deal->info_url();
1993551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    if (info_url.empty() && carrier)
2003551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      info_url = carrier->top_up_url();
2013551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  } else if (!ShouldShow3gPromoNotification()) {
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    check_for_promo_ = false;
2033551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return;
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  int icon_id;
20768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  if (default_network->network_technology() == shill::kNetworkTechnologyLte)
2083551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE;
2093551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  else
2103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G;
2113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const gfx::Image& icon =
2123551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
2133551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
2143551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  message_center::MessageCenter::Get()->AddNotification(
2153551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)      message_center::Notification::CreateSystemNotification(
2163551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)          ash::network_connect::kNetworkActivateNotificationId,
2173551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)          base::string16() /* title */,
2183551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)          message,
2193551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)          icon,
220a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)          ash::system_notifier::kNotifierNetwork,
2213551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)          base::Bind(&NotificationClicked,
2223551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                     default_network->path(), info_url)));
2233551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
2243551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  check_for_promo_ = false;
2253551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  SetShow3gPromoNotification(false);
2263551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (carrier_deal_promo_pref != kNotificationCountPrefDefault)
2273551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    SetCarrierDealPromoShown(carrier_deal_promo_pref + 1);
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace chromeos
231