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

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

Issue 1155453002: Passing ProfileID instead of Profile* to clarify that profile should not be used for making any cal… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notification_test_util.h" 5 #include "chrome/browser/notifications/notification_test_util.h"
6 6
7 MockNotificationDelegate::MockNotificationDelegate(const std::string& id) 7 MockNotificationDelegate::MockNotificationDelegate(const std::string& id)
8 : id_(id) {} 8 : id_(id) {}
9 9
10 MockNotificationDelegate::~MockNotificationDelegate() {} 10 MockNotificationDelegate::~MockNotificationDelegate() {}
(...skipping 16 matching lines...) Expand all
27 return notifications_[index].first; 27 return notifications_[index].first;
28 } 28 }
29 29
30 void StubNotificationUIManager::SetNotificationAddedCallback( 30 void StubNotificationUIManager::SetNotificationAddedCallback(
31 const base::Closure& callback) { 31 const base::Closure& callback) {
32 notification_added_callback_ = callback; 32 notification_added_callback_ = callback;
33 } 33 }
34 34
35 void StubNotificationUIManager::Add(const Notification& notification, 35 void StubNotificationUIManager::Add(const Notification& notification,
36 Profile* profile) { 36 Profile* profile) {
37 notifications_.push_back(std::make_pair(notification, profile)); 37 notifications_.push_back(std::make_pair(
38 notification, NotificationUIManager::GetProfileID(profile)));
38 39
39 if (!notification_added_callback_.is_null()) { 40 if (!notification_added_callback_.is_null()) {
40 notification_added_callback_.Run(); 41 notification_added_callback_.Run();
41 notification_added_callback_.Reset(); 42 notification_added_callback_.Reset();
42 } 43 }
43 44
44 // Fire the Display() event on the delegate. 45 // Fire the Display() event on the delegate.
45 notification.delegate()->Display(); 46 notification.delegate()->Display();
46 } 47 }
47 48
(...skipping 27 matching lines...) Expand all
75 iter->first.delegate()->Close(false /* by_user */); 76 iter->first.delegate()->Close(false /* by_user */);
76 notifications_.erase(iter); 77 notifications_.erase(iter);
77 return true; 78 return true;
78 } 79 }
79 80
80 return false; 81 return false;
81 } 82 }
82 83
83 std::set<std::string> 84 std::set<std::string>
84 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin( 85 StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
85 Profile* profile, 86 ProfileID profile_id,
86 const GURL& source) { 87 const GURL& source) {
87 std::set<std::string> delegate_ids; 88 std::set<std::string> delegate_ids;
88 for (const auto& pair : notifications_) { 89 for (const auto& pair : notifications_) {
89 if (pair.second == profile && pair.first.origin_url() == source) 90 if (pair.second == profile_id && pair.first.origin_url() == source)
90 delegate_ids.insert(pair.first.delegate_id()); 91 delegate_ids.insert(pair.first.delegate_id());
91 } 92 }
92 return delegate_ids; 93 return delegate_ids;
93 } 94 }
94 95
95 std::set<std::string> StubNotificationUIManager::GetAllIdsByProfile( 96 std::set<std::string> StubNotificationUIManager::GetAllIdsByProfile(
96 Profile* profile) { 97 ProfileID profile_id) {
97 std::set<std::string> delegate_ids; 98 std::set<std::string> delegate_ids;
98 for (const auto& pair : notifications_) { 99 for (const auto& pair : notifications_) {
99 if (pair.second == profile) 100 if (pair.second == profile_id)
100 delegate_ids.insert(pair.first.delegate_id()); 101 delegate_ids.insert(pair.first.delegate_id());
101 } 102 }
102 return delegate_ids; 103 return delegate_ids;
103 } 104 }
104 105
105 bool StubNotificationUIManager::CancelAllBySourceOrigin( 106 bool StubNotificationUIManager::CancelAllBySourceOrigin(
106 const GURL& source_origin) { 107 const GURL& source_origin) {
107 NOTIMPLEMENTED(); 108 NOTIMPLEMENTED();
108 return false; 109 return false;
109 } 110 }
110 111
111 bool StubNotificationUIManager::CancelAllByProfile(ProfileID profile_id) { 112 bool StubNotificationUIManager::CancelAllByProfile(ProfileID profile_id) {
112 NOTIMPLEMENTED(); 113 NOTIMPLEMENTED();
113 return false; 114 return false;
114 } 115 }
115 116
116 void StubNotificationUIManager::CancelAll() { 117 void StubNotificationUIManager::CancelAll() {
117 for (const auto& pair : notifications_) 118 for (const auto& pair : notifications_)
118 pair.first.delegate()->Close(false /* by_user */); 119 pair.first.delegate()->Close(false /* by_user */);
119 notifications_.clear(); 120 notifications_.clear();
120 } 121 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_test_util.h ('k') | chrome/browser/notifications/notification_ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698