Commit 7e01241f authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

Add Tether to list of ash system notifiers.

Without being a system notifier, 
MultiUserNotificationBlockerChromeOS::ShouldShowNotification()
returns false, preventing Tether notifications from
displaying. It's appropriate to consider Tether a system 
notifier given that it is baked into the system tray and 
Settings.

Bug: 747639, 672263
Change-Id: I0f0d9a4ce3da7c62b148af979c611eaca6682053
Reviewed-on: https://chromium-review.googlesource.com/596833
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491416}
parent fcfda5c1
......@@ -32,7 +32,8 @@ const char* kAshSystemNotifiers[] = {
kNotifierDisk, kNotifierLocale, kNotifierMultiProfileFirstRun,
kNotifierNetwork, kNotifierNetworkPortalDetector, kNotifierScreenshot,
kNotifierScreenCapture, kNotifierScreenShare, kNotifierSessionLengthTimeout,
kNotifierSms, kNotifierSupervisedUser, kNotifierWebUsb, kNotifierWifiToggle,
kNotifierSms, kNotifierSupervisedUser, kNotifierTether, kNotifierWebUsb,
kNotifierWifiToggle,
// Note: Order doesn't matter here, so keep this in alphabetic order, don't
// just add your stuff at the end!
NULL};
......@@ -76,6 +77,7 @@ const char kNotifierScreenShare[] = "ash.screen-share";
const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
const char kNotifierSms[] = "ash.sms";
const char kNotifierSupervisedUser[] = "ash.locally-managed-user";
const char kNotifierTether[] = "ash.tether";
const char kNotifierWebUsb[] = "ash.webusb";
const char kNotifierWifiToggle[] = "ash.wifi-toggle";
......
......@@ -39,6 +39,7 @@ ASH_EXPORT extern const char kNotifierScreenShare[];
ASH_EXPORT extern const char kNotifierSessionLengthTimeout[];
ASH_EXPORT extern const char kNotifierSms[];
ASH_EXPORT extern const char kNotifierSupervisedUser[];
ASH_EXPORT extern const char kNotifierTether[];
ASH_EXPORT extern const char kNotifierWebUsb[];
ASH_EXPORT extern const char kNotifierWifiToggle[];
......
......@@ -17,4 +17,7 @@ specific_include_rules = {
"+ash/system/system_notifier.h",
"+ash/resources/grit/ash_resources.h",
],
"tether_notification_presenter\.cc": [
"+ash/system/system_notifier.h",
],
}
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/net/tether_notification_presenter.h"
#include "ash/system/system_notifier.h"
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
......@@ -54,11 +55,39 @@ int GetNormalizedSignalStrength(int signal_strength) {
return std::min(std::max(normalized_signal_strength, 0), 4);
}
} // namespace
std::unique_ptr<message_center::Notification> CreateNotification(
const std::string& id,
const base::string16& title,
const base::string16& message,
const message_center::RichNotificationData rich_notification_data,
int signal_strength) {
auto source = base::MakeUnique<ash::network_icon::SignalStrengthImageSource>(
ash::network_icon::BARS, gfx::kGoogleBlue500, kTetherSignalIconSize,
GetNormalizedSignalStrength(signal_strength));
std::unique_ptr<message_center::Notification> notification =
base::MakeUnique<message_center::Notification>(
message_center::NotificationType::NOTIFICATION_TYPE_SIMPLE, id, title,
message,
gfx::Image(gfx::ImageSkia(std::move(source), kTetherSignalIconSize)),
base::string16() /* display_source */, GURL() /* origin_url */,
message_center::NotifierId(
message_center::NotifierId::NotifierType::SYSTEM_COMPONENT,
ash::system_notifier::kNotifierTether),
rich_notification_data, nullptr);
notification->SetSystemPriority();
return notification;
}
// static
constexpr const char TetherNotificationPresenter::kTetherNotifierId[] =
"cros_tether_notification_ids.notifier_id";
std::unique_ptr<message_center::Notification>
CreateNotificationWithMediumSignalStrengthIcon(const std::string& id,
const base::string16& title,
const base::string16& message) {
return CreateNotification(id, title, message,
message_center::RichNotificationData(),
kMediumSignalStrength);
}
} // namespace
// static
constexpr const char TetherNotificationPresenter::kActiveHostNotificationId[] =
......@@ -82,44 +111,10 @@ constexpr const char
// static
constexpr const char* const
TetherNotificationPresenter::kIdsWhichOpenTetherSettingsOnClick[] = {
TetherNotificationPresenter::kTetherNotifierId,
TetherNotificationPresenter::kActiveHostNotificationId,
TetherNotificationPresenter::kPotentialHotspotNotificationId,
TetherNotificationPresenter::kSetupRequiredNotificationId};
// static
std::unique_ptr<message_center::Notification>
TetherNotificationPresenter::CreateNotificationWithMediumSignalStrengthIcon(
const std::string& id,
const base::string16& title,
const base::string16& message) {
return CreateNotification(id, title, message,
message_center::RichNotificationData(),
kMediumSignalStrength);
}
// static
std::unique_ptr<message_center::Notification>
TetherNotificationPresenter::CreateNotification(
const std::string& id,
const base::string16& title,
const base::string16& message,
const message_center::RichNotificationData rich_notification_data,
int signal_strength) {
auto source = base::MakeUnique<ash::network_icon::SignalStrengthImageSource>(
ash::network_icon::BARS, gfx::kGoogleBlue500, kTetherSignalIconSize,
GetNormalizedSignalStrength(signal_strength));
return base::MakeUnique<message_center::Notification>(
message_center::NotificationType::NOTIFICATION_TYPE_SIMPLE, id, title,
message,
gfx::Image(gfx::ImageSkia(std::move(source), kTetherSignalIconSize)),
base::string16() /* display_source */, GURL() /* origin_url */,
message_center::NotifierId(
message_center::NotifierId::NotifierType::SYSTEM_COMPONENT,
kTetherNotifierId),
rich_notification_data, nullptr);
}
TetherNotificationPresenter::TetherNotificationPresenter(
Profile* profile,
message_center::MessageCenter* message_center,
......
......@@ -73,8 +73,9 @@ class TetherNotificationPresenter
};
private:
friend class TetherNotificationPresenterTest;
// IDs associated with Tether notification types.
static const char kTetherNotifierId[];
static const char kPotentialHotspotNotificationId[];
static const char kActiveHostNotificationId[];
static const char kSetupRequiredNotificationId[];
......@@ -83,19 +84,6 @@ class TetherNotificationPresenter
// IDs of all notifications which, when clicked, open mobile data settings.
static const char* const kIdsWhichOpenTetherSettingsOnClick[];
static std::unique_ptr<message_center::Notification>
CreateNotificationWithMediumSignalStrengthIcon(const std::string& id,
const base::string16& title,
const base::string16& message);
static std::unique_ptr<message_center::Notification> CreateNotification(
const std::string& id,
const base::string16& title,
const base::string16& message,
const message_center::RichNotificationData rich_notification_data,
int signal_strength);
friend class TetherNotificationPresenterTest;
void SetSettingsUiDelegateForTesting(
std::unique_ptr<SettingsUiDelegate> settings_ui_delegate);
void ShowNotification(
......
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