| 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/ui/webui/local_discovery/local_discovery_ui_handler.h" | 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { | 174 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { |
| 175 Profile* profile = Profile::FromWebUI(web_ui()); | 175 Profile* profile = Profile::FromWebUI(web_ui()); |
| 176 | 176 |
| 177 // If privet_lister_ is already set, it is a mock used for tests or the result | 177 // If privet_lister_ is already set, it is a mock used for tests or the result |
| 178 // of a reload. | 178 // of a reload. |
| 179 if (!privet_lister_) { | 179 if (!privet_lister_) { |
| 180 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); | 180 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); |
| 181 privet_lister_.reset( | 181 privet_lister_.reset( |
| 182 new PrivetDeviceListerImpl(service_discovery_client_.get(), this)); | 182 new PrivetDeviceListerImpl(service_discovery_client_.get(), this)); |
| 183 privet_http_factory_ = | 183 privet_http_factory_ = PrivetHTTPAsynchronousFactory::CreateInstance( |
| 184 PrivetHTTPAsynchronousFactory::CreateInstance( | 184 service_discovery_client_.get(), profile->GetRequestContext()); |
| 185 service_discovery_client_.get(), profile->GetRequestContext()); | |
| 186 | 185 |
| 187 SigninManagerBase* signin_manager = | 186 SigninManagerBase* signin_manager = |
| 188 SigninManagerFactory::GetInstance()->GetForProfile(profile); | 187 SigninManagerFactory::GetInstance()->GetForProfile(profile); |
| 189 if (signin_manager) | 188 if (signin_manager) |
| 190 signin_manager->AddObserver(this); | 189 signin_manager->AddObserver(this); |
| 191 } | 190 } |
| 192 | 191 |
| 193 privet_lister_->Start(); | 192 privet_lister_->Start(); |
| 194 privet_lister_->DiscoverNewDevices(false); | 193 privet_lister_->DiscoverNewDevices(false); |
| 195 | 194 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 GURL url(signin::GetPromoURL(signin::SOURCE_DEVICES_PAGE, | 278 GURL url(signin::GetPromoURL(signin::SOURCE_DEVICES_PAGE, |
| 280 true)); // auto close after success. | 279 true)); // auto close after success. |
| 281 | 280 |
| 282 browser->OpenURL( | 281 browser->OpenURL( |
| 283 content::OpenURLParams(url, content::Referrer(), SINGLETON_TAB, | 282 content::OpenURLParams(url, content::Referrer(), SINGLETON_TAB, |
| 284 content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | 283 content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
| 285 } | 284 } |
| 286 | 285 |
| 287 void LocalDiscoveryUIHandler::StartRegisterHTTP( | 286 void LocalDiscoveryUIHandler::StartRegisterHTTP( |
| 288 scoped_ptr<PrivetHTTPClient> http_client) { | 287 scoped_ptr<PrivetHTTPClient> http_client) { |
| 289 current_http_client_.swap(http_client); | 288 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); |
| 290 | 289 |
| 291 std::string user = GetSyncAccount(); | 290 std::string user = GetSyncAccount(); |
| 292 | 291 |
| 293 if (!current_http_client_) { | 292 if (!current_http_client_) { |
| 294 SendRegisterError(); | 293 SendRegisterError(); |
| 295 return; | 294 return; |
| 296 } | 295 } |
| 297 | 296 |
| 298 current_register_operation_ = | 297 current_register_operation_ = |
| 299 current_http_client_->CreateRegisterOperation(user, this); | 298 current_http_client_->CreateRegisterOperation(user, this); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 695 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
| 697 | 696 |
| 698 web_ui()->CallJavascriptFunction( | 697 web_ui()->CallJavascriptFunction( |
| 699 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); | 698 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); |
| 700 } | 699 } |
| 701 } | 700 } |
| 702 | 701 |
| 703 #endif // ENABLE_WIFI_BOOTSTRAPPING | 702 #endif // ENABLE_WIFI_BOOTSTRAPPING |
| 704 | 703 |
| 705 } // namespace local_discovery | 704 } // namespace local_discovery |
| OLD | NEW |