OLD | NEW |
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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 DeviceContextMap::iterator device_iter = devices_seen_.find(name); | 118 DeviceContextMap::iterator device_iter = devices_seen_.find(name); |
119 DCHECK(device_iter != devices_seen_.end()); | 119 DCHECK(device_iter != devices_seen_.end()); |
120 DeviceContext* device = device_iter->second.get(); | 120 DeviceContext* device = device_iter->second.get(); |
121 | 121 |
122 device->info_operation.reset(); | 122 device->info_operation.reset(); |
123 device->privet_http_resolution.reset(); | 123 device->privet_http_resolution.reset(); |
124 device->notification_may_be_active = false; | 124 device->notification_may_be_active = false; |
125 delegate_->PrivetRemoveNotification(name); | 125 delegate_->PrivetRemoveNotification(name); |
126 } | 126 } |
127 | 127 |
| 128 void PrivetNotificationsListener::DeviceCacheFlushed() { |
| 129 for (DeviceContextMap::iterator i = devices_seen_.begin(); |
| 130 i != devices_seen_.end(); ++i) { |
| 131 DeviceContext* device = i->second.get(); |
| 132 |
| 133 device->info_operation.reset(); |
| 134 device->privet_http_resolution.reset(); |
| 135 if (device->notification_may_be_active) { |
| 136 device->notification_may_be_active = false; |
| 137 delegate_->PrivetRemoveNotification(i->first); |
| 138 } |
| 139 } |
| 140 } |
| 141 |
128 PrivetNotificationsListener::DeviceContext::DeviceContext() { | 142 PrivetNotificationsListener::DeviceContext::DeviceContext() { |
129 } | 143 } |
130 | 144 |
131 PrivetNotificationsListener::DeviceContext::~DeviceContext() { | 145 PrivetNotificationsListener::DeviceContext::~DeviceContext() { |
132 } | 146 } |
133 | 147 |
134 PrivetNotificationService::PrivetNotificationService( | 148 PrivetNotificationService::PrivetNotificationService( |
135 content::BrowserContext* profile, | 149 content::BrowserContext* profile, |
136 NotificationUIManager* notification_manager) | 150 NotificationUIManager* notification_manager) |
137 : profile_(profile), | 151 : profile_(profile), |
(...skipping 11 matching lines...) Expand all Loading... |
149 bool added, | 163 bool added, |
150 const std::string& name, | 164 const std::string& name, |
151 const DeviceDescription& description) { | 165 const DeviceDescription& description) { |
152 privet_notifications_listener_->DeviceChanged(added, name, description); | 166 privet_notifications_listener_->DeviceChanged(added, name, description); |
153 } | 167 } |
154 | 168 |
155 void PrivetNotificationService::DeviceRemoved(const std::string& name) { | 169 void PrivetNotificationService::DeviceRemoved(const std::string& name) { |
156 privet_notifications_listener_->DeviceRemoved(name); | 170 privet_notifications_listener_->DeviceRemoved(name); |
157 } | 171 } |
158 | 172 |
| 173 void PrivetNotificationService::DeviceCacheFlushed() { |
| 174 privet_notifications_listener_->DeviceCacheFlushed(); |
| 175 } |
| 176 |
159 void PrivetNotificationService::PrivetNotify( | 177 void PrivetNotificationService::PrivetNotify( |
160 const std::string& device_name, | 178 const std::string& device_name, |
161 const std::string& human_readable_name, | 179 const std::string& human_readable_name, |
162 const std::string& description) { | 180 const std::string& description) { |
163 if (!LocalDiscoveryUIHandler::GetHasVisible()) { | 181 if (!LocalDiscoveryUIHandler::GetHasVisible()) { |
164 Profile* profile_object = Profile::FromBrowserContext(profile_); | 182 Profile* profile_object = Profile::FromBrowserContext(profile_); |
165 message_center::RichNotificationData rich_notification_data; | 183 message_center::RichNotificationData rich_notification_data; |
166 | 184 |
167 rich_notification_data.buttons.push_back( | 185 rich_notification_data.buttons.push_back( |
168 message_center::ButtonInfo(l10n_util::GetStringUTF16( | 186 message_center::ButtonInfo(l10n_util::GetStringUTF16( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 contents->GetController().LoadURL(url, | 277 contents->GetController().LoadURL(url, |
260 content::Referrer(), | 278 content::Referrer(), |
261 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 279 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
262 ""); | 280 ""); |
263 | 281 |
264 browser->tab_strip_model()->AppendWebContents(contents.release(), true); | 282 browser->tab_strip_model()->AppendWebContents(contents.release(), true); |
265 } | 283 } |
266 | 284 |
267 | 285 |
268 } // namespace local_discovery | 286 } // namespace local_discovery |
OLD | NEW |