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 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
33 #include "components/cloud_devices/common/cloud_devices_switches.h" | 33 #include "components/cloud_devices/common/cloud_devices_switches.h" |
34 #include "components/cloud_devices/common/cloud_devices_urls.h" | 34 #include "components/cloud_devices/common/cloud_devices_urls.h" |
35 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 35 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
36 #include "components/signin/core/browser/signin_manager_base.h" | 36 #include "components/signin/core/browser/signin_manager_base.h" |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/browser/web_ui.h" | 38 #include "content/public/browser/web_ui.h" |
39 #include "content/public/common/page_transition_types.h" | |
40 #include "net/base/host_port_pair.h" | 39 #include "net/base/host_port_pair.h" |
41 #include "net/base/net_util.h" | 40 #include "net/base/net_util.h" |
42 #include "net/base/url_util.h" | 41 #include "net/base/url_util.h" |
43 #include "net/http/http_status_code.h" | 42 #include "net/http/http_status_code.h" |
44 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/page_transition_types.h" |
45 | 45 |
46 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) | 46 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) |
47 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE | 47 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE |
48 #endif | 48 #endif |
49 | 49 |
50 namespace local_discovery { | 50 namespace local_discovery { |
51 | 51 |
52 namespace { | 52 namespace { |
53 | 53 |
54 const char kDictionaryKeyServiceName[] = "service_name"; | 54 const char kDictionaryKeyServiceName[] = "service_name"; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 std::string id; | 284 std::string id; |
285 bool rv = args->GetString(0, &id); | 285 bool rv = args->GetString(0, &id); |
286 DCHECK(rv); | 286 DCHECK(rv); |
287 | 287 |
288 Browser* browser = chrome::FindBrowserWithWebContents( | 288 Browser* browser = chrome::FindBrowserWithWebContents( |
289 web_ui()->GetWebContents()); | 289 web_ui()->GetWebContents()); |
290 DCHECK(browser); | 290 DCHECK(browser); |
291 | 291 |
292 chrome::AddSelectedTabWithURL(browser, | 292 chrome::AddSelectedTabWithURL(browser, |
293 cloud_devices::GetCloudPrintManageDeviceURL(id), | 293 cloud_devices::GetCloudPrintManageDeviceURL(id), |
294 content::PAGE_TRANSITION_FROM_API); | 294 ui::PAGE_TRANSITION_FROM_API); |
295 } | 295 } |
296 | 296 |
297 void LocalDiscoveryUIHandler::HandleShowSyncUI( | 297 void LocalDiscoveryUIHandler::HandleShowSyncUI( |
298 const base::ListValue* args) { | 298 const base::ListValue* args) { |
299 Browser* browser = chrome::FindBrowserWithWebContents( | 299 Browser* browser = chrome::FindBrowserWithWebContents( |
300 web_ui()->GetWebContents()); | 300 web_ui()->GetWebContents()); |
301 DCHECK(browser); | 301 DCHECK(browser); |
302 | 302 |
303 GURL url(signin::GetPromoURL(signin::SOURCE_DEVICES_PAGE, | 303 GURL url(signin::GetPromoURL(signin::SOURCE_DEVICES_PAGE, |
304 true)); // auto close after success. | 304 true)); // auto close after success. |
305 | 305 |
306 browser->OpenURL( | 306 browser->OpenURL( |
307 content::OpenURLParams(url, content::Referrer(), SINGLETON_TAB, | 307 content::OpenURLParams(url, content::Referrer(), SINGLETON_TAB, |
308 content::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | 308 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
309 } | 309 } |
310 | 310 |
311 void LocalDiscoveryUIHandler::StartRegisterHTTP( | 311 void LocalDiscoveryUIHandler::StartRegisterHTTP( |
312 scoped_ptr<PrivetHTTPClient> http_client) { | 312 scoped_ptr<PrivetHTTPClient> http_client) { |
313 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); | 313 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); |
314 | 314 |
315 std::string user = GetSyncAccount(); | 315 std::string user = GetSyncAccount(); |
316 | 316 |
317 if (!current_http_client_) { | 317 if (!current_http_client_) { |
318 SendRegisterError(); | 318 SendRegisterError(); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 const base::ListValue* args) { | 679 const base::ListValue* args) { |
680 content::RecordAction( | 680 content::RecordAction( |
681 base::UserMetricsAction("Options_EnableCloudPrintProxy")); | 681 base::UserMetricsAction("Options_EnableCloudPrintProxy")); |
682 // Open the connector enable page in the current tab. | 682 // Open the connector enable page in the current tab. |
683 Profile* profile = Profile::FromWebUI(web_ui()); | 683 Profile* profile = Profile::FromWebUI(web_ui()); |
684 content::OpenURLParams params( | 684 content::OpenURLParams params( |
685 cloud_devices::GetCloudPrintEnableURL( | 685 cloud_devices::GetCloudPrintEnableURL( |
686 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), | 686 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
687 content::Referrer(), | 687 content::Referrer(), |
688 CURRENT_TAB, | 688 CURRENT_TAB, |
689 content::PAGE_TRANSITION_LINK, | 689 ui::PAGE_TRANSITION_LINK, |
690 false); | 690 false); |
691 web_ui()->GetWebContents()->OpenURL(params); | 691 web_ui()->GetWebContents()->OpenURL(params); |
692 } | 692 } |
693 | 693 |
694 void LocalDiscoveryUIHandler::HandleDisableCloudPrintConnector( | 694 void LocalDiscoveryUIHandler::HandleDisableCloudPrintConnector( |
695 const base::ListValue* args) { | 695 const base::ListValue* args) { |
696 content::RecordAction( | 696 content::RecordAction( |
697 base::UserMetricsAction("Options_DisableCloudPrintProxy")); | 697 base::UserMetricsAction("Options_DisableCloudPrintProxy")); |
698 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> | 698 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
699 DisableForUser(); | 699 DisableForUser(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 790 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
791 | 791 |
792 web_ui()->CallJavascriptFunction( | 792 web_ui()->CallJavascriptFunction( |
793 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); | 793 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); |
794 } | 794 } |
795 } | 795 } |
796 | 796 |
797 #endif // ENABLE_WIFI_BOOTSTRAPPING | 797 #endif // ENABLE_WIFI_BOOTSTRAPPING |
798 | 798 |
799 } // namespace local_discovery | 799 } // namespace local_discovery |
OLD | NEW |