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" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" | 16 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" |
17 #include "chrome/browser/local_discovery/privet_constants.h" | 17 #include "chrome/browser/local_discovery/privet_constants.h" |
18 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 18 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
19 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" | 19 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" |
20 #include "chrome/browser/local_discovery/privet_http_impl.h" | 20 #include "chrome/browser/local_discovery/privet_http_impl.h" |
21 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 21 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
22 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 22 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
23 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 23 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
26 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
27 #include "chrome/browser/signin/signin_promo.h" | 27 #include "chrome/browser/signin/signin_promo.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
| 30 #include "chrome/browser/ui/chrome_pages.h" |
30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
32 #include "chrome/grit/generated_resources.h" | 33 #include "chrome/grit/generated_resources.h" |
33 #include "components/cloud_devices/common/cloud_devices_switches.h" | 34 #include "components/cloud_devices/common/cloud_devices_switches.h" |
34 #include "components/cloud_devices/common/cloud_devices_urls.h" | 35 #include "components/cloud_devices/common/cloud_devices_urls.h" |
35 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
36 #include "components/signin/core/browser/signin_manager_base.h" | 37 #include "components/signin/core/browser/signin_manager_base.h" |
37 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/browser/web_ui.h" | 39 #include "content/public/browser/web_ui.h" |
39 #include "net/base/host_port_pair.h" | 40 #include "net/base/host_port_pair.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 chrome::AddSelectedTabWithURL(browser, | 293 chrome::AddSelectedTabWithURL(browser, |
293 cloud_devices::GetCloudPrintManageDeviceURL(id), | 294 cloud_devices::GetCloudPrintManageDeviceURL(id), |
294 ui::PAGE_TRANSITION_FROM_API); | 295 ui::PAGE_TRANSITION_FROM_API); |
295 } | 296 } |
296 | 297 |
297 void LocalDiscoveryUIHandler::HandleShowSyncUI( | 298 void LocalDiscoveryUIHandler::HandleShowSyncUI( |
298 const base::ListValue* args) { | 299 const base::ListValue* args) { |
299 Browser* browser = chrome::FindBrowserWithWebContents( | 300 Browser* browser = chrome::FindBrowserWithWebContents( |
300 web_ui()->GetWebContents()); | 301 web_ui()->GetWebContents()); |
301 DCHECK(browser); | 302 DCHECK(browser); |
302 | 303 chrome::ShowBrowserSignin(browser, signin_metrics::SOURCE_DEVICES_PAGE); |
303 GURL url(signin::GetPromoURL(signin::SOURCE_DEVICES_PAGE, | |
304 true)); // auto close after success. | |
305 | |
306 browser->OpenURL( | |
307 content::OpenURLParams(url, content::Referrer(), SINGLETON_TAB, | |
308 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | |
309 } | 304 } |
310 | 305 |
311 void LocalDiscoveryUIHandler::StartRegisterHTTP( | 306 void LocalDiscoveryUIHandler::StartRegisterHTTP( |
312 scoped_ptr<PrivetHTTPClient> http_client) { | 307 scoped_ptr<PrivetHTTPClient> http_client) { |
313 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); | 308 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); |
314 | 309 |
315 std::string user = GetSyncAccount(); | 310 std::string user = GetSyncAccount(); |
316 | 311 |
317 if (!current_http_client_) { | 312 if (!current_http_client_) { |
318 SendRegisterError(); | 313 SendRegisterError(); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 784 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
790 | 785 |
791 web_ui()->CallJavascriptFunction( | 786 web_ui()->CallJavascriptFunction( |
792 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); | 787 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); |
793 } | 788 } |
794 } | 789 } |
795 | 790 |
796 #endif // ENABLE_WIFI_BOOTSTRAPPING | 791 #endif // ENABLE_WIFI_BOOTSTRAPPING |
797 | 792 |
798 } // namespace local_discovery | 793 } // namespace local_discovery |
OLD | NEW |