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