diff options
-rw-r--r-- | chrome/app/chromeos_strings.grdp | 6 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 9 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 22 | ||||
-rw-r--r-- | chrome/browser/chromeos/preferences.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/data_promo_notification.cc | 127 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/data_promo_notification.h | 8 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.cc | 1 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.h | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 | ||||
-rw-r--r-- | chromeos/chromeos_switches.cc | 5 | ||||
-rw-r--r-- | chromeos/chromeos_switches.h | 3 | ||||
-rw-r--r-- | tools/metrics/histograms/histograms.xml | 2 | ||||
-rw-r--r-- | ui/chromeos/resources/default_100_percent/network/notification_datasaver.png | bin | 0 -> 4488 bytes | |||
-rw-r--r-- | ui/chromeos/resources/default_200_percent/network/notification_datasaver.png | bin | 0 -> 6917 bytes | |||
-rw-r--r-- | ui/chromeos/resources/ui_chromeos_resources.grd | 1 |
16 files changed, 178 insertions, 20 deletions
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 922abf0..de7b0f3 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp @@ -5648,6 +5648,12 @@ All users must sign out to continue. <message name="IDS_3G_NOTIFICATION_MESSAGE" desc="Text of the 3G data notification telling that 3G data is enabled."> Google Chrome will use mobile data if you're not connected to another network. </message> + <message name="IDS_3G_DATASAVER_TITLE" desc="Title of the 3G data notification prompting user to install Data Saver."> + You are using mobile data + </message> + <message name="IDS_3G_DATASAVER_MESSAGE" desc="Text of the 3G data notification prompting user to install Data Saver."> + Save data and browse faster using Google Data Saver. Click to learn more. + </message> <!-- chrome://mobilesetup strings --> <message name="IDS_MOBILE_SETUP_TITLE" desc="ChromeOS mobile device activation page title"> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 7c36636..bff006f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6980,6 +6980,15 @@ Keep your key file in a safe place. You will need it to create new versions of y Enables compositing with an addition of one hardware overlay when possible. </message> </if> + <message name="IDS_FLAGS_DATASAVER_PROMPT_NAME" desc="Title for the flag to enable a prompt to install Data Saver when a cellular network is detected."> + Enable cellular Data Saver Prompt. + </message> + <message name="IDS_FLAGS_DATASAVER_PROMPT_DESCRIPTION" desc="Decription for the flag to enable a prompt to install Data Saver when a cellular network is detected."> + Enables a prompt, which appears when a cellular network connection is detected, to take the user to the Data Saver extension page on Chrome Web Store. + </message> + <message name="IDS_FLAGS_DATASAVER_PROMPT_DEMO_MODE" desc="The value of the Data Saver prompt flag which always shows prompt on network properties change."> + Demo mode + </message> <!-- Crashes --> <message name="IDS_CRASHES_TITLE" desc="Title for the chrome://crashes page."> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index ad25f94..1e64b83 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -425,6 +425,19 @@ const Experiment::Choice kAshScreenRotationAnimationChoices[] = { }; #endif +#if defined(OS_CHROMEOS) +const Experiment::Choice kDataSaverPromptChoices[] = { + { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, + { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, + chromeos::switches::kDisableDataSaverPrompt, "" }, + { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, + chromeos::switches::kEnableDataSaverPrompt, "" }, + { IDS_FLAGS_DATASAVER_PROMPT_DEMO_MODE, + chromeos::switches::kEnableDataSaverPrompt, + chromeos::switches::kDataSaverPromptDemoMode }, +}; +#endif + // RECORDING USER METRICS FOR FLAGS: // ----------------------------------------------------------------------------- // The first line of the experiment is the internal name. If you'd like to @@ -2319,6 +2332,15 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(chromeos::switches::kEnableMtpWriteSupport) }, #endif // defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) + { + "enable-datasaver-prompt", + IDS_FLAGS_DATASAVER_PROMPT_NAME, + IDS_FLAGS_DATASAVER_PROMPT_DESCRIPTION, + kOsCrOS, + MULTI_VALUE_TYPE(kDataSaverPromptChoices) + }, +#endif // defined(OS_CHROMEOS) // NOTE: Adding new command-line switches requires adding corresponding // entries to enum "LoginCustomFlags" in histograms.xml. See note in // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test. diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index d181107..e0cb1f5 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -292,6 +292,12 @@ void Preferences::RegisterProfilePrefs( true, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); + // Number of times Data Saver prompt has been shown on 3G data network. + registry->RegisterIntegerPref( + prefs::kDataSaverPromptsShown, + 0, + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); + // Initially all existing users would see "What's new" for current version // after update. registry->RegisterStringPref(prefs::kChromeOSReleaseNotesVersion, diff --git a/chrome/browser/chromeos/status/data_promo_notification.cc b/chrome/browser/chromeos/status/data_promo_notification.cc index 821e95a..dd36d0d 100644 --- a/chrome/browser/chromeos/status/data_promo_notification.cc +++ b/chrome/browser/chromeos/status/data_promo_notification.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/status/data_promo_notification.h" #include "ash/system/system_notifier.h" +#include "base/command_line.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" @@ -17,14 +18,17 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/ui/singleton_tabs.h" +#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" +#include "chromeos/chromeos_switches.h" #include "chromeos/login/login_state.h" #include "chromeos/network/device_state.h" #include "chromeos/network/network_connection_handler.h" #include "chromeos/network/network_event_log.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" +#include "extensions/browser/extension_registry.h" #include "grit/ui_chromeos_resources.h" #include "third_party/cros_system_api/dbus/service_constants.h" #include "ui/base/l10n/l10n_util.h" @@ -41,8 +45,13 @@ namespace chromeos { namespace { const char kDataPromoNotificationId[] = "chrome://settings/internet/data_promo"; +const char kDataSaverNotificationId[] = "chrome://settings/internet/data_saver"; +const char kDataSaverExtensionUrl[] = + "https://chrome.google.com/webstore/detail/" + "pfmgfdlgomnbgkofeojodiodmgpgmkac"; const int kNotificationCountPrefDefault = -1; +const int kTimesToShowDataSaverPrompt = 2; bool GetBooleanPref(const char* pref_name) { Profile* profile = ProfileManager::GetPrimaryUserProfile(); @@ -85,6 +94,41 @@ void SetCarrierDealPromoShown(int value) { SetIntegerLocalPref(prefs::kCarrierDealPromoShown, value); } +// Returns number of times the Data Saver prompt has been displayed. +int GetDataSaverPromptsShown() { + return ProfileManager::GetActiveUserProfile()->GetPrefs()->GetInteger( + prefs::kDataSaverPromptsShown); +} + +// Updates number of times the Data Saver prompt has been displayed. +void SetDataSaverPromptsShown(int times_shown) { + ProfileManager::GetActiveUserProfile()->GetPrefs()->SetInteger( + prefs::kDataSaverPromptsShown, times_shown); +} + +// Is command line switch set for Data Saver prompt? +bool DataSaverSwitchEnabled() { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kDisableDataSaverPrompt)) + return false; + + return base::CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kEnableDataSaverPrompt); +} + +// Is command line switch set for Data Saver demo mode, where we show the prompt +// after any change in network properties? +bool DataSaverSwitchDemoMode() { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + chromeos::switches::kDisableDataSaverPrompt)) + return false; + + const std::string value = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + chromeos::switches::kEnableDataSaverPrompt); + return value == chromeos::switches::kDataSaverPromptDemoMode; +} + const chromeos::MobileConfig::Carrier* GetCarrier( const NetworkState* cellular) { const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> @@ -123,13 +167,13 @@ const chromeos::MobileConfig::CarrierDeal* GetCarrierDeal( void NotificationClicked(const std::string& service_path, const std::string& info_url) { - if (info_url.empty()) + if (!info_url.empty()) { + chrome::ScopedTabbedBrowserDisplayer displayer( + ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); + chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); + } else { ui::NetworkConnect::Get()->ShowNetworkSettingsForPath(service_path); - - chrome::ScopedTabbedBrowserDisplayer displayer( - ProfileManager::GetPrimaryUserProfile(), - chrome::HOST_DESKTOP_TYPE_ASH); - chrome::ShowSingletonTab(displayer.browser(), GURL(info_url)); + } } } // namespace @@ -138,7 +182,7 @@ void NotificationClicked(const std::string& service_path, // DataPromoNotification DataPromoNotification::DataPromoNotification() - : check_for_promo_(true), + : notifications_shown_(false), weak_ptr_factory_(this) { NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE); } @@ -157,7 +201,8 @@ void DataPromoNotification::RegisterPrefs(PrefRegistrySimple* registry) { void DataPromoNotification::NetworkPropertiesUpdated( const NetworkState* network) { - if (!network || network->type() != shill::kTypeCellular) + if (!network || + (network->type() != shill::kTypeCellular && !DataSaverSwitchDemoMode())) return; ShowOptionalMobileDataPromoNotification(); } @@ -169,20 +214,28 @@ void DataPromoNotification::DefaultNetworkChanged(const NetworkState* network) { } void DataPromoNotification::ShowOptionalMobileDataPromoNotification() { - // Display a one-time notification for authenticated users on first use - // of Mobile Data connection or if there is a carrier deal defined - // show that even if user has already seen generic promo. - if (!check_for_promo_ || !LoginState::Get()->IsUserAuthenticated()) + // Do not show notifications to unauthenticated users, or when requesting a + // network connection, or if there's no default_network. + if (!LoginState::Get()->IsUserAuthenticated()) return; const NetworkState* default_network = NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); - if (!default_network || default_network->type() != shill::kTypeCellular) + if (!default_network) return; - // When requesting a network connection, do not show the notification. if (NetworkHandler::Get()->network_connection_handler()-> HasPendingConnectRequest()) return; + if (!DataSaverSwitchDemoMode() && + (notifications_shown_ || default_network->type() != shill::kTypeCellular)) + return; + + notifications_shown_ = true; + bool data_saver_prompt_shown = ShowDataSaverNotification(); + + // Display a one-time notification on first use of Mobile Data connection, or + // if there is a carrier deal defined show that even if user has already seen + // generic promo. Show deal regardless of |data_saver_prompt_shown|. int carrier_deal_promo_pref = kNotificationCountPrefDefault; const MobileConfig::CarrierDeal* deal = NULL; const MobileConfig::Carrier* carrier = GetCarrier(default_network); @@ -201,8 +254,7 @@ void DataPromoNotification::ShowOptionalMobileDataPromoNotification() { info_url = deal->info_url(); if (info_url.empty() && carrier) info_url = carrier->top_up_url(); - } else if (!ShouldShow3gPromoNotification()) { - check_for_promo_ = false; + } else if (data_saver_prompt_shown || !ShouldShow3gPromoNotification()) { return; } @@ -220,10 +272,51 @@ void DataPromoNotification::ShowOptionalMobileDataPromoNotification() { ui::NetworkStateNotifier::kNotifierNetwork, base::Bind(&NotificationClicked, default_network->path(), info_url))); - check_for_promo_ = false; SetShow3gPromoNotification(false); if (carrier_deal_promo_pref != kNotificationCountPrefDefault) SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); } +bool DataPromoNotification::ShowDataSaverNotification() { + if (!DataSaverSwitchEnabled()) + return false; + + if (message_center::MessageCenter::Get()->FindVisibleNotificationById( + kDataSaverNotificationId)) // already showing. + return true; + + int times_shown = GetDataSaverPromptsShown(); + if (!DataSaverSwitchDemoMode() && times_shown >= kTimesToShowDataSaverPrompt) + return false; + + if (extensions::ExtensionRegistry::Get(ProfileManager::GetActiveUserProfile()) + ->GetExtensionById(extension_misc::kDataSaverExtensionId, + extensions::ExtensionRegistry::EVERYTHING)) { + // If extension is installed, disable future prompts. + SetDataSaverPromptsShown(kTimesToShowDataSaverPrompt); + return false; + } + + base::string16 title = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_TITLE); + base::string16 message = l10n_util::GetStringUTF16(IDS_3G_DATASAVER_MESSAGE); + const gfx::Image& icon = + ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_AURA_UBER_TRAY_NOTIFICATION_DATASAVER); + + message_center::MessageCenter::Get()->AddNotification( + message_center::Notification::CreateSystemNotification( + kDataSaverNotificationId, title, message, icon, + ui::NetworkStateNotifier::kNotifierNetwork, + base::Bind(&NotificationClicked, "", kDataSaverExtensionUrl))); + + if (DataSaverSwitchDemoMode()) { + SetDataSaverPromptsShown(0); // demo mode resets times shown counts. + SetShow3gPromoNotification(true); + } else { + SetDataSaverPromptsShown(times_shown + 1); + } + + return true; +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/status/data_promo_notification.h b/chrome/browser/chromeos/status/data_promo_notification.h index def5e8e..88a58fd 100644 --- a/chrome/browser/chromeos/status/data_promo_notification.h +++ b/chrome/browser/chromeos/status/data_promo_notification.h @@ -37,9 +37,11 @@ class DataPromoNotification : public NetworkStateHandlerObserver { // Shows 3G promo notification if needed. void ShowOptionalMobileDataPromoNotification(); - // True if check for promo needs to be done, otherwise ignore it for the - // current session. - bool check_for_promo_; + // Show notification prompting user to install Data Saver extension. + bool ShowDataSaverNotification(); + + // True if we've shown notifications during this session, or won't need to. + bool notifications_shown_; // Factory for delaying showing promo notification. base::WeakPtrFactory<DataPromoNotification> weak_ptr_factory_; diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index 23a88df..41dfa45 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -30,6 +30,7 @@ namespace extension_misc { const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno"; const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf"; const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng"; +const char kDataSaverExtensionId[] = "pfmgfdlgomnbgkofeojodiodmgpgmkac"; const char kEasyUnlockAppId[] = "mkaemigholebcgchlkbankmihknojeak"; const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa"; const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia"; diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index e97794a..b368a7d 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -37,6 +37,9 @@ extern const char kChromeAppId[]; // The extension id of the Cloud Print component application. extern const char kCloudPrintAppId[]; +// The extension id of the Data Saver extension. +extern const char kDataSaverExtensionId[]; + // The extension id of the Easy Unlock component application. extern const char kEasyUnlockAppId[]; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index fb50cb1..bd6bd52 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -615,6 +615,10 @@ const char kShowPlanNotifications[] = const char kShow3gPromoNotification[] = "settings.internet.mobile.show_3g_promo_notification"; +// An integer pref counting times Data Saver prompt has been shown. +const char kDataSaverPromptsShown[] = + "settings.internet.mobile.datasaver_prompts_shown"; + // A string pref that contains version where "What's new" promo was shown. const char kChromeOSReleaseNotesVersion[] = "settings.release_notes.version"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 2d4724e..b44ea9f 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -219,6 +219,7 @@ extern const char kLabsMediaplayerEnabled[]; extern const char kEnableAutoScreenLock[]; extern const char kShowPlanNotifications[]; extern const char kShow3gPromoNotification[]; +extern const char kDataSaverPromptsShown[]; extern const char kChromeOSReleaseNotesVersion[]; extern const char kUseSharedProxies[]; extern const char kDisplayPowerState[]; diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index ea79992..f1eea58 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -342,6 +342,11 @@ const char kEnableFirewallHolePunching[] = "enable-firewall-hole-punching"; // handle the plugged in printer. const char kEnablePrinterAppSearch[] = "enable-printer-app-search"; +// Switches and optional value for Data Saver prompt on cellular networks. +const char kDisableDataSaverPrompt[] = "disable-datasaver-prompt"; +const char kEnableDataSaverPrompt[] = "enable-datasaver-prompt"; +const char kDataSaverPromptDemoMode[] = "demo"; + bool WakeOnWifiEnabled() { return !base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableWakeOnWifi); } diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 6a29218..fe57af8 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -111,6 +111,9 @@ CHROMEOS_EXPORT extern const char kWakeOnPackets[]; CHROMEOS_EXPORT extern const char kDisableCaptivePortalBypassProxy[]; CHROMEOS_EXPORT extern const char kDisableTimeZoneTrackingOption[]; CHROMEOS_EXPORT extern const char kDisableWebviewSigninFlow[]; +CHROMEOS_EXPORT extern const char kDisableDataSaverPrompt[]; +CHROMEOS_EXPORT extern const char kEnableDataSaverPrompt[]; +CHROMEOS_EXPORT extern const char kDataSaverPromptDemoMode[]; CHROMEOS_EXPORT bool WakeOnWifiEnabled(); diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index afcf189..6c170c4 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -54061,12 +54061,14 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="-1341092934" label="enable-accelerated-overflow-scroll"/> <int value="-1340055960" label="enable-streamlined-hosted-apps"/> <int value="-1334327410" label="ash-enable-touch-view-testing"/> + <int value="-1322882747" label="disable-datasaver-prompt"/> <int value="-1319688939" label="ignore-gpu-blacklist"/> <int value="-1285021473" label="save-page-as-mhtml"/> <int value="-1268836676" label="disable-out-of-process-pdf"/> <int value="-1267958145" label="disable-pdf-material-ui"/> <int value="-1251411236" label="disable-new-md-input-view"/> <int value="-1241747717" label="enable-android-password-link"/> + <int value="-1235586511" label="enable-datasaver-prompt"/> <int value="-1218608640" label="disable-offline-load-stale-cache"/> <int value="-1216837777" label="clear-data-reduction-proxy-data-savings"/> <int value="-1212273428" label="enable-experimental-app-list"/> diff --git a/ui/chromeos/resources/default_100_percent/network/notification_datasaver.png b/ui/chromeos/resources/default_100_percent/network/notification_datasaver.png Binary files differnew file mode 100644 index 0000000..2e9a3aa --- /dev/null +++ b/ui/chromeos/resources/default_100_percent/network/notification_datasaver.png diff --git a/ui/chromeos/resources/default_200_percent/network/notification_datasaver.png b/ui/chromeos/resources/default_200_percent/network/notification_datasaver.png Binary files differnew file mode 100644 index 0000000..7f5be0f --- /dev/null +++ b/ui/chromeos/resources/default_200_percent/network/notification_datasaver.png diff --git a/ui/chromeos/resources/ui_chromeos_resources.grd b/ui/chromeos/resources/ui_chromeos_resources.grd index f557091..adf6709 100644 --- a/ui/chromeos/resources/ui_chromeos_resources.grd +++ b/ui/chromeos/resources/ui_chromeos_resources.grd @@ -46,6 +46,7 @@ <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE" file="network/statusbar_network_vpn_badge.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_WIRED" file="network/statusbar_wired.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_3G" file="network/notification_3g.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_DATASAVER" file="network/notification_datasaver.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_LTE" file="network/notification_lte.png" /> <!-- Default user profile images. --> |