diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 09:21:39 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 09:21:39 +0000 |
commit | 265415dfb20d0bc9e34b75fc76eb36a6f2c74cf7 (patch) | |
tree | 623be9a966db5c094abe3682fac6eba64295dd98 | |
parent | 58dd13d618fb81ea689ffb62ff3fbba01ac37628 (diff) | |
download | chromium_src-265415dfb20d0bc9e34b75fc76eb36a6f2c74cf7.zip chromium_src-265415dfb20d0bc9e34b75fc76eb36a6f2c74cf7.tar.gz chromium_src-265415dfb20d0bc9e34b75fc76eb36a6f2c74cf7.tar.bz2 |
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
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 9 | ||||
-rw-r--r-- | chrome/browser/local_discovery/privet_notifications.cc | 13 | ||||
-rw-r--r-- | chrome/browser/local_discovery/privet_notifications.h | 4 | ||||
-rw-r--r-- | chrome/browser/local_discovery/privet_notifications_factory.cc | 10 | ||||
-rw-r--r-- | chrome/browser/task_manager/task_manager_browsertest.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
8 files changed, 35 insertions, 15 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 556dafb..4f7334f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -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> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index c079ee7..67335f8 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -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", diff --git a/chrome/browser/local_discovery/privet_notifications.cc b/chrome/browser/local_discovery/privet_notifications.cc index b378a64..e5c329a 100644 --- a/chrome/browser/local_discovery/privet_notifications.cc +++ b/chrome/browser/local_discovery/privet_notifications.cc @@ -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() { diff --git a/chrome/browser/local_discovery/privet_notifications.h b/chrome/browser/local_discovery/privet_notifications.h index 0e3fb93..2b1a46b 100644 --- a/chrome/browser/local_discovery/privet_notifications.h +++ b/chrome/browser/local_discovery/privet_notifications.h @@ -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_; diff --git a/chrome/browser/local_discovery/privet_notifications_factory.cc b/chrome/browser/local_discovery/privet_notifications_factory.cc index 305b37d..7a22ac5 100644 --- a/chrome/browser/local_discovery/privet_notifications_factory.cc +++ b/chrome/browser/local_discovery/privet_notifications_factory.cc @@ -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 { diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 6851bc4..045a988 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -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: diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index fec391e..8de3ad9 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -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"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 6fc0349..56c31f5 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -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[]; |