| 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/printing/cloud_print/privet_notifications.h" | 5 #include "chrome/browser/printing/cloud_print/privet_notifications.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 DeviceContextMap::iterator found = devices_seen_.find(name); | 94 DeviceContextMap::iterator found = devices_seen_.find(name); |
| 95 if (found != devices_seen_.end()) { | 95 if (found != devices_seen_.end()) { |
| 96 if (!description.id.empty() && // Device is registered | 96 if (!description.id.empty() && // Device is registered |
| 97 found->second->notification_may_be_active) { | 97 found->second->notification_may_be_active) { |
| 98 found->second->notification_may_be_active = false; | 98 found->second->notification_may_be_active = false; |
| 99 NotifyDeviceRemoved(); | 99 NotifyDeviceRemoved(); |
| 100 } | 100 } |
| 101 return; // Already saw this device. | 101 return; // Already saw this device. |
| 102 } | 102 } |
| 103 | 103 |
| 104 linked_ptr<DeviceContext> device_context(new DeviceContext); | 104 scoped_ptr<DeviceContext>& device_context = devices_seen_[name]; |
| 105 | 105 device_context.reset(new DeviceContext); |
| 106 device_context->notification_may_be_active = false; | 106 device_context->notification_may_be_active = false; |
| 107 device_context->registered = !description.id.empty(); | 107 device_context->registered = !description.id.empty(); |
| 108 | 108 |
| 109 devices_seen_.insert(make_pair(name, device_context)); | |
| 110 | |
| 111 if (!device_context->registered) { | 109 if (!device_context->registered) { |
| 112 device_context->privet_http_resolution = | 110 device_context->privet_http_resolution = |
| 113 privet_http_factory_->CreatePrivetHTTP(name); | 111 privet_http_factory_->CreatePrivetHTTP(name); |
| 114 device_context->privet_http_resolution->Start( | 112 device_context->privet_http_resolution->Start( |
| 115 description.address, | 113 description.address, |
| 116 base::Bind(&PrivetNotificationsListener::CreateInfoOperation, | 114 base::Bind(&PrivetNotificationsListener::CreateInfoOperation, |
| 117 base::Unretained(this))); | 115 base::Unretained(this))); |
| 118 } | 116 } |
| 119 } | 117 } |
| 120 | 118 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 384 |
| 387 void PrivetNotificationDelegate::DisableNotifications() { | 385 void PrivetNotificationDelegate::DisableNotifications() { |
| 388 Profile* profile_obj = Profile::FromBrowserContext(profile_); | 386 Profile* profile_obj = Profile::FromBrowserContext(profile_); |
| 389 | 387 |
| 390 profile_obj->GetPrefs()->SetBoolean( | 388 profile_obj->GetPrefs()->SetBoolean( |
| 391 prefs::kLocalDiscoveryNotificationsEnabled, | 389 prefs::kLocalDiscoveryNotificationsEnabled, |
| 392 false); | 390 false); |
| 393 } | 391 } |
| 394 | 392 |
| 395 } // namespace cloud_print | 393 } // namespace cloud_print |
| OLD | NEW |