Commit a4ae7da1 authored by Tony de Luna's avatar Tony de Luna Committed by Commit Bot

Rename DataPromoNotification to MobileDataNotifications

Notifications for displaying data promotions are no longer supported.

Class is now in charge of displaying mobile data warnings and prompts
user to install data saver extension.

BUG=910767

Change-Id: I74c45001158194788fb335be83e040b95e3271be
Reviewed-on: https://chromium-review.googlesource.com/c/1362211
Commit-Queue: Tony De Luna <tonydeluna@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616076}
parent 5479debf
......@@ -1399,10 +1399,10 @@ jumbo_split_static_library("ui") {
"ash/multi_user/multi_user_window_manager_client_impl.h",
"ash/multi_user/multi_user_window_manager_client_stub.cc",
"ash/multi_user/multi_user_window_manager_client_stub.h",
"ash/network/data_promo_notification.cc",
"ash/network/data_promo_notification.h",
"ash/network/enrollment_dialog_view.cc",
"ash/network/enrollment_dialog_view.h",
"ash/network/mobile_data_notifications.cc",
"ash/network/mobile_data_notifications.h",
"ash/network/network_connect_delegate_chromeos.cc",
"ash/network/network_connect_delegate_chromeos.h",
"ash/network/network_portal_notification_controller.cc",
......
......@@ -35,7 +35,7 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/ash/media_client.h"
#include "chrome/browser/ui/ash/network/data_promo_notification.h"
#include "chrome/browser/ui/ash/network/mobile_data_notifications.h"
#include "chrome/browser/ui/ash/network/network_connect_delegate_chromeos.h"
#include "chrome/browser/ui/ash/network/network_portal_notification_controller.h"
#include "chrome/browser/ui/ash/screen_orientation_delegate_chromeos.h"
......@@ -304,7 +304,7 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
}
void ChromeBrowserMainExtraPartsAsh::PostBrowserStart() {
data_promo_notification_ = std::make_unique<DataPromoNotification>();
mobile_data_notifications_ = std::make_unique<MobileDataNotifications>();
if (ash::features::IsNightLightEnabled()) {
night_light_client_ = std::make_unique<NightLightClient>(
......@@ -321,7 +321,7 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
#endif
night_light_client_.reset();
data_promo_notification_.reset();
mobile_data_notifications_.reset();
chrome_launcher_controller_initializer_.reset();
wallpaper_controller_client_.reset();
......
......@@ -37,11 +37,11 @@ class AshShellInit;
class CastConfigClientMediaRouter;
class ChromeNewWindowClient;
class ContainedShellClient;
class DataPromoNotification;
class ImeControllerClient;
class ImmersiveContextMus;
class LoginScreenClient;
class MediaClient;
class MobileDataNotifications;
class NetworkConnectDelegateChromeOS;
class NightLightClient;
class ScreenOrientationDelegateChromeos;
......@@ -125,7 +125,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<policy::DisplaySettingsHandler> display_settings_handler_;
// Initialized in PostBrowserStart in all configs:
std::unique_ptr<DataPromoNotification> data_promo_notification_;
std::unique_ptr<MobileDataNotifications> mobile_data_notifications_;
std::unique_ptr<NightLightClient> night_light_client_;
// Created for mash (both in single and multi-process).
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/network/data_promo_notification.h"
#include "chrome/browser/ui/ash/network/mobile_data_notifications.h"
#include <memory>
#include <string>
......@@ -139,21 +139,21 @@ void DisplayNotification(const std::string& notification_id,
} // namespace
////////////////////////////////////////////////////////////////////////////////
// DataPromoNotification
// MobileDataNotifications
DataPromoNotification::DataPromoNotification()
: notifications_shown_(false), weak_ptr_factory_(this) {
MobileDataNotifications::MobileDataNotifications()
: notifications_shown_(false) {
NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
}
DataPromoNotification::~DataPromoNotification() {
MobileDataNotifications::~MobileDataNotifications() {
if (NetworkHandler::IsInitialized()) {
NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
FROM_HERE);
}
}
void DataPromoNotification::NetworkPropertiesUpdated(
void MobileDataNotifications::NetworkPropertiesUpdated(
const NetworkState* network) {
if (!network ||
(network->type() != shill::kTypeCellular && !DataSaverSwitchDemoMode()))
......@@ -161,13 +161,14 @@ void DataPromoNotification::NetworkPropertiesUpdated(
ShowOptionalMobileDataNotification();
}
void DataPromoNotification::DefaultNetworkChanged(const NetworkState* network) {
void MobileDataNotifications::DefaultNetworkChanged(
const NetworkState* network) {
// Call NetworkPropertiesUpdated in case the Cellular network became the
// default network.
NetworkPropertiesUpdated(network);
}
void DataPromoNotification::ShowOptionalMobileDataNotification() {
void MobileDataNotifications::ShowOptionalMobileDataNotification() {
if (notifications_shown_)
return;
......@@ -216,7 +217,7 @@ void DataPromoNotification::ShowOptionalMobileDataNotification() {
}
}
bool DataPromoNotification::ShouldShowDataSaverNotification() {
bool MobileDataNotifications::ShouldShowDataSaverNotification() {
if (!DataSaverSwitchEnabled())
return false;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_NETWORK_DATA_PROMO_NOTIFICATION_H_
#define CHROME_BROWSER_UI_ASH_NETWORK_DATA_PROMO_NOTIFICATION_H_
#ifndef CHROME_BROWSER_UI_ASH_NETWORK_MOBILE_DATA_NOTIFICATIONS_H_
#define CHROME_BROWSER_UI_ASH_NETWORK_MOBILE_DATA_NOTIFICATIONS_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
......@@ -14,10 +14,10 @@
// * "Chrome will use mobile data..." when cellular is the default network
// for the first time in a session.
// * Prompt users to install data saver extension.
class DataPromoNotification : public chromeos::NetworkStateHandlerObserver {
class MobileDataNotifications : public chromeos::NetworkStateHandlerObserver {
public:
DataPromoNotification();
~DataPromoNotification() override;
MobileDataNotifications();
~MobileDataNotifications() override;
private:
// NetworkStateHandlerObserver
......@@ -35,10 +35,7 @@ class DataPromoNotification : public chromeos::NetworkStateHandlerObserver {
// mobile notifications once per session.
bool notifications_shown_;
// Factory for delaying showing promo notification.
base::WeakPtrFactory<DataPromoNotification> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DataPromoNotification);
DISALLOW_COPY_AND_ASSIGN(MobileDataNotifications);
};
#endif // CHROME_BROWSER_UI_ASH_NETWORK_DATA_PROMO_NOTIFICATION_H_
#endif // CHROME_BROWSER_UI_ASH_NETWORK_MOBILE_DATA_NOTIFICATIONS_H_
......@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/network/data_promo_notification.h"
#include "chrome/browser/ui/ash/network/mobile_data_notifications.h"
#include <memory>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/macros.h"
......@@ -54,10 +58,10 @@ class NetworkConnectTestDelegate : public chromeos::NetworkConnect::Delegate {
DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate);
};
class DataPromoNotificationTest : public testing::Test {
class MobileDataNotificationsTest : public testing::Test {
public:
DataPromoNotificationTest() {}
~DataPromoNotificationTest() override {}
MobileDataNotificationsTest() {}
~MobileDataNotificationsTest() override {}
void SetUp() override {
testing::Test::SetUp();
......@@ -65,7 +69,7 @@ class DataPromoNotificationTest : public testing::Test {
chromeos::switches::kEnableDataSaverPrompt);
DBusThreadManager::Initialize();
chromeos::NetworkHandler::Initialize();
data_promo_notification_.reset(new DataPromoNotification);
mobile_data_notifications_.reset(new MobileDataNotifications);
SetupUser();
SetupNetworkShillState();
base::RunLoop().RunUntilIdle();
......@@ -79,7 +83,7 @@ class DataPromoNotificationTest : public testing::Test {
LoginState::Shutdown();
profile_manager_.reset();
user_manager_enabler_.reset();
data_promo_notification_.reset();
mobile_data_notifications_.reset();
chromeos::NetworkHandler::Shutdown();
DBusThreadManager::Shutdown();
testing::Test::TearDown();
......@@ -142,17 +146,17 @@ class DataPromoNotificationTest : public testing::Test {
}
content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<DataPromoNotification> data_promo_notification_;
std::unique_ptr<MobileDataNotifications> mobile_data_notifications_;
std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_;
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
std::unique_ptr<TestingProfileManager> profile_manager_;
std::unique_ptr<NotificationDisplayServiceTester> display_service_;
private:
DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest);
DISALLOW_COPY_AND_ASSIGN(MobileDataNotificationsTest);
};
TEST_F(DataPromoNotificationTest, DataSaverNotification) {
TEST_F(MobileDataNotificationsTest, DataSaverNotification) {
// Network setup shouldn't be enough to activate notification.
EXPECT_FALSE(display_service_->GetNotification(kNotificationId));
......
......@@ -3497,7 +3497,7 @@ test("unit_tests") {
"../browser/ui/ash/multi_user/multi_user_context_menu_chromeos_unittest.cc",
"../browser/ui/ash/multi_user/multi_user_util_chromeos_unittest.cc",
"../browser/ui/ash/multi_user/multi_user_window_manager_client_impl_unittest.cc",
"../browser/ui/ash/network/data_promo_notification_unittest.cc",
"../browser/ui/ash/network/mobile_data_notifications_unittest.cc",
"../browser/ui/ash/network/network_portal_notification_controller_unittest.cc",
"../browser/ui/ash/network/network_state_notifier_unittest.cc",
"../browser/ui/ash/network/tether_notification_presenter_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment