| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/gcd_private/gcd_private_api.h" | 5 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 8 #include "base/location.h" | 9 #include "base/location.h" |
| 9 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 14 #include "chrome/browser/local_discovery/cloud_device_list.h" | 15 #include "chrome/browser/local_discovery/cloud_device_list.h" |
| 15 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" | 16 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" |
| 16 #include "chrome/browser/local_discovery/gcd_api_flow.h" | 17 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
| 17 #include "chrome/browser/local_discovery/gcd_constants.h" | 18 #include "chrome/browser/local_discovery/gcd_constants.h" |
| 18 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 19 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
| 19 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" | 20 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" |
| 20 #include "chrome/browser/local_discovery/privet_http_impl.h" | 21 #include "chrome/browser/local_discovery/privet_http_impl.h" |
| 21 #include "chrome/browser/local_discovery/privetv3_session.h" | 22 #include "chrome/browser/local_discovery/privetv3_session.h" |
| 22 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 23 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
| 27 #include "chrome/common/chrome_switches.h" |
| 26 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 28 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 27 #include "components/signin/core/browser/signin_manager.h" | 29 #include "components/signin/core/browser/signin_manager.h" |
| 28 #include "components/signin/core/browser/signin_manager_base.h" | 30 #include "components/signin/core/browser/signin_manager_base.h" |
| 29 #include "extensions/browser/event_router.h" | 31 #include "extensions/browser/event_router.h" |
| 30 #include "net/base/net_util.h" | 32 #include "net/base/net_util.h" |
| 31 | 33 |
| 32 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 34 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
| 33 #include "chrome/browser/local_discovery/wifi/wifi_manager.h" | 35 #include "chrome/browser/local_discovery/wifi/wifi_manager.h" |
| 34 #endif | 36 #endif |
| 35 | 37 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return false; | 312 return false; |
| 311 | 313 |
| 312 privet_device_lister_->DiscoverNewDevices(true); | 314 privet_device_lister_->DiscoverNewDevices(true); |
| 313 | 315 |
| 314 return true; | 316 return true; |
| 315 } | 317 } |
| 316 | 318 |
| 317 void GcdPrivateAPIImpl::CreateSession(const std::string& service_name, | 319 void GcdPrivateAPIImpl::CreateSession(const std::string& service_name, |
| 318 const CreateSessionCallback& callback) { | 320 const CreateSessionCallback& callback) { |
| 319 int session_id = last_session_id_++; | 321 int session_id = last_session_id_++; |
| 322 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 323 switches::kEnablePrivetV3)) { |
| 324 return callback.Run(session_id, gcd_private::STATUS_SESSIONERROR, |
| 325 base::DictionaryValue()); |
| 326 } |
| 320 scoped_ptr<local_discovery::PrivetHTTPAsynchronousFactory> factory( | 327 scoped_ptr<local_discovery::PrivetHTTPAsynchronousFactory> factory( |
| 321 local_discovery::PrivetHTTPAsynchronousFactory::CreateInstance( | 328 local_discovery::PrivetHTTPAsynchronousFactory::CreateInstance( |
| 322 browser_context_->GetRequestContext())); | 329 browser_context_->GetRequestContext())); |
| 323 auto& session_data = sessions_[session_id]; | 330 auto& session_data = sessions_[session_id]; |
| 324 session_data.http_resolution.reset( | 331 session_data.http_resolution.reset( |
| 325 factory->CreatePrivetHTTP(service_name).release()); | 332 factory->CreatePrivetHTTP(service_name).release()); |
| 326 session_data.http_resolution->Start( | 333 session_data.http_resolution->Start( |
| 327 base::Bind(&GcdPrivateAPIImpl::OnServiceResolved, base::Unretained(this), | 334 base::Bind(&GcdPrivateAPIImpl::OnServiceResolved, base::Unretained(this), |
| 328 session_id, callback)); | 335 session_id, callback)); |
| 329 } | 336 } |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 } | 889 } |
| 883 | 890 |
| 884 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { | 891 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { |
| 885 } | 892 } |
| 886 | 893 |
| 887 bool GcdPrivateGetCommandsListFunction::RunAsync() { | 894 bool GcdPrivateGetCommandsListFunction::RunAsync() { |
| 888 return false; | 895 return false; |
| 889 } | 896 } |
| 890 | 897 |
| 891 } // namespace extensions | 898 } // namespace extensions |
| OLD | NEW |