Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/printing/cloud_print/privet_notifications.cc

Issue 1553333002: Move cloud print specific files out of local_discovery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moveprn
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/local_discovery/privet_notifications.h" 5 #include "chrome/browser/printing/cloud_print/privet_notifications.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/local_discovery/privet_device_lister_impl.h"
20 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h"
21 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" 19 #include "chrome/browser/local_discovery/service_discovery_shared_client.h"
22 #include "chrome/browser/notifications/notification.h" 20 #include "chrome/browser/notifications/notification.h"
23 #include "chrome/browser/notifications/notification_ui_manager.h" 21 #include "chrome/browser/notifications/notification_ui_manager.h"
22 #include "chrome/browser/printing/cloud_print/privet_device_lister_impl.h"
23 #include "chrome/browser/printing/cloud_print/privet_http_asynchronous_factory.h "
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
28 #include "chrome/browser/ui/browser_navigator_params.h" 28 #include "chrome/browser/ui/browser_navigator_params.h"
29 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
30 #include "chrome/browser/ui/host_desktop.h" 30 #include "chrome/browser/ui/host_desktop.h"
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model.h"
32 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" 32 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/grit/generated_resources.h" 35 #include "chrome/grit/generated_resources.h"
36 #include "components/signin/core/browser/signin_manager_base.h" 36 #include "components/signin/core/browser/signin_manager_base.h"
37 #include "content/public/browser/browser_context.h" 37 #include "content/public/browser/browser_context.h"
38 #include "content/public/browser/navigation_controller.h" 38 #include "content/public/browser/navigation_controller.h"
39 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
40 #include "grit/theme_resources.h" 40 #include "grit/theme_resources.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/page_transition_types.h" 42 #include "ui/base/page_transition_types.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/message_center/notifier_settings.h" 44 #include "ui/message_center/notifier_settings.h"
45 45
46 #if defined(ENABLE_MDNS) 46 #if defined(ENABLE_MDNS)
47 #include "chrome/browser/local_discovery/privet_traffic_detector.h" 47 #include "chrome/browser/printing/cloud_print/privet_traffic_detector.h"
48 #endif 48 #endif
49 49
50 namespace local_discovery { 50 namespace cloud_print {
51 51
52 namespace { 52 namespace {
53 53
54 const int kTenMinutesInSeconds = 600; 54 const int kTenMinutesInSeconds = 600;
55 const char kPrivetInfoKeyUptime[] = "uptime"; 55 const char kPrivetInfoKeyUptime[] = "uptime";
56 const char kPrivetNotificationID[] = "privet_notification"; 56 const char kPrivetNotificationID[] = "privet_notification";
57 const char kPrivetNotificationOriginUrl[] = "chrome://devices"; 57 const char kPrivetNotificationOriginUrl[] = "chrome://devices";
58 const int kStartDelaySeconds = 5; 58 const int kStartDelaySeconds = 5;
59 59
60 enum PrivetNotificationsEvent { 60 enum PrivetNotificationsEvent {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 message_center::NOTIFICATION_TYPE_SIMPLE, title, body, 263 message_center::NOTIFICATION_TYPE_SIMPLE, title, body,
264 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 264 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
265 IDR_LOCAL_DISCOVERY_CLOUDPRINT_ICON), 265 IDR_LOCAL_DISCOVERY_CLOUDPRINT_ICON),
266 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, 266 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
267 kPrivetNotificationID), 267 kPrivetNotificationID),
268 product_name, GURL(kPrivetNotificationOriginUrl), kPrivetNotificationID, 268 product_name, GURL(kPrivetNotificationOriginUrl), kPrivetNotificationID,
269 rich_notification_data, new PrivetNotificationDelegate(profile_)); 269 rich_notification_data, new PrivetNotificationDelegate(profile_));
270 270
271 bool updated = g_browser_process->notification_ui_manager()->Update( 271 bool updated = g_browser_process->notification_ui_manager()->Update(
272 notification, profile_object); 272 notification, profile_object);
273 if (!updated && added && !LocalDiscoveryUIHandler::GetHasVisible()) { 273 if (!updated && added &&
274 !local_discovery::LocalDiscoveryUIHandler::GetHasVisible()) {
274 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_SHOWN); 275 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_SHOWN);
275 g_browser_process->notification_ui_manager()->Add(notification, 276 g_browser_process->notification_ui_manager()->Add(notification,
276 profile_object); 277 profile_object);
277 } 278 }
278 } 279 }
279 280
280 void PrivetNotificationService::PrivetRemoveNotification() { 281 void PrivetNotificationService::PrivetRemoveNotification() {
281 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CANCELED); 282 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CANCELED);
282 Profile* profile_object = Profile::FromBrowserContext(profile_); 283 Profile* profile_object = Profile::FromBrowserContext(profile_);
283 g_browser_process->notification_ui_manager()->CancelById( 284 g_browser_process->notification_ui_manager()->CancelById(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 privet_notifications_listener_.reset(); 330 privet_notifications_listener_.reset();
330 } 331 }
331 #endif 332 #endif
332 } 333 }
333 334
334 void PrivetNotificationService::StartLister() { 335 void PrivetNotificationService::StartLister() {
335 ReportPrivetUmaEvent(PRIVET_LISTER_STARTED); 336 ReportPrivetUmaEvent(PRIVET_LISTER_STARTED);
336 #if defined(ENABLE_MDNS) 337 #if defined(ENABLE_MDNS)
337 traffic_detector_ = NULL; 338 traffic_detector_ = NULL;
338 #endif // ENABLE_MDNS 339 #endif // ENABLE_MDNS
339 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); 340 service_discovery_client_ =
341 local_discovery::ServiceDiscoverySharedClient::GetInstance();
340 device_lister_.reset( 342 device_lister_.reset(
341 new PrivetDeviceListerImpl(service_discovery_client_.get(), this)); 343 new PrivetDeviceListerImpl(service_discovery_client_.get(), this));
342 device_lister_->Start(); 344 device_lister_->Start();
343 device_lister_->DiscoverNewDevices(false); 345 device_lister_->DiscoverNewDevices(false);
344 346
345 scoped_ptr<PrivetHTTPAsynchronousFactory> http_factory( 347 scoped_ptr<PrivetHTTPAsynchronousFactory> http_factory(
346 PrivetHTTPAsynchronousFactory::CreateInstance( 348 PrivetHTTPAsynchronousFactory::CreateInstance(
347 profile_->GetRequestContext())); 349 profile_->GetRequestContext()));
348 350
349 privet_notifications_listener_.reset( 351 privet_notifications_listener_.reset(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 385 }
384 386
385 void PrivetNotificationDelegate::DisableNotifications() { 387 void PrivetNotificationDelegate::DisableNotifications() {
386 Profile* profile_obj = Profile::FromBrowserContext(profile_); 388 Profile* profile_obj = Profile::FromBrowserContext(profile_);
387 389
388 profile_obj->GetPrefs()->SetBoolean( 390 profile_obj->GetPrefs()->SetBoolean(
389 prefs::kLocalDiscoveryNotificationsEnabled, 391 prefs::kLocalDiscoveryNotificationsEnabled,
390 false); 392 false);
391 } 393 }
392 394
393 } // namespace local_discovery 395 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698