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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/local_discovery/cloud_print_account_manager.h" |
| 14 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" |
| 15 #include "chrome/browser/local_discovery/privet_constants.h" |
13 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 16 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
| 17 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" |
| 18 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" |
14 #include "chrome/browser/local_discovery/privet_http_impl.h" | 19 #include "chrome/browser/local_discovery/privet_http_impl.h" |
| 20 #include "chrome/browser/local_discovery/service_discovery_host_client.h" |
15 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 21 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
16 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 23 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
19 #include "chrome/browser/signin/signin_manager.h" | 25 #include "chrome/browser/signin/signin_manager.h" |
20 #include "chrome/browser/signin/signin_manager_base.h" | 26 #include "chrome/browser/signin/signin_manager_base.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "chrome/browser/signin/signin_promo.h" | 28 #include "chrome/browser/signin/signin_promo.h" |
23 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
24 #include "chrome/browser/ui/browser_tabstrip.h" | 30 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #include "content/public/browser/user_metrics.h" |
25 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
26 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
27 #include "net/base/host_port_pair.h" | 34 #include "net/base/host_port_pair.h" |
28 #include "net/base/net_util.h" | 35 #include "net/base/net_util.h" |
29 #include "net/http/http_status_code.h" | 36 #include "net/http/http_status_code.h" |
30 | 37 |
31 namespace local_discovery { | 38 namespace local_discovery { |
32 | 39 |
33 namespace { | 40 namespace { |
34 const char kPrivetAutomatedClaimURLFormat[] = "%s/confirm?token=%s"; | 41 const char kPrivetAutomatedClaimURLFormat[] = "%s/confirm?token=%s"; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 105 |
99 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { | 106 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { |
100 Profile* profile = Profile::FromWebUI(web_ui()); | 107 Profile* profile = Profile::FromWebUI(web_ui()); |
101 | 108 |
102 // If privet_lister_ is already set, it is a mock used for tests or the result | 109 // If privet_lister_ is already set, it is a mock used for tests or the result |
103 // of a reload. | 110 // of a reload. |
104 if (!privet_lister_) { | 111 if (!privet_lister_) { |
105 service_discovery_client_ = ServiceDiscoveryHostClientFactory::GetClient(); | 112 service_discovery_client_ = ServiceDiscoveryHostClientFactory::GetClient(); |
106 privet_lister_.reset(new PrivetDeviceListerImpl( | 113 privet_lister_.reset(new PrivetDeviceListerImpl( |
107 service_discovery_client_.get(), this)); | 114 service_discovery_client_.get(), this)); |
108 privet_http_factory_.reset(new PrivetHTTPAsynchronousFactoryImpl( | 115 privet_http_factory_ = |
109 service_discovery_client_.get(), | 116 PrivetHTTPAsynchronousFactory::CreateInstance( |
110 profile->GetRequestContext())); | 117 service_discovery_client_.get(), profile->GetRequestContext()); |
111 } | 118 } |
112 | 119 |
113 privet_lister_->Start(); | 120 privet_lister_->Start(); |
114 privet_lister_->DiscoverNewDevices(false); | 121 privet_lister_->DiscoverNewDevices(false); |
115 | 122 |
116 CheckUserLoggedIn(); | 123 CheckUserLoggedIn(); |
117 } | 124 } |
118 | 125 |
119 void LocalDiscoveryUIHandler::HandleIsVisible(const base::ListValue* args) { | 126 void LocalDiscoveryUIHandler::HandleIsVisible(const base::ListValue* args) { |
120 bool is_visible = false; | 127 bool is_visible = false; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return return_value.Pass(); | 438 return return_value.Pass(); |
432 } | 439 } |
433 | 440 |
434 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { | 441 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { |
435 base::FundamentalValue logged_in_value(!GetSyncAccount().empty()); | 442 base::FundamentalValue logged_in_value(!GetSyncAccount().empty()); |
436 web_ui()->CallJavascriptFunction("local_discovery.setUserLoggedIn", | 443 web_ui()->CallJavascriptFunction("local_discovery.setUserLoggedIn", |
437 logged_in_value); | 444 logged_in_value); |
438 } | 445 } |
439 | 446 |
440 } // namespace local_discovery | 447 } // namespace local_discovery |
OLD | NEW |