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

Side by Side Diff: chrome/browser/local_discovery/privet_notifications.cc

Issue 186983003: [Privet] Do not show notifications from guest and default profiles in ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/local_discovery/privet_notifications.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" 15 #include "chrome/browser/local_discovery/privet_device_lister_impl.h"
16 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" 16 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h"
17 #include "chrome/browser/local_discovery/privet_traffic_detector.h" 17 #include "chrome/browser/local_discovery/privet_traffic_detector.h"
18 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" 18 #include "chrome/browser/local_discovery/service_discovery_shared_client.h"
19 #include "chrome/browser/notifications/notification.h" 19 #include "chrome/browser/notifications/notification.h"
20 #include "chrome/browser/notifications/notification_ui_manager.h" 20 #include "chrome/browser/notifications/notification_ui_manager.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/signin/signin_manager_base.h"
23 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_finder.h" 25 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/host_desktop.h" 27 #include "chrome/browser/ui/host_desktop.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" 29 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
28 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
30 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/navigation_controller.h" 33 #include "content/public/browser/navigation_controller.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 279 }
278 } 280 }
279 281
280 void PrivetNotificationService::PrivetRemoveNotification() { 282 void PrivetNotificationService::PrivetRemoveNotification() {
281 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CANCELED); 283 ReportPrivetUmaEvent(PRIVET_NOTIFICATION_CANCELED);
282 g_browser_process->notification_ui_manager()->CancelById( 284 g_browser_process->notification_ui_manager()->CancelById(
283 kPrivetNotificationID); 285 kPrivetNotificationID);
284 } 286 }
285 287
286 void PrivetNotificationService::Start() { 288 void PrivetNotificationService::Start() {
289 #if defined(CHROMEOS)
290 SigninManagerBase* signin_manager =
291 SigninManagerFactory::GetForProfileIfExists(
292 Profile::FromBrowserContext(profile_));
293
294 if (!signin_manager || signin_manager->GetAuthenticatedUsername().empty())
Vitaly Buka (NO REVIEWS) 2014/03/04 22:47:33 I guess that's not enough. service keeps running a
Noam Samuel 2014/03/04 22:58:49 Have we seen this behavior? I'd suspect notificati
295 return;
296 #endif
297
287 enable_privet_notification_member_.Init( 298 enable_privet_notification_member_.Init(
288 prefs::kLocalDiscoveryNotificationsEnabled, 299 prefs::kLocalDiscoveryNotificationsEnabled,
289 Profile::FromBrowserContext(profile_)->GetPrefs(), 300 Profile::FromBrowserContext(profile_)->GetPrefs(),
290 base::Bind(&PrivetNotificationService::OnNotificationsEnabledChanged, 301 base::Bind(&PrivetNotificationService::OnNotificationsEnabledChanged,
291 base::Unretained(this))); 302 base::Unretained(this)));
292 OnNotificationsEnabledChanged(); 303 OnNotificationsEnabledChanged();
293 } 304 }
294 305
295 void PrivetNotificationService::OnNotificationsEnabledChanged() { 306 void PrivetNotificationService::OnNotificationsEnabledChanged() {
296 if (IsForced()) { 307 if (IsForced()) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 390
380 void PrivetNotificationDelegate::DisableNotifications() { 391 void PrivetNotificationDelegate::DisableNotifications() {
381 Profile* profile_obj = Profile::FromBrowserContext(profile_); 392 Profile* profile_obj = Profile::FromBrowserContext(profile_);
382 393
383 profile_obj->GetPrefs()->SetBoolean( 394 profile_obj->GetPrefs()->SetBoolean(
384 prefs::kLocalDiscoveryNotificationsEnabled, 395 prefs::kLocalDiscoveryNotificationsEnabled,
385 false); 396 false);
386 } 397 }
387 398
388 } // namespace local_discovery 399 } // namespace local_discovery
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698