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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 2100663002: Fix a few bugs when closing mac notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DCHECK(profile); 403 DCHECK(profile);
404 404
405 closed_notifications_.insert(persistent_notification_id); 405 closed_notifications_.insert(persistent_notification_id);
406 406
407 #if defined(OS_ANDROID) 407 #if defined(OS_ANDROID)
408 bool cancel_by_persistent_id = true; 408 bool cancel_by_persistent_id = true;
409 #else 409 #else
410 bool cancel_by_persistent_id = 410 bool cancel_by_persistent_id =
411 GetNotificationDisplayService(profile)->SupportsNotificationCenter(); 411 GetNotificationDisplayService(profile)->SupportsNotificationCenter();
412 #endif 412 #endif
413 413 auto iter = persistent_notifications_.find(persistent_notification_id);
414 if (iter == persistent_notifications_.end())
415 return;
Peter Beverloo 2016/06/26 20:46:26 This will break closing persistent notifications s
Miguel Garcia 2016/06/28 08:17:20 True, changed it a bit to reflect that case, if in
414 if (cancel_by_persistent_id) { 416 if (cancel_by_persistent_id) {
415 // TODO(peter): Remove this conversion when the notification ids are being 417 // TODO(peter): Remove this conversion when the notification ids are being
416 // generated by the caller of this method. 418 // generated by the caller of this method.
417 GetNotificationDisplayService(profile)->Close( 419 GetNotificationDisplayService(profile)->Close(
418 base::Int64ToString(persistent_notification_id)); 420 base::Int64ToString(persistent_notification_id));
421 } else {
422 GetNotificationDisplayService(profile)->Close(iter->second);
Peter Beverloo 2016/06/26 20:46:26 Is invoking Close() twice with different values a
Miguel Garcia 2016/06/28 08:17:20 It isn't but in a world with an XPC service it wil
419 } 423 }
420
421 auto iter = persistent_notifications_.find(persistent_notification_id);
422 if (iter == persistent_notifications_.end())
423 return;
424
425 GetNotificationDisplayService(profile)->Close(iter->second);
426
427 persistent_notifications_.erase(iter); 424 persistent_notifications_.erase(iter);
428 } 425 }
429 426
430 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( 427 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications(
431 BrowserContext* browser_context, 428 BrowserContext* browser_context,
432 std::set<std::string>* displayed_notifications) { 429 std::set<std::string>* displayed_notifications) {
433 DCHECK(displayed_notifications); 430 DCHECK(displayed_notifications);
434 431
435 Profile* profile = Profile::FromBrowserContext(browser_context); 432 Profile* profile = Profile::FromBrowserContext(browser_context);
436 if (!profile || profile->AsTestingProfile()) 433 if (!profile || profile->AsTestingProfile())
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 561 }
565 #endif 562 #endif
566 563
567 return base::string16(); 564 return base::string16();
568 } 565 }
569 566
570 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 567 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
571 NotificationDisplayService* display_service) { 568 NotificationDisplayService* display_service) {
572 test_display_service_ = display_service; 569 test_display_service_ = display_service;
573 } 570 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698