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

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: add balnk lines 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
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | 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 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
414 if (cancel_by_persistent_id) { 414 if (cancel_by_persistent_id) {
415 // TODO(peter): Remove this conversion when the notification ids are being 415 // TODO(peter): Remove this conversion when the notification ids are being
416 // generated by the caller of this method. 416 // generated by the caller of this method.
417 GetNotificationDisplayService(profile)->Close( 417 GetNotificationDisplayService(profile)->Close(
418 base::Int64ToString(persistent_notification_id)); 418 base::Int64ToString(persistent_notification_id));
419 } else {
420 auto iter = persistent_notifications_.find(persistent_notification_id);
421 if (iter == persistent_notifications_.end())
422 return;
423 GetNotificationDisplayService(profile)->Close(iter->second);
419 } 424 }
420 425
421 auto iter = persistent_notifications_.find(persistent_notification_id); 426 persistent_notifications_.erase(persistent_notification_id);
422 if (iter == persistent_notifications_.end())
423 return;
424
425 GetNotificationDisplayService(profile)->Close(iter->second);
426
427 persistent_notifications_.erase(iter);
428 } 427 }
429 428
430 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( 429 bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications(
431 BrowserContext* browser_context, 430 BrowserContext* browser_context,
432 std::set<std::string>* displayed_notifications) { 431 std::set<std::string>* displayed_notifications) {
433 DCHECK(displayed_notifications); 432 DCHECK(displayed_notifications);
434 433
435 Profile* profile = Profile::FromBrowserContext(browser_context); 434 Profile* profile = Profile::FromBrowserContext(browser_context);
436 if (!profile || profile->AsTestingProfile()) 435 if (!profile || profile->AsTestingProfile())
437 return false; // Tests will not have a message center. 436 return false; // Tests will not have a message center.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 563 }
565 #endif 564 #endif
566 565
567 return base::string16(); 566 return base::string16();
568 } 567 }
569 568
570 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 569 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
571 NotificationDisplayService* display_service) { 570 NotificationDisplayService* display_service) {
572 test_display_service_ = display_service; 571 test_display_service_ = display_service;
573 } 572 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698