| 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/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" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 description.address, | 110 description.address, |
| 111 base::Bind(&PrivetNotificationsListener::CreateInfoOperation, | 111 base::Bind(&PrivetNotificationsListener::CreateInfoOperation, |
| 112 base::Unretained(this))); | 112 base::Unretained(this))); |
| 113 | 113 |
| 114 device_context->privet_http_resolution->Start(); | 114 device_context->privet_http_resolution->Start(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void PrivetNotificationsListener::CreateInfoOperation( | 118 void PrivetNotificationsListener::CreateInfoOperation( |
| 119 scoped_ptr<PrivetHTTPClient> http_client) { | 119 scoped_ptr<PrivetHTTPClient> http_client) { |
| 120 if (!http_client) { |
| 121 // Do nothing if resolution fails. |
| 122 return; |
| 123 } |
| 124 |
| 120 std::string name = http_client->GetName(); | 125 std::string name = http_client->GetName(); |
| 121 DeviceContextMap::iterator device_iter = devices_seen_.find(name); | 126 DeviceContextMap::iterator device_iter = devices_seen_.find(name); |
| 122 DCHECK(device_iter != devices_seen_.end()); | 127 DCHECK(device_iter != devices_seen_.end()); |
| 123 DeviceContext* device = device_iter->second.get(); | 128 DeviceContext* device = device_iter->second.get(); |
| 124 device->privet_http.swap(http_client); | 129 device->privet_http.swap(http_client); |
| 125 device->info_operation = device->privet_http->CreateInfoOperation( | 130 device->info_operation = device->privet_http->CreateInfoOperation( |
| 126 base::Bind(&PrivetNotificationsListener::OnPrivetInfoDone, | 131 base::Bind(&PrivetNotificationsListener::OnPrivetInfoDone, |
| 127 base::Unretained(this), | 132 base::Unretained(this), |
| 128 device)); | 133 device)); |
| 129 device->info_operation->Start(); | 134 device->info_operation->Start(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 407 |
| 403 void PrivetNotificationDelegate::DisableNotifications() { | 408 void PrivetNotificationDelegate::DisableNotifications() { |
| 404 Profile* profile_obj = Profile::FromBrowserContext(profile_); | 409 Profile* profile_obj = Profile::FromBrowserContext(profile_); |
| 405 | 410 |
| 406 profile_obj->GetPrefs()->SetBoolean( | 411 profile_obj->GetPrefs()->SetBoolean( |
| 407 prefs::kLocalDiscoveryNotificationsEnabled, | 412 prefs::kLocalDiscoveryNotificationsEnabled, |
| 408 false); | 413 false); |
| 409 } | 414 } |
| 410 | 415 |
| 411 } // namespace local_discovery | 416 } // namespace local_discovery |
| OLD | NEW |