Enable device discovery notifications.

Add kill switch for notifications.
Disabled notifications for task manager test.

BUG=286157
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/23903024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222238 0039d316-1c4b-4281-b951-d872f2087c98
parent 58dd13d6
......@@ -5465,6 +5465,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_DESCRIPTION" desc="Description for 'disable device discovery' flag.">
Disable device discovery on local network.
</message>
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_NAME" desc="Title of the disable 'disable device discovery notificatios' flag.">
Disable Device Discovery Notifications
</message>
<message name="IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_DESCRIPTION" desc="Description for 'disable device discovery notifications' flag.">
Disable device discovery notifications on local network.
</message>
<message name="IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME" desc="Title of the touch-optimized UI flag." >
Touch Optimized UI
</message>
......
......@@ -1476,6 +1476,7 @@ const Experiment kExperiments[] = {
kOsAll,
SINGLE_VALUE_TYPE(switches::kSyncfsEnableDirectoryOperation),
},
#if defined(ENABLE_MDNS)
{
"disable-device-discovery",
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NAME,
......@@ -1483,6 +1484,14 @@ const Experiment kExperiments[] = {
kOsWin | kOsLinux | kOsCrOS,
SINGLE_VALUE_TYPE(switches::kDisableDeviceDiscovery)
},
{
"disable-device-discovery-notifications",
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_NAME,
IDS_FLAGS_DISABLE_DEVICE_DISCOVERY_NOTIFICATIONS_DESCRIPTION,
kOsWin | kOsLinux | kOsCrOS,
SINGLE_VALUE_TYPE(switches::kDisableDeviceDiscoveryNotifications)
},
#endif // ENABLE_MDNS
#if defined(OS_MACOSX)
{
"enable-app-list-shim",
......
......@@ -8,6 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/local_discovery/privet_device_lister_impl.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/profiles/profile.h"
......@@ -148,10 +149,8 @@ PrivetNotificationsListener::DeviceContext::~DeviceContext() {
}
PrivetNotificationService::PrivetNotificationService(
content::BrowserContext* profile,
NotificationUIManager* notification_manager)
: profile_(profile),
notification_manager_(notification_manager) {
content::BrowserContext* profile)
: profile_(profile) {
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&PrivetNotificationService::Start, AsWeakPtr()),
......@@ -210,13 +209,15 @@ void PrivetNotificationService::PrivetNotify(
rich_notification_data,
new PrivetNotificationDelegate(device_name, profile_));
notification_manager_->Add(notification, profile_object);
g_browser_process->notification_ui_manager()->Add(notification,
profile_object);
}
}
void PrivetNotificationService::PrivetRemoveNotification(
const std::string& device_name) {
notification_manager_->CancelById(kPrivetNotificationIDPrefix + device_name);
g_browser_process->notification_ui_manager()->CancelById(
kPrivetNotificationIDPrefix + device_name);
}
void PrivetNotificationService::Start() {
......
......@@ -93,8 +93,7 @@ class PrivetNotificationService
public PrivetNotificationsListener::Delegate,
public base::SupportsWeakPtr<PrivetNotificationService> {
public:
PrivetNotificationService(content::BrowserContext* profile,
NotificationUIManager* notification_manager);
explicit PrivetNotificationService(content::BrowserContext* profile);
virtual ~PrivetNotificationService();
// PrivetDeviceLister::Delegate implementation:
......@@ -115,7 +114,6 @@ class PrivetNotificationService
void Start();
content::BrowserContext* profile_;
NotificationUIManager* notification_manager_;
scoped_ptr<PrivetDeviceLister> device_lister_;
scoped_refptr<ServiceDiscoveryHostClient> service_discovery_client_;
scoped_ptr<PrivetNotificationsListener> privet_notifications_listener_;
......
......@@ -29,16 +29,14 @@ PrivetNotificationServiceFactory::~PrivetNotificationServiceFactory() {
BrowserContextKeyedService*
PrivetNotificationServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return new PrivetNotificationService(
profile, g_browser_process->notification_ui_manager());
return new PrivetNotificationService(profile);
}
bool
PrivetNotificationServiceFactory::ServiceIsCreatedWithBrowserContext() const {
// TODO(vitalybuka): re-enable after fixing broken tests.
return false;
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableDeviceDiscovery);
CommandLine* command_line = CommandLine::ForCurrentProcess();
return !command_line->HasSwitch(switches::kDisableDeviceDiscovery) &&
!command_line->HasSwitch(switches::kDisableDeviceDiscoveryNotifications);
}
bool PrivetNotificationServiceFactory::ServiceIsNULLWhileTesting() const {
......
......@@ -104,6 +104,9 @@ class TaskManagerBrowserTest : public ExtensionBrowserTest {
// well defined.
command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
// Do not launch device discovery process.
command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications);
}
private:
......
......@@ -323,6 +323,10 @@ const char kDisableDefaultApps[] = "disable-default-apps";
// Disables device discovery.
const char kDisableDeviceDiscovery[] = "disable-device-discovery";
// Disables device discovery notifications.
const char kDisableDeviceDiscoveryNotifications[] =
"disable-device-discovery-notifications";
// Disables retrieval of PAC URLs from DHCP as per the WPAD standard.
const char kDisableDhcpWpad[] = "disable-dhcp-wpad";
......
......@@ -99,6 +99,7 @@ extern const char kDisableCRLSets[];
extern const char kDisableCustomJumpList[];
extern const char kDisableDefaultApps[];
extern const char kDisableDeviceDiscovery[];
extern const char kDisableDeviceDiscoveryNotifications[];
extern const char kDisableDhcpWpad[];
extern const char kDisableDnsProbes[];
extern const char kDisableExtensionsFileAccessCheck[];
......
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