summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-20 22:04:48 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-20 22:04:48 +0000
commit09cff78781a7bfc6858544b0bd754300eb000bbb (patch)
treeed81b0c8d63d755ee720a1f8b9bde267b3cbd260
parentb897d5caed9c84579564d4a6d8b864776931616a (diff)
downloadchromium_src-09cff78781a7bfc6858544b0bd754300eb000bbb.zip
chromium_src-09cff78781a7bfc6858544b0bd754300eb000bbb.tar.gz
chromium_src-09cff78781a7bfc6858544b0bd754300eb000bbb.tar.bz2
Moved CloudPrintUrl to components/cloud_devices/cloud_devices_urls.h.
Removed unused cloud print prefs. TBR=jochen, rogerta Review URL: https://codereview.chromium.org/240283010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264945 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc3
-rw-r--r--chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc5
-rw-r--r--chrome/browser/local_discovery/cloud_print_printer_list.cc10
-rw-r--r--chrome/browser/local_discovery/cloud_print_printer_list.h2
-rw-r--r--chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc4
-rw-r--r--chrome/browser/local_discovery/gcd_base_api_flow.cc6
-rw-r--r--chrome/browser/local_discovery/gcd_constants.cc2
-rw-r--r--chrome/browser/local_discovery/gcd_constants.h2
-rw-r--r--chrome/browser/local_discovery/gcd_url.cc25
-rw-r--r--chrome/browser/local_discovery/gcd_url.h16
-rw-r--r--chrome/browser/local_discovery/privet_confirm_api_flow.cc25
-rw-r--r--chrome/browser/local_discovery/privet_confirm_api_flow.h1
-rw-r--r--chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc31
-rw-r--r--chrome/browser/prefs/browser_prefs.cc2
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_url.cc122
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_url.h40
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc30
-rw-r--r--chrome/browser/printing/print_dialog_cloud_unittest.cc67
-rw-r--r--chrome/browser/service_process/service_process_control.cc3
-rw-r--r--chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc34
-rw-r--r--chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h3
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc1
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc21
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/common/DEPS1
-rw-r--r--chrome/common/chrome_switches.cc12
-rw-r--r--chrome/common/chrome_switches.h3
-rw-r--r--chrome/common/cloud_print/cloud_print_constants.cc1
-rw-r--r--chrome/common/cloud_print/cloud_print_constants.h2
-rw-r--r--chrome/common/extensions/manifest_handlers/app_launch_info.cc18
-rw-r--r--chrome/common/pref_names.cc5
-rw-r--r--chrome/common/pref_names.h2
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy_backend.cc2
-rw-r--r--chrome/service/cloud_print/connector_settings.cc16
-rw-r--r--chrome/service/cloud_print/connector_settings_unittest.cc3
-rw-r--r--cloud_print/DEPS1
-rw-r--r--cloud_print/service/service.gyp1
-rw-r--r--cloud_print/service/win/chrome_launcher.cc25
-rw-r--r--cloud_print/service/win/service_utils.cc3
-rw-r--r--components/cloud_devices.gypi5
-rw-r--r--components/cloud_devices/common/DEPS4
-rw-r--r--components/cloud_devices/common/cloud_devices_switches.cc21
-rw-r--r--components/cloud_devices/common/cloud_devices_switches.h16
-rw-r--r--components/cloud_devices/common/cloud_devices_urls.cc119
-rw-r--r--components/cloud_devices/common/cloud_devices_urls.h31
-rw-r--r--components/cloud_devices/common/cloud_devices_urls_unittest.cc87
-rw-r--r--components/components_tests.gyp1
47 files changed, 379 insertions, 459 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index c9507de..59db60e 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -98,6 +98,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chromeos/chromeos_constants.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/browser/nacl_host_message_filter.h"
#include "components/nacl/browser/nacl_process_host.h"
@@ -1571,7 +1572,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kAllowNaClFileHandleAPI,
switches::kAppsCheckoutURL,
switches::kAppsGalleryURL,
- switches::kCloudPrintServiceURL,
+ switches::kCloudPrintURL,
switches::kCloudPrintXmppEndpoint,
switches::kDisableBundledPpapiFlash,
switches::kDisableExtensionsResourceWhitelist,
diff --git a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
index 7798bc6..42d9377 100644
--- a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
+++ b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
@@ -8,9 +8,9 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/cloud_print_private.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -25,7 +25,8 @@ class ExtensionCloudPrintPrivateApiTest : public ExtensionApiTest {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionApiTest::SetUpCommandLine(command_line);
- command_line->AppendSwitchASCII(switches::kCloudPrintServiceURL,
+ command_line->AppendSwitchASCII(
+ switches::kCloudPrintURL,
"http://www.cloudprintapp.com/files/extensions/api_test/"
"cloud_print_private");
}
diff --git a/chrome/browser/local_discovery/cloud_print_printer_list.cc b/chrome/browser/local_discovery/cloud_print_printer_list.cc
index 4dc0479..8849073 100644
--- a/chrome/browser/local_discovery/cloud_print_printer_list.cc
+++ b/chrome/browser/local_discovery/cloud_print_printer_list.cc
@@ -7,30 +7,24 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/local_discovery/cloud_print_printer_list.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
namespace local_discovery {
-namespace {
-const char kPrinterListURLFormat[] = "%s/search";
-}
-
CloudPrintPrinterList::CloudPrintPrinterList(
net::URLRequestContextGetter* request_context,
- const std::string& cloud_print_url,
OAuth2TokenService* token_service,
const std::string& account_id,
Delegate* delegate)
: request_context_(request_context),
- url_(base::StringPrintf(kPrinterListURLFormat, cloud_print_url.c_str())),
delegate_(delegate),
api_flow_(request_context_,
token_service,
account_id,
- url_,
+ cloud_devices::GetCloudPrintRelativeURL("search"),
this) {
}
-
CloudPrintPrinterList::~CloudPrintPrinterList() {
}
diff --git a/chrome/browser/local_discovery/cloud_print_printer_list.h b/chrome/browser/local_discovery/cloud_print_printer_list.h
index ba0c31c..f3333b6 100644
--- a/chrome/browser/local_discovery/cloud_print_printer_list.h
+++ b/chrome/browser/local_discovery/cloud_print_printer_list.h
@@ -37,7 +37,6 @@ class CloudPrintPrinterList : public GCDBaseApiFlow::Delegate {
typedef PrinterList::const_iterator iterator;
CloudPrintPrinterList(net::URLRequestContextGetter* request_context,
- const std::string& cloud_print_url,
OAuth2TokenService* token_service,
const std::string& account_id,
Delegate* delegate);
@@ -69,7 +68,6 @@ class CloudPrintPrinterList : public GCDBaseApiFlow::Delegate {
PrinterDetails* printer_details);
scoped_refptr<net::URLRequestContextGetter> request_context_;
- GURL url_;
PrinterIDMap printer_id_map_;
PrinterList printer_list_;
Delegate* delegate_;
diff --git a/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc b/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
index 5bc121c..f312898 100644
--- a/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
+++ b/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/local_discovery/cloud_print_printer_list.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "content/public/test/test_browser_thread.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -56,7 +57,6 @@ class CloudPrintPrinterListTest : public testing::Test {
token_service_.AddAccount("account_id");
printer_list_.reset(
new CloudPrintPrinterList(request_context_.get(),
- "http://SoMeUrL.com/cloudprint",
&token_service_,
"account_id",
&delegate_));
@@ -88,7 +88,7 @@ class CloudPrintPrinterListTest : public testing::Test {
TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) {
fetcher_factory_->SetFakeResponse(
- GURL("http://SoMeUrL.com/cloudprint/search"),
+ cloud_devices::GetCloudPrintRelativeURL("search"),
kSampleSuccessResponseOAuth,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
diff --git a/chrome/browser/local_discovery/gcd_base_api_flow.cc b/chrome/browser/local_discovery/gcd_base_api_flow.cc
index 118b77d..d780cfb 100644
--- a/chrome/browser/local_discovery/gcd_base_api_flow.cc
+++ b/chrome/browser/local_discovery/gcd_base_api_flow.cc
@@ -9,8 +9,8 @@
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/local_discovery/gcd_constants.h"
-#include "chrome/browser/local_discovery/gcd_url.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/base/load_flags.h"
#include "net/base/url_util.h"
@@ -50,9 +50,9 @@ GCDBaseApiFlow::~GCDBaseApiFlow() {}
void GCDBaseApiFlow::Start() {
OAuth2TokenService::ScopeSet oauth_scopes;
if (delegate_->GCDIsCloudPrint()) {
- oauth_scopes.insert(cloud_print::kCloudPrintAuth);
+ oauth_scopes.insert(cloud_devices::kCloudPrintAuthScope);
} else {
- oauth_scopes.insert(kGCDOAuthScope);
+ oauth_scopes.insert(cloud_devices::kCloudDevicesAuthScope);
}
oauth_request_ =
token_service_->StartRequest(account_id_, oauth_scopes, this);
diff --git a/chrome/browser/local_discovery/gcd_constants.cc b/chrome/browser/local_discovery/gcd_constants.cc
index c622235..b5b63cc 100644
--- a/chrome/browser/local_discovery/gcd_constants.cc
+++ b/chrome/browser/local_discovery/gcd_constants.cc
@@ -6,8 +6,6 @@
namespace local_discovery {
-const char kGCDOAuthScope[] = "https://www.googleapis.com/auth/clouddevices";
-const char kGCDDefaultUrl[] = "https://www.googleapis.com/clouddevices/v1";
const char kGCDKeyKind[] = "kind";
} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/gcd_constants.h b/chrome/browser/local_discovery/gcd_constants.h
index 9c16b08..c51d15e 100644
--- a/chrome/browser/local_discovery/gcd_constants.h
+++ b/chrome/browser/local_discovery/gcd_constants.h
@@ -7,8 +7,6 @@
namespace local_discovery {
-extern const char kGCDOAuthScope[];
-extern const char kGCDDefaultUrl[];
extern const char kGCDKeyKind[];
} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/gcd_url.cc b/chrome/browser/local_discovery/gcd_url.cc
deleted file mode 100644
index ee69b99..0000000
--- a/chrome/browser/local_discovery/gcd_url.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/local_discovery/gcd_url.h"
-
-#include "base/command_line.h"
-#include "chrome/browser/local_discovery/gcd_constants.h"
-#include "chrome/common/chrome_switches.h"
-
-namespace local_discovery {
-
-GURL GetGcdURL() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- GURL server_url =
- GURL(command_line.GetSwitchValueASCII(switches::kGCDServiceURL));
-
- if (!server_url.is_valid()) {
- server_url = GURL(kGCDDefaultUrl);
- }
-
- return server_url;
-}
-
-} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/gcd_url.h b/chrome/browser/local_discovery/gcd_url.h
deleted file mode 100644
index 6cfc0b80..0000000
--- a/chrome/browser/local_discovery/gcd_url.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_GCD_URL_H_
-#define CHROME_BROWSER_LOCAL_DISCOVERY_GCD_URL_H_
-
-#include "url/gurl.h"
-
-namespace local_discovery {
-
-GURL GetGcdURL();
-
-} // namespace local_discovery
-
-#endif // CHROME_BROWSER_LOCAL_DISCOVERY_GCD_URL_H_
diff --git a/chrome/browser/local_discovery/privet_confirm_api_flow.cc b/chrome/browser/local_discovery/privet_confirm_api_flow.cc
index 40ba039..c12a977 100644
--- a/chrome/browser/local_discovery/privet_confirm_api_flow.cc
+++ b/chrome/browser/local_discovery/privet_confirm_api_flow.cc
@@ -10,35 +10,42 @@
#include "chrome/browser/local_discovery/gcd_constants.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
+#include "net/base/url_util.h"
namespace local_discovery {
namespace {
-const char kCloudPrintAutomatedClaimURLFormat[] = "%s/confirm?token=%s";
-const char kGCDAutomatedClaimURLFormat[] = "%s/registrationTickets/%s";
+
const char kGCDAutomatedClaimUploadData[] = "{ \"userEmail\": \"me\" }";
const char kGCDKindRegistrationTicket[] = "clouddevices#registrationTicket";
+
+GURL GetConfirmFlowUrl(bool is_cloud_print, const std::string& token) {
+ if (is_cloud_print) {
+ return net::AppendQueryParameter(
+ cloud_devices::GetCloudPrintRelativeURL("confirm"), "token", token);
+ }
+ return cloud_devices::GetCloudDevicesRelativeURL("registrationTickets/" +
+ token);
}
+} // namespace
+
PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow(
net::URLRequestContextGetter* request_context,
OAuth2TokenService* token_service,
const std::string& account_id,
bool is_cloud_print,
- const GURL& base_url,
const std::string& token,
const ResponseCallback& callback)
: is_cloud_print_(is_cloud_print),
flow_(request_context,
token_service,
account_id,
- GURL(base::StringPrintf((is_cloud_print)
- ? kCloudPrintAutomatedClaimURLFormat
- : kGCDAutomatedClaimURLFormat,
- base_url.spec().c_str(),
- token.c_str())),
+ GetConfirmFlowUrl(is_cloud_print, token),
this),
- callback_(callback) {}
+ callback_(callback) {
+}
PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() {
}
diff --git a/chrome/browser/local_discovery/privet_confirm_api_flow.h b/chrome/browser/local_discovery/privet_confirm_api_flow.h
index b22694e..6faf930 100644
--- a/chrome/browser/local_discovery/privet_confirm_api_flow.h
+++ b/chrome/browser/local_discovery/privet_confirm_api_flow.h
@@ -24,7 +24,6 @@ class PrivetConfirmApiCallFlow : public GCDBaseApiFlow::Delegate {
OAuth2TokenService* token_service_,
const std::string& account_id,
bool is_cloud_print,
- const GURL& base_url,
const std::string& token,
const ResponseCallback& callback);
diff --git a/chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc b/chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc
index b80698b..772f71b 100644
--- a/chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc
+++ b/chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc
@@ -82,8 +82,7 @@ TEST_F(PrivetConfirmApiFlowTest, SuccessOAuth2) {
&token_service_,
account_id_,
true,
- GURL("http://SoMeUrL.com/cloudprint"),
- "SomeCloudprintToken",
+ "SomeToken",
callback_.callback());
GCDBaseApiFlow* cloudprint_flow = confirm_flow.GetBaseApiFlowForTests();
@@ -92,9 +91,8 @@ TEST_F(PrivetConfirmApiFlowTest, SuccessOAuth2) {
cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time());
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
- EXPECT_EQ(
- GURL("http://SoMeUrL.com/cloudprint/confirm?token=SomeCloudprintToken"),
- fetcher->GetOriginalURL());
+ EXPECT_EQ(GURL("https://www.google.com/cloudprint/confirm?token=SomeToken"),
+ fetcher->GetOriginalURL());
net::HttpRequestHeaders headers;
fetcher->GetExtraRequestHeaders(&headers);
@@ -120,7 +118,6 @@ TEST_F(PrivetConfirmApiFlowTest, BadToken) {
&token_service_,
account_id_,
true,
- GURL("http://SoMeUrL.com/cloudprint"),
"SomeCloudprintToken",
callback_.callback());
@@ -138,8 +135,7 @@ TEST_F(PrivetConfirmApiFlowTest, ServerFailure) {
&token_service_,
account_id_,
true,
- GURL("http://SoMeUrL.com/cloudprint"),
- "SomeCloudprintToken",
+ "SomeToken",
callback_.callback());
confirm_flow.Start();
@@ -149,9 +145,8 @@ TEST_F(PrivetConfirmApiFlowTest, ServerFailure) {
cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time());
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
- EXPECT_EQ(
- GURL("http://SoMeUrL.com/cloudprint/confirm?token=SomeCloudprintToken"),
- fetcher->GetOriginalURL());
+ EXPECT_EQ(GURL("https://www.google.com/cloudprint/confirm?token=SomeToken"),
+ fetcher->GetOriginalURL());
fetcher->SetResponseString(kFailedConfirmResponse);
fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
@@ -168,8 +163,7 @@ TEST_F(PrivetConfirmApiFlowTest, BadJson) {
&token_service_,
account_id_,
true,
- GURL("http://SoMeUrL.com/cloudprint"),
- "SomeCloudprintToken",
+ "SomeToken",
callback_.callback());
confirm_flow.Start();
@@ -179,9 +173,8 @@ TEST_F(PrivetConfirmApiFlowTest, BadJson) {
cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time());
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
- EXPECT_EQ(
- GURL("http://SoMeUrL.com/cloudprint/confirm?token=SomeCloudprintToken"),
- fetcher->GetOriginalURL());
+ EXPECT_EQ(GURL("https://www.google.com/cloudprint/confirm?token=SomeToken"),
+ fetcher->GetOriginalURL());
fetcher->SetResponseString(kFailedConfirmResponseBadJson);
fetcher->set_status(net::URLRequestStatus(
@@ -200,7 +193,6 @@ TEST_F(PrivetConfirmApiFlowTest, SuccessGCD) {
&token_service_,
account_id_,
false,
- GURL("http://SoMeUrL.com/gcd"),
"SomeGcdToken",
callback_.callback());
GCDBaseApiFlow* gcd_flow = confirm_flow.GetBaseApiFlowForTests();
@@ -210,9 +202,8 @@ TEST_F(PrivetConfirmApiFlowTest, SuccessGCD) {
gcd_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time());
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
- EXPECT_EQ(GURL(
- "http://SoMeUrL.com/gcd/registrationTickets/"
- "SomeGcdToken"),
+ EXPECT_EQ(GURL("https://www.googleapis.com/clouddevices/v1/"
+ "registrationTickets/SomeGcdToken"),
fetcher->GetOriginalURL());
EXPECT_EQ("{ \"userEmail\": \"me\" }", fetcher->upload_data());
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index ed107fe..11c7aa5 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -56,7 +56,6 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/prefs/session_startup_pref.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/profiles/chrome_version_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -388,7 +387,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#if defined(ENABLE_FULL_PRINTING)
print_dialog_cloud::RegisterProfilePrefs(registry);
printing::StickySettings::RegisterProfilePrefs(registry);
- CloudPrintURL::RegisterProfilePrefs(registry);
#endif
#if defined(ENABLE_MANAGED_USERS)
diff --git a/chrome/browser/printing/cloud_print/cloud_print_url.cc b/chrome/browser/printing/cloud_print/cloud_print_url.cc
deleted file mode 100644
index 530e606..0000000
--- a/chrome/browser/printing/cloud_print/cloud_print_url.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
-
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/prefs/pref_service.h"
-#include "base/strings/stringprintf.h"
-#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "components/user_prefs/pref_registry_syncable.h"
-#include "google_apis/gaia/gaia_urls.h"
-#include "net/base/url_util.h"
-#include "url/gurl.h"
-
-// Url must not be matched by "urls" section of
-// cloud_print_app/manifest.json. If it's matched, print driver dialog will
-// open sign-in page in separate window.
-const char kDefaultCloudPrintServiceURL[] = "https://www.google.com/cloudprint";
-
-const char kLearnMoreURL[] =
- "https://www.google.com/support/cloudprint";
-const char kTestPageURL[] =
- "http://www.google.com/landing/cloudprint/enable.html?print=true";
-
-// static
-void CloudPrintURL::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- GURL cloud_print_url(
- command_line->GetSwitchValueASCII(switches::kCloudPrintServiceURL));
- if (cloud_print_url.is_empty())
- cloud_print_url = GURL(kDefaultCloudPrintServiceURL);
- registry->RegisterStringPref(
- prefs::kCloudPrintServiceURL,
- cloud_print_url.spec(),
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
- GURL gaia_url(GaiaUrls::GetInstance()->service_login_url());
- gaia_url = net::AppendQueryParameter(gaia_url, "service", "cloudprint");
- gaia_url = net::AppendQueryParameter(gaia_url, "sarp", "1");
- gaia_url = net::AppendQueryParameter(gaia_url, "continue",
- cloud_print_url.spec());
- registry->RegisterStringPref(
- prefs::kCloudPrintSigninURL,
- gaia_url.spec(),
- user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-}
-
-// Returns the root service URL for the cloud print service. The default is to
-// point at the Google Cloud Print service. This can be overridden by the
-// command line or by the user preferences.
-GURL CloudPrintURL::GetCloudPrintServiceURL() {
- DCHECK(profile_);
- return GURL(profile_->GetPrefs()->GetString(prefs::kCloudPrintServiceURL));
-}
-
-GURL CloudPrintURL::GetCloudPrintSigninURL() {
- DCHECK(profile_);
- GURL cloud_print_signin_url(
- profile_->GetPrefs()->GetString(prefs::kCloudPrintSigninURL));
- return google_util::AppendGoogleLocaleParam(cloud_print_signin_url);
-}
-
-GURL CloudPrintURL::GetCloudPrintAddAccountURL() {
- DCHECK(profile_);
- GURL url(GaiaUrls::GetInstance()->add_account_url());
- url = net::AppendQueryParameter(url, "service", "cloudprint");
- url = net::AppendQueryParameter(url, "sarp", "1");
- url = net::AppendQueryParameter(
- url,
- "continue",
- profile_->GetPrefs()->GetString(prefs::kCloudPrintServiceURL));
- return google_util::AppendGoogleLocaleParam(url);
-}
-
-GURL CloudPrintURL::GetCloudPrintServiceDialogURL() {
- GURL cloud_print_service_url = GetCloudPrintServiceURL();
- std::string path(cloud_print_service_url.path() + "/client/dialog.html");
- GURL::Replacements replacements;
- replacements.SetPathStr(path);
- GURL cloud_print_dialog_url = cloud_print_service_url.ReplaceComponents(
- replacements);
- return google_util::AppendGoogleLocaleParam(cloud_print_dialog_url);
-}
-
-GURL CloudPrintURL::GetCloudPrintServiceManageURL() {
- GURL cloud_print_service_url = GetCloudPrintServiceURL();
- std::string path(cloud_print_service_url.path() + "/manage.html");
- GURL::Replacements replacements;
- replacements.SetPathStr(path);
- GURL cloud_print_manage_url = cloud_print_service_url.ReplaceComponents(
- replacements);
- return cloud_print_manage_url;
-}
-
-GURL CloudPrintURL::GetCloudPrintServiceEnableURL(
- const std::string& proxy_id) {
- GURL cloud_print_service_url = GetCloudPrintServiceURL();
- std::string path(cloud_print_service_url.path() +
- "/enable_chrome_connector/enable.html");
- GURL::Replacements replacements;
- replacements.SetPathStr(path);
- std::string query = base::StringPrintf("proxy=%s", proxy_id.c_str());
- replacements.SetQueryStr(query);
- GURL cloud_print_enable_url = cloud_print_service_url.ReplaceComponents(
- replacements);
- return cloud_print_enable_url;
-}
-
-GURL CloudPrintURL::GetCloudPrintLearnMoreURL() {
- GURL cloud_print_learn_more_url(kLearnMoreURL);
- return cloud_print_learn_more_url;
-}
-
-GURL CloudPrintURL::GetCloudPrintTestPageURL() {
- GURL cloud_print_learn_more_url(kTestPageURL);
- return cloud_print_learn_more_url;
-}
diff --git a/chrome/browser/printing/cloud_print/cloud_print_url.h b/chrome/browser/printing/cloud_print/cloud_print_url.h
deleted file mode 100644
index a328ec1..0000000
--- a/chrome/browser/printing/cloud_print/cloud_print_url.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_URL_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_URL_H_
-
-#include <string>
-
-class GURL;
-class Profile;
-
-namespace user_prefs {
-class PrefRegistrySyncable;
-}
-
-// Centralize URL management for the cloud print service.
-class CloudPrintURL {
- public:
- static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
-
- explicit CloudPrintURL(Profile* profile) : profile_(profile) {}
-
- GURL GetCloudPrintServiceURL();
- GURL GetCloudPrintServiceDialogURL();
- GURL GetCloudPrintServiceManageURL();
- GURL GetCloudPrintServiceEnableURL(const std::string& proxy_id);
- GURL GetCloudPrintSigninURL();
- GURL GetCloudPrintAddAccountURL();
-
- // These aren't derived from the service, but it makes sense to keep all the
- // URLs together, and this gives the unit tests access for testing.
- static GURL GetCloudPrintLearnMoreURL();
- static GURL GetCloudPrintTestPageURL();
-
- private:
- Profile* profile_;
-};
-
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_URL_H_
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index 5582f3b..740664c 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -15,8 +15,8 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/devtools/devtools_window.h"
+#include "chrome/browser/google/google_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/printing/print_dialog_cloud_internal.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -25,6 +25,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/url_constants.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
@@ -335,9 +336,8 @@ void CloudPrintFlowHandler::RegisterMessages() {
&web_ui()->GetWebContents()->GetController();
NavigationEntry* pending_entry = controller->GetPendingEntry();
if (pending_entry) {
- Profile* profile = Profile::FromWebUI(web_ui());
- pending_entry->SetURL(
- CloudPrintURL(profile).GetCloudPrintServiceDialogURL());
+ pending_entry->SetURL(google_util::AppendGoogleLocaleParam(
+ cloud_devices::GetCloudPrintRelativeURL("client/dialog.html")));
}
registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(controller));
@@ -477,8 +477,7 @@ void CloudPrintFlowHandler::StoreDialogClientSize() const {
}
bool CloudPrintFlowHandler::IsCloudPrintDialogUrl(const GURL& url) {
- GURL cloud_print_url =
- CloudPrintURL(Profile::FromWebUI(web_ui())).GetCloudPrintServiceURL();
+ GURL cloud_print_url = cloud_devices::GetCloudPrintURL();
return IsSimilarUrl(url, cloud_print_url);
}
@@ -712,16 +711,15 @@ void CreateCloudPrintSigninTab(Browser* browser,
bool add_account,
const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- CloudPrintURL cp_url(browser->profile());
- content::WebContents* web_contents =
- browser->OpenURL(
- content::OpenURLParams(add_account ?
- cp_url.GetCloudPrintAddAccountURL() :
- cp_url.GetCloudPrintSigninURL(),
- content::Referrer(), NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_AUTO_BOOKMARK,
- false));
- new SignInObserver(web_contents, cp_url.GetCloudPrintServiceURL(), callback);
+ GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL()
+ : cloud_devices::GetCloudPrintSigninURL();
+ content::WebContents* web_contents = browser->OpenURL(
+ content::OpenURLParams(google_util::AppendGoogleLocaleParam(url),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_AUTO_BOOKMARK,
+ false));
+ new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), callback);
}
void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc
index 8d44ace..c29721e 100644
--- a/chrome/browser/printing/print_dialog_cloud_unittest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc
@@ -17,10 +17,9 @@
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
-#include "chrome/test/base/testing_profile.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
@@ -138,70 +137,6 @@ class MockCloudPrintDataSenderHelper : public CloudPrintDataSenderHelper {
const base::Value& arg2));
};
-class CloudPrintURLTest : public testing::Test {
- public:
- CloudPrintURLTest() {}
-
- protected:
- virtual void SetUp() {
- profile_.reset(new TestingProfile());
- }
-
- scoped_ptr<Profile> profile_;
-};
-
-TEST_F(CloudPrintURLTest, CheckDefaultURLs) {
- std::string service_url =
- CloudPrintURL(profile_.get()).
- GetCloudPrintServiceURL().spec();
- EXPECT_THAT(service_url, HasSubstr("www.google.com"));
- EXPECT_THAT(service_url, HasSubstr("cloudprint"));
-
- std::string dialog_url =
- CloudPrintURL(profile_.get()).
- GetCloudPrintServiceDialogURL().spec();
- EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
- EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
- EXPECT_THAT(dialog_url, HasSubstr("/client/"));
- EXPECT_THAT(dialog_url, Not(HasSubstr("cloudprint/cloudprint")));
- EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));
-
- // Repeat to make sure there isn't a transient glitch.
- dialog_url =
- CloudPrintURL(profile_.get()).
- GetCloudPrintServiceDialogURL().spec();
- EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
- EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
- EXPECT_THAT(dialog_url, HasSubstr("/client/"));
- EXPECT_THAT(dialog_url, Not(HasSubstr("cloudprint/cloudprint")));
- EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));
-
- std::string manage_url =
- CloudPrintURL(profile_.get()).
- GetCloudPrintServiceManageURL().spec();
- EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
- EXPECT_THAT(manage_url, HasSubstr("/cloudprint/"));
- EXPECT_THAT(manage_url, Not(HasSubstr("/client/")));
- EXPECT_THAT(manage_url, Not(HasSubstr("cloudprint/cloudprint")));
- EXPECT_THAT(manage_url, HasSubstr("/manage"));
-
- GURL learn_more_url = CloudPrintURL::GetCloudPrintLearnMoreURL();
- std::string learn_more_path = learn_more_url.spec();
- EXPECT_THAT(learn_more_path, HasSubstr("www.google.com"));
- EXPECT_THAT(learn_more_path, HasSubstr("/support/"));
- EXPECT_THAT(learn_more_path, HasSubstr("/cloudprint"));
- EXPECT_TRUE(learn_more_url.has_path());
- EXPECT_FALSE(learn_more_url.has_query());
-
- GURL test_page_url = CloudPrintURL::GetCloudPrintTestPageURL();
- std::string test_page_path = test_page_url.spec();
- EXPECT_THAT(test_page_path, HasSubstr("www.google.com"));
- EXPECT_THAT(test_page_path, HasSubstr("/landing/"));
- EXPECT_THAT(test_page_path, HasSubstr("/cloudprint/"));
- EXPECT_TRUE(test_page_url.has_path());
- EXPECT_TRUE(test_page_url.has_query());
-}
-
// Testing for CloudPrintDataSender needs a mock WebUI.
class CloudPrintDataSenderTest : public testing::Test {
public:
diff --git a/chrome/browser/service_process/service_process_control.cc b/chrome/browser/service_process/service_process_control.cc
index 4cd3a3a2..b9cfa57 100644
--- a/chrome/browser/service_process/service_process_control.cc
+++ b/chrome/browser/service_process/service_process_control.cc
@@ -21,6 +21,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/service_messages.h"
#include "chrome/common/service_process_util.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/child_process_host.h"
@@ -135,8 +136,8 @@ void ServiceProcessControl::Launch(const base::Closure& success_task,
switches::kServiceProcess);
static const char* const kSwitchesToCopy[] = {
- switches::kCloudPrintServiceURL,
switches::kCloudPrintSetupProxy,
+ switches::kCloudPrintURL,
switches::kCloudPrintXmppEndpoint,
#if defined(OS_WIN)
switches::kEnableCloudPrintXps,
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
index 198a019a..485d3c8 100644
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
@@ -13,7 +13,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/local_discovery/gcd_url.h"
#include "chrome/browser/local_discovery/privet_confirm_api_flow.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "chrome/browser/local_discovery/privet_device_lister_impl.h"
@@ -22,7 +21,6 @@
#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
@@ -31,15 +29,16 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "content/public/browser/user_metrics.h"
-#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/page_transition_types.h"
#include "grit/generated_resources.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_util.h"
+#include "net/base/url_util.h"
#include "net/http/http_status_code.h"
#include "ui/base/l10n/l10n_util.h"
@@ -189,12 +188,11 @@ void LocalDiscoveryUIHandler::HandleRequestPrinterList(
SigninManagerBase* signin_manager =
SigninManagerFactory::GetInstance()->GetForProfile(profile);
- cloud_print_printer_list_.reset(new CloudPrintPrinterList(
- profile->GetRequestContext(),
- GetCloudPrintBaseUrl(),
- token_service,
- signin_manager->GetAuthenticatedAccountId(),
- this));
+ cloud_print_printer_list_.reset(
+ new CloudPrintPrinterList(profile->GetRequestContext(),
+ token_service,
+ signin_manager->GetAuthenticatedAccountId(),
+ this));
cloud_print_printer_list_->Start();
}
@@ -204,7 +202,7 @@ void LocalDiscoveryUIHandler::HandleOpenCloudPrintURL(
bool rv = args->GetString(0, &url);
DCHECK(rv);
- GURL url_full(GetCloudPrintBaseUrl() + url);
+ GURL url_full(cloud_devices::GetCloudPrintRelativeURL(url));
Browser* browser = chrome::FindBrowserWithWebContents(
web_ui()->GetWebContents());
@@ -277,14 +275,11 @@ void LocalDiscoveryUIHandler::OnPrivetRegisterClaimToken(
return;
}
- GURL base_url = (is_cloud_print) ? GURL(GetCloudPrintBaseUrl()) : GetGcdURL();
-
confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow(
profile->GetRequestContext(),
token_service,
signin_manager->GetAuthenticatedAccountId(),
is_cloud_print,
- base_url,
token,
base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone,
base::Unretained(this))));
@@ -469,12 +464,6 @@ std::string LocalDiscoveryUIHandler::GetSyncAccount() {
return signin_manager->GetAuthenticatedUsername();
}
-std::string LocalDiscoveryUIHandler::GetCloudPrintBaseUrl() {
- CloudPrintURL cloud_print_url(Profile::FromWebUI(web_ui()));
-
- return cloud_print_url.GetCloudPrintServiceURL().spec();
-}
-
// TODO(noamsml): Create master object for registration flow.
void LocalDiscoveryUIHandler::ResetCurrentRegistration() {
if (current_register_operation_.get()) {
@@ -543,9 +532,12 @@ void LocalDiscoveryUIHandler::ShowCloudPrintSetupDialog(
// Open the connector enable page in the current tab.
Profile* profile = Profile::FromWebUI(web_ui());
content::OpenURLParams params(
- CloudPrintURL(profile).GetCloudPrintServiceEnableURL(
+ cloud_devices::GetCloudPrintEnableURL(
CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()),
- content::Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
+ content::Referrer(),
+ CURRENT_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false);
web_ui()->GetWebContents()->OpenURL(params);
}
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
index 706043b..1929063 100644
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
@@ -130,9 +130,6 @@ class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
// Get the sync account email.
std::string GetSyncAccount();
- // Get the base cloud print URL.
- std::string GetCloudPrintBaseUrl();
-
// Reset and cancel the current registration.
void ResetCurrentRegistration();
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 0cdf249..beeb8d5 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -34,7 +34,6 @@
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
#include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index a6ec0c6..1250aecf 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -27,7 +27,6 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_error_dialog.h"
#include "chrome/browser/printing/print_job_manager.h"
@@ -49,6 +48,7 @@
#include "chrome/common/crash_keys.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_manager_base.h"
@@ -432,7 +432,7 @@ class PrintPreviewHandler::AccessTokenService
if (service) {
OAuth2TokenService::ScopeSet oauth_scopes;
- oauth_scopes.insert(cloud_print::kCloudPrintAuth);
+ oauth_scopes.insert(cloud_devices::kCloudPrintAuthScope);
scoped_ptr<OAuth2TokenService::Request> request(
service->StartRequest(account_id, oauth_scopes, this));
requests_[type].reset(request.release());
@@ -955,15 +955,12 @@ void PrintPreviewHandler::PrintWithCloudPrintDialog() {
void PrintPreviewHandler::HandleManageCloudPrint(
const base::ListValue* /*args*/) {
++manage_cloud_printers_dialog_request_count_;
- Profile* profile = Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext());
- preview_web_contents()->OpenURL(
- content::OpenURLParams(
- CloudPrintURL(profile).GetCloudPrintServiceManageURL(),
- content::Referrer(),
- NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK,
- false));
+ preview_web_contents()->OpenURL(content::OpenURLParams(
+ cloud_devices::GetCloudPrintRelativeURL("manage.html"),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false));
}
void PrintPreviewHandler::HandleShowSystemDialog(
@@ -1178,7 +1175,7 @@ void PrintPreviewHandler::SendCloudPrintEnabled() {
preview_web_contents()->GetBrowserContext());
PrefService* prefs = profile->GetPrefs();
if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) {
- GURL gcp_url(CloudPrintURL(profile).GetCloudPrintServiceURL());
+ GURL gcp_url(cloud_devices::GetCloudPrintURL());
base::StringValue gcp_url_value(gcp_url.spec());
web_ui()->CallJavascriptFunction("setUseCloudPrint", gcp_url_value);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index f6cdc8b..922635e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -980,8 +980,6 @@
'browser/local_discovery/gcd_base_api_flow.h',
'browser/local_discovery/gcd_constants.cc',
'browser/local_discovery/gcd_constants.h',
- 'browser/local_discovery/gcd_url.cc',
- 'browser/local_discovery/gcd_url.h',
'browser/local_discovery/privet_confirm_api_flow.cc',
'browser/local_discovery/privet_confirm_api_flow.h',
'browser/local_discovery/privet_constants.cc',
@@ -1664,8 +1662,6 @@
'browser/printing/cloud_print/cloud_print_proxy_service.h',
'browser/printing/cloud_print/cloud_print_proxy_service_factory.cc',
'browser/printing/cloud_print/cloud_print_proxy_service_factory.h',
- 'browser/printing/cloud_print/cloud_print_url.cc',
- 'browser/printing/cloud_print/cloud_print_url.h',
'browser/printing/print_dialog_cloud.cc',
'browser/printing/print_dialog_cloud.h',
'browser/printing/print_error_dialog.cc',
diff --git a/chrome/common/DEPS b/chrome/common/DEPS
index 2ecbccd..23a65ab 100644
--- a/chrome/common/DEPS
+++ b/chrome/common/DEPS
@@ -5,6 +5,7 @@ include_rules = [
"+components/autofill/content/common",
"+components/autofill/core/common",
"+components/bookmarks/core/common",
+ "+components/cloud_devices/common",
"+components/data_reduction_proxy/common",
"+components/nacl/common",
"+components/password_manager/core/common",
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index dae8fc3..24b420d 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -153,9 +153,6 @@ const char kCheckCloudPrintConnectorPolicy[] =
// Comma-separated list of SSL cipher suites to disable.
const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
-// The URL of the cloud devices service to use.
-const char kGCDServiceURL[] = "gcd-url";
-
// Tells chrome to display the cloud print dialog and upload the specified file
// for printing.
const char kCloudPrintFile[] = "cloud-print-file";
@@ -176,15 +173,6 @@ const char kCloudPrintJobTitle[] = "cloud-print-job-title";
// service or register proxy for autostart.
const char kCloudPrintSetupProxy[] = "cloud-print-setup-proxy";
-// The URL of the cloud print service to use, overrides any value stored in
-// preferences, and the default. Only used if the cloud print service has been
-// enabled. Used for testing.
-const char kCloudPrintServiceURL[] = "cloud-print-url";
-
-// The XMPP endpoint the cloud print service will use. Only used if the cloud
-// print service has been enabled. Used for testing.
-const char kCloudPrintXmppEndpoint[] = "cloud-print-xmpp-endpoint";
-
// Comma-separated options to troubleshoot the component updater. Only valid
// for the browser process.
const char kComponentUpdater[] = "component-updater";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 9522504..a35f16e 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -57,14 +57,11 @@ extern const char kCertificateTransparencyLog[];
extern const char kCheckForUpdateIntervalSec[];
extern const char kCheckCloudPrintConnectorPolicy[];
extern const char kCipherSuiteBlacklist[];
-extern const char kGCDServiceURL[];
extern const char kCloudPrintFile[];
extern const char kCloudPrintJobTitle[];
extern const char kCloudPrintFileType[];
extern const char kCloudPrintPrintTicket[];
extern const char kCloudPrintSetupProxy[];
-extern const char kCloudPrintServiceURL[];
-extern const char kCloudPrintXmppEndpoint[];
extern const char kComponentUpdater[];
extern const char kConflictingModulesCheck[];
extern const char kCrashOnHangThreads[];
diff --git a/chrome/common/cloud_print/cloud_print_constants.cc b/chrome/common/cloud_print/cloud_print_constants.cc
index 7764198..e9a641e 100644
--- a/chrome/common/cloud_print/cloud_print_constants.cc
+++ b/chrome/common/cloud_print/cloud_print_constants.cc
@@ -9,7 +9,6 @@ namespace cloud_print {
const char kCloudPrintUserAgent[] = "GoogleCloudPrintProxy";
const char kChromeCloudPrintProxyHeader[] = "X-CloudPrint-Proxy: Chrome";
const char kCloudPrintPushNotificationsSource[] = "cloudprint.google.com";
-const char kCloudPrintAuth[] = "https://www.googleapis.com/auth/cloudprint";
const char kProxyIdValue[] = "proxy";
const char kPrinterNameValue[] = "printer";
diff --git a/chrome/common/cloud_print/cloud_print_constants.h b/chrome/common/cloud_print/cloud_print_constants.h
index 8422209..864ae79 100644
--- a/chrome/common/cloud_print/cloud_print_constants.h
+++ b/chrome/common/cloud_print/cloud_print_constants.h
@@ -15,8 +15,6 @@ extern const char kCloudPrintUserAgent[];
extern const char kChromeCloudPrintProxyHeader[];
// The source of cloud print notifications.
extern const char kCloudPrintPushNotificationsSource[];
-// The cloud print OAuth2 scope.
-extern const char kCloudPrintAuth[];
// Values used to register or update a printer with the cloud print service.
extern const char kProxyIdValue[];
diff --git a/chrome/common/extensions/manifest_handlers/app_launch_info.cc b/chrome/common/extensions/manifest_handlers/app_launch_info.cc
index a3b3ac5..18ec3ab 100644
--- a/chrome/common/extensions/manifest_handlers/app_launch_info.cc
+++ b/chrome/common/extensions/manifest_handlers/app_launch_info.cc
@@ -12,6 +12,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
@@ -205,19 +206,10 @@ bool AppLaunchInfo::LoadLaunchURL(Extension* extension, base::string16* error) {
} else if (extension->id() == extension_misc::kCloudPrintAppId) {
// In order for the --cloud-print-service switch to work, we must update
// the launch URL and web extent.
- // TODO(sanjeevr): Ideally we want to use CloudPrintURL here but that is
- // currently under chrome/browser.
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- GURL cloud_print_service_url = GURL(command_line.GetSwitchValueASCII(
- switches::kCloudPrintServiceURL));
- if (!cloud_print_service_url.is_empty()) {
- std::string path(
- cloud_print_service_url.path() + "/enable_chrome_connector");
- GURL::Replacements replacements;
- replacements.SetPathStr(path);
- GURL cloud_print_enable_connector_url =
- cloud_print_service_url.ReplaceComponents(replacements);
- OverrideLaunchURL(extension, cloud_print_enable_connector_url);
+ GURL url =
+ cloud_devices::GetCloudPrintRelativeURL("enable_chrome_connector");
+ if (!url.is_empty()) {
+ OverrideLaunchURL(extension, url);
}
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index e77b53b..31f79af 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1887,11 +1887,6 @@ const char kRemoteAccessHostAllowGnubbyAuth[] =
// The last used printer and its settings.
const char kPrintPreviewStickySettings[] =
"printing.print_preview_sticky_settings";
-// The root URL of the cloud print service.
-const char kCloudPrintServiceURL[] = "cloud_print.service_url";
-
-// The URL to use to sign in to cloud print.
-const char kCloudPrintSigninURL[] = "cloud_print.signin_url";
// The last requested size of the dialog as it was closed.
const char kCloudPrintDialogWidth[] = "cloud_print.dialog_size.width";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index a7c6158..6267052 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -632,8 +632,6 @@ extern const char kRemoteAccessHostAllowGnubbyAuth[];
extern const char kPrintPreviewStickySettings[];
extern const char kCloudPrintRoot[];
-extern const char kCloudPrintServiceURL[];
-extern const char kCloudPrintSigninURL[];
extern const char kCloudPrintDialogWidth[];
extern const char kCloudPrintDialogHeight[];
extern const char kCloudPrintSigninDialogWidth[];
diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
index de44436..52205cd 100644
--- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
@@ -13,7 +13,6 @@
#include "base/metrics/histogram.h"
#include "base/rand_util.h"
#include "base/values.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "chrome/service/cloud_print/cloud_print_auth.h"
#include "chrome/service/cloud_print/cloud_print_connector.h"
@@ -22,6 +21,7 @@
#include "chrome/service/cloud_print/connector_settings.h"
#include "chrome/service/net/service_url_request_context.h"
#include "chrome/service/service_process.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
#include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/gaia_urls.h"
#include "grit/generated_resources.h"
diff --git a/chrome/service/cloud_print/connector_settings.cc b/chrome/service/cloud_print/connector_settings.cc
index 35ed6eb..01eadc9 100644
--- a/chrome/service/cloud_print/connector_settings.cc
+++ b/chrome/service/cloud_print/connector_settings.cc
@@ -4,18 +4,16 @@
#include "chrome/service/cloud_print/connector_settings.h"
-#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "base/values.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/service/cloud_print/print_system.h"
#include "chrome/service/service_process_prefs.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
namespace {
-const char kDefaultCloudPrintServerUrl[] = "https://www.google.com/cloudprint";
const char kDeleteOnEnumFail[] = "delete_on_enum_fail";
const char kName[] = "name";
const char kConnect[] = "connect";
@@ -56,17 +54,7 @@ void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
}
// Check if there is an override for the cloud print server URL.
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- server_url_ =
- GURL(command_line.GetSwitchValueASCII(switches::kCloudPrintServiceURL));
- if (server_url_.is_empty() || !server_url_.is_valid()) {
- server_url_ =
- GURL(prefs->GetString(prefs::kCloudPrintServiceURL, std::string()));
- DCHECK(server_url_.is_empty() || server_url_.is_valid());
- if (server_url_.is_empty() || !server_url_.is_valid()) {
- server_url_ = GURL(kDefaultCloudPrintServerUrl);
- }
- }
+ server_url_ = cloud_devices::GetCloudPrintURL();
DCHECK(server_url_.is_valid());
connect_new_printers_ = prefs->GetBoolean(
diff --git a/chrome/service/cloud_print/connector_settings_unittest.cc b/chrome/service/cloud_print/connector_settings_unittest.cc
index 07f4717..b53c215 100644
--- a/chrome/service/cloud_print/connector_settings_unittest.cc
+++ b/chrome/service/cloud_print/connector_settings_unittest.cc
@@ -28,7 +28,6 @@ const char kServiceStateContent[] =
" 'proxy_id': 'PROXY',"
" 'robot_email': '123@cloudprint.googleusercontent.com',"
" 'robot_refresh_token': '123',"
- " 'service_url': 'http://cp.google.com',"
" 'xmpp_auth_token': 'xmp token',"
" 'xmpp_ping_enabled': true,"
" 'xmpp_ping_timeout_sec': 256,"
@@ -99,7 +98,7 @@ TEST_F(ConnectorSettingsTest, InitFromFile) {
scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kServiceStateContent));
ConnectorSettings settings;
settings.InitFrom(prefs.get());
- EXPECT_EQ("http://cp.google.com/", settings.server_url().spec());
+ EXPECT_EQ("https://www.google.com/cloudprint", settings.server_url().spec());
EXPECT_EQ("PROXY", settings.proxy_id());
EXPECT_FALSE(settings.proxy_id().empty());
EXPECT_TRUE(settings.delete_on_enum_fail());
diff --git a/cloud_print/DEPS b/cloud_print/DEPS
index 88a5403..25918c1 100644
--- a/cloud_print/DEPS
+++ b/cloud_print/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+chrome/common",
"+chrome/installer/launcher_support",
+ "+components/cloud_devices/common",
"+google_apis",
"+grit",
"+jingle/notifier",
diff --git a/cloud_print/service/service.gyp b/cloud_print/service/service.gyp
index f4bc65b..04d612d 100644
--- a/cloud_print/service/service.gyp
+++ b/cloud_print/service/service.gyp
@@ -54,6 +54,7 @@
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_static',
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '<(DEPTH)/components/components.gyp:cloud_devices_common',
'<(DEPTH)/google_apis/google_apis.gyp:google_apis',
'<(DEPTH)/ipc/ipc.gyp:ipc',
'<(DEPTH)/net/net.gyp:net',
diff --git a/cloud_print/service/win/chrome_launcher.cc b/cloud_print/service/win/chrome_launcher.cc
index 231ae84..650b502 100644
--- a/cloud_print/service/win/chrome_launcher.cc
+++ b/cloud_print/service/win/chrome_launcher.cc
@@ -23,6 +23,7 @@
#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/service/service_constants.h"
#include "cloud_print/service/win/service_utils.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
@@ -91,27 +92,6 @@ bool LaunchProcess(const CommandLine& cmdline,
return true;
}
-GURL GetCloudPrintServiceEnableURL(const std::string& proxy_id) {
- GURL url(
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kCloudPrintServiceURL));
- if (url.is_empty())
- url = GURL("https://www.google.com/cloudprint");
- url = net::AppendQueryParameter(url, "proxy", proxy_id);
- std::string url_path(url.path() + "/enable_chrome_connector/enable.html");
- GURL::Replacements replacements;
- replacements.SetPathStr(url_path);
- return url.ReplaceComponents(replacements);
-}
-
-GURL GetCloudPrintServiceEnableURLWithSignin(const std::string& proxy_id) {
- GURL url(GaiaUrls::GetInstance()->service_login_url());
- url = net::AppendQueryParameter(url, "service", "cloudprint");
- url = net::AppendQueryParameter(url, "sarp", "1");
- return net::AppendQueryParameter(
- url, "continue", GetCloudPrintServiceEnableURL(proxy_id).spec());
-}
-
std::string ReadAndUpdateServiceState(const base::FilePath& directory,
const std::string& proxy_id) {
std::string json;
@@ -311,7 +291,8 @@ std::string ChromeLauncher::CreateServiceStateFile(
cmd.AppendSwitch(switches::kNoDefaultBrowserCheck);
cmd.AppendSwitch(switches::kNoFirstRun);
- cmd.AppendArg(GetCloudPrintServiceEnableURLWithSignin(proxy_id).spec());
+ cmd.AppendArg(
+ cloud_devices::GetCloudPrintEnableURLWithSignin(proxy_id).spec());
base::win::ScopedHandle chrome_handle;
DWORD thread_id = 0;
diff --git a/cloud_print/service/win/service_utils.cc b/cloud_print/service/win/service_utils.cc
index 2d1d3a4..b71bca2 100644
--- a/cloud_print/service/win/service_utils.cc
+++ b/cloud_print/service/win/service_utils.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "chrome/common/chrome_switches.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
base::string16 GetLocalComputerName() {
DWORD size = 0;
@@ -49,7 +50,7 @@ base::string16 GetCurrentUserName() {
void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination) {
static const char* const kSwitchesToCopy[] = {
- switches::kCloudPrintServiceURL,
+ switches::kCloudPrintURL,
switches::kCloudPrintXmppEndpoint,
switches::kEnableCloudPrintXps,
switches::kEnableLogging,
diff --git a/components/cloud_devices.gypi b/components/cloud_devices.gypi
index 344ad68..abdcc75 100644
--- a/components/cloud_devices.gypi
+++ b/components/cloud_devices.gypi
@@ -12,12 +12,17 @@
],
'dependencies': [
'../base/base.gyp:base',
+ '../net/net.gyp:net',
],
'sources': [
'cloud_devices/common/cloud_device_description.cc',
'cloud_devices/common/cloud_device_description.h',
'cloud_devices/common/cloud_device_description_consts.cc',
'cloud_devices/common/cloud_device_description_consts.h',
+ 'cloud_devices/common/cloud_devices_switches.cc',
+ 'cloud_devices/common/cloud_devices_switches.h',
+ 'cloud_devices/common/cloud_devices_urls.cc',
+ 'cloud_devices/common/cloud_devices_urls.h',
'cloud_devices/common/description_items.h',
'cloud_devices/common/description_items_inl.h',
'cloud_devices/common/printer_description.cc',
diff --git a/components/cloud_devices/common/DEPS b/components/cloud_devices/common/DEPS
new file mode 100644
index 0000000..2d23c96
--- /dev/null
+++ b/components/cloud_devices/common/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+google_apis/gaia",
+ "+net/base",
+]
diff --git a/components/cloud_devices/common/cloud_devices_switches.cc b/components/cloud_devices/common/cloud_devices_switches.cc
new file mode 100644
index 0000000..83667fa
--- /dev/null
+++ b/components/cloud_devices/common/cloud_devices_switches.cc
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cloud_devices/common/cloud_devices_switches.h"
+
+namespace switches {
+
+// The URL of the cloud print service to use, overrides any value stored in
+// preferences, and the default. Only used if the cloud print service has been
+// enabled. Used for testing.
+const char kCloudPrintURL[] = "cloud-print-url";
+
+// The XMPP endpoint the cloud print service will use. Only used if the cloud
+// print service has been enabled. Used for testing.
+const char kCloudPrintXmppEndpoint[] = "cloud-print-xmpp-endpoint";
+
+// The URL of the cloud devices service to use.
+const char kCloudDevicesURL[] = "cloud-devices-url";
+
+} // namespace switches
diff --git a/components/cloud_devices/common/cloud_devices_switches.h b/components/cloud_devices/common/cloud_devices_switches.h
new file mode 100644
index 0000000..2a57d73
--- /dev/null
+++ b/components/cloud_devices/common/cloud_devices_switches.h
@@ -0,0 +1,16 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_SWITCHES_H_
+#define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_SWITCHES_H_
+
+namespace switches {
+
+extern const char kCloudPrintURL[];
+extern const char kCloudPrintXmppEndpoint[];
+extern const char kCloudDevicesURL[];
+
+} // namespace switches
+
+#endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_SWITCHES_H_
diff --git a/components/cloud_devices/common/cloud_devices_urls.cc b/components/cloud_devices/common/cloud_devices_urls.cc
new file mode 100644
index 0000000..7645429
--- /dev/null
+++ b/components/cloud_devices/common/cloud_devices_urls.cc
@@ -0,0 +1,119 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cloud_devices/common/cloud_devices_urls.h"
+
+#include "base/command_line.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "net/base/url_util.h"
+
+namespace cloud_devices {
+
+const char kCloudPrintAuthScope[] =
+ "https://www.googleapis.com/auth/cloudprint";
+
+const char kCloudDevicesAuthScope[] =
+ "https://www.googleapis.com/auth/clouddevices";
+
+const char kCloudPrintLearnMoreURL[] =
+ "https://www.google.com/support/cloudprint";
+
+const char kCloudPrintTestPageURL[] =
+ "http://www.google.com/landing/cloudprint/enable.html?print=true";
+
+namespace {
+
+// Url must not be matched by "urls" section of
+// cloud_print_app/manifest.json. If it's matched, print driver dialog will
+// open sign-in page in separate window.
+const char kCloudPrintURL[] = "https://www.google.com/cloudprint";
+
+const char kCloudDevicesUrl[] = "https://www.googleapis.com/clouddevices/v1";
+}
+
+// Returns the root service URL for the cloud print service. The default is to
+// point at the Google Cloud Print service. This can be overridden by the
+// command line or by the user preferences.
+GURL GetCloudPrintURL() {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ GURL cloud_print_url(
+ command_line->GetSwitchValueASCII(switches::kCloudPrintURL));
+ if (cloud_print_url.is_empty())
+ cloud_print_url = GURL(kCloudPrintURL);
+ return cloud_print_url;
+}
+
+GURL GetCloudPrintRelativeURL(const std::string& relative_path) {
+ GURL url = GetCloudPrintURL();
+ std::string path;
+ const char kURLPathSeparator[] = "/";
+ base::TrimString(url.path(), kURLPathSeparator, &path);
+ std::string trimmed_path;
+ base::TrimString(relative_path, kURLPathSeparator, &trimmed_path);
+ path += kURLPathSeparator;
+ path += trimmed_path;
+ GURL::Replacements replacements;
+ replacements.SetPathStr(path);
+ return url.ReplaceComponents(replacements);
+}
+
+GURL GetCloudPrintSigninURL() {
+ GURL url(GaiaUrls::GetInstance()->service_login_url());
+ url = net::AppendQueryParameter(url, "service", "cloudprint");
+ url = net::AppendQueryParameter(url, "sarp", "1");
+ std::string continue_str = GetCloudPrintURL().spec();
+ url = net::AppendQueryParameter(url, "continue", continue_str);
+ return url;
+}
+
+GURL GetCloudPrintAddAccountURL() {
+ GURL url(GaiaUrls::GetInstance()->add_account_url());
+ url = net::AppendQueryParameter(url, "service", "cloudprint");
+ url = net::AppendQueryParameter(url, "sarp", "1");
+ std::string continue_str = GetCloudPrintURL().spec();
+ url = net::AppendQueryParameter(url, "continue", continue_str);
+ return url;
+}
+
+GURL GetCloudPrintEnableURL(const std::string& proxy_id) {
+ GURL url = GetCloudPrintRelativeURL("enable_chrome_connector/enable.html");
+ url = net::AppendQueryParameter(url, "proxy", proxy_id);
+ return url;
+}
+
+GURL GetCloudPrintEnableURLWithSignin(const std::string& proxy_id) {
+ GURL url(GaiaUrls::GetInstance()->service_login_url());
+ url = net::AppendQueryParameter(url, "service", "cloudprint");
+ url = net::AppendQueryParameter(url, "sarp", "1");
+ std::string continue_str = GetCloudPrintEnableURL(proxy_id).spec();
+ return net::AppendQueryParameter(url, "continue", continue_str);
+}
+
+GURL GetCloudDevicesURL() {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ GURL cloud_print_url(
+ command_line->GetSwitchValueASCII(switches::kCloudDevicesURL));
+ if (cloud_print_url.is_empty())
+ cloud_print_url = GURL(kCloudDevicesUrl);
+ return cloud_print_url;
+}
+
+GURL GetCloudDevicesRelativeURL(const std::string& relative_path) {
+ GURL url = GetCloudDevicesURL();
+ std::string path;
+ const char kURLPathSeparator[] = "/";
+ base::TrimString(url.path(), kURLPathSeparator, &path);
+ std::string trimmed_path;
+ base::TrimString(relative_path, kURLPathSeparator, &trimmed_path);
+ path += kURLPathSeparator;
+ path += trimmed_path;
+ GURL::Replacements replacements;
+ replacements.SetPathStr(path);
+ return url.ReplaceComponents(replacements);
+}
+
+} // namespace cloud_devices
diff --git a/components/cloud_devices/common/cloud_devices_urls.h b/components/cloud_devices/common/cloud_devices_urls.h
new file mode 100644
index 0000000..8e03856
--- /dev/null
+++ b/components/cloud_devices/common/cloud_devices_urls.h
@@ -0,0 +1,31 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_URLS_H_
+#define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_URLS_H_
+
+#include <string>
+
+#include "url/gurl.h"
+
+namespace cloud_devices {
+
+extern const char kCloudPrintAuthScope[];
+extern const char kCloudDevicesAuthScope[];
+extern const char kCloudPrintLearnMoreURL[];
+extern const char kCloudPrintTestPageURL[];
+
+GURL GetCloudPrintURL();
+GURL GetCloudPrintRelativeURL(const std::string& relative_path);
+GURL GetCloudPrintEnableURL(const std::string& proxy_id);
+GURL GetCloudPrintEnableURLWithSignin(const std::string& proxy_id);
+GURL GetCloudPrintSigninURL();
+GURL GetCloudPrintAddAccountURL();
+
+GURL GetCloudDevicesURL();
+GURL GetCloudDevicesRelativeURL(const std::string& relative_path);
+
+} // namespace cloud_devices
+
+#endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICES_URLS_H_
diff --git a/components/cloud_devices/common/cloud_devices_urls_unittest.cc b/components/cloud_devices/common/cloud_devices_urls_unittest.cc
new file mode 100644
index 0000000..4a285c6
--- /dev/null
+++ b/components/cloud_devices/common/cloud_devices_urls_unittest.cc
@@ -0,0 +1,87 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cloud_devices/common/cloud_devices_urls.h"
+
+#include <string>
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::HasSubstr;
+
+namespace cloud_devices {
+
+TEST(CloudPrintURLTest, GetCloudPrintURL) {
+ std::string service_url = GetCloudPrintURL().spec();
+ EXPECT_THAT(service_url, HasSubstr("www.google.com"));
+ EXPECT_THAT(service_url, HasSubstr("cloudprint"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintRelativeURL) {
+ EXPECT_THAT(GetCloudPrintRelativeURL("///a/b/c///").spec(),
+ HasSubstr("/cloudprint/a/b/c"));
+
+ EXPECT_THAT(GetCloudPrintRelativeURL("a/b/c").spec(),
+ HasSubstr("/cloudprint/a/b/c"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintDialogUrl) {
+ std::string dialog_url =
+ GetCloudPrintRelativeURL("client/dialog.html").spec();
+ EXPECT_THAT(dialog_url, HasSubstr("www.google.com"));
+ EXPECT_THAT(dialog_url, HasSubstr("/cloudprint/"));
+ EXPECT_THAT(dialog_url, HasSubstr("/client/"));
+ EXPECT_THAT(dialog_url, Not(HasSubstr("cloudprint/cloudprint")));
+ EXPECT_THAT(dialog_url, HasSubstr("/dialog.html"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintManageUrl) {
+ std::string manage_url = GetCloudPrintRelativeURL("manage.html").spec();
+ EXPECT_THAT(manage_url, HasSubstr("www.google.com"));
+ EXPECT_THAT(manage_url, HasSubstr("/cloudprint/"));
+ EXPECT_THAT(manage_url, Not(HasSubstr("/client/")));
+ EXPECT_THAT(manage_url, Not(HasSubstr("cloudprint/cloudprint")));
+ EXPECT_THAT(manage_url, HasSubstr("/manage.html"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintEnableURL) {
+ std::string enable_url = GetCloudPrintEnableURL("123123").spec();
+ EXPECT_THAT(enable_url, HasSubstr("proxy=123123"));
+ EXPECT_THAT(enable_url, HasSubstr("/enable_chrome_connector/enable.html"));
+ EXPECT_THAT(enable_url, HasSubstr("/cloudprint/"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintEnableURLWithSignin) {
+ std::string enable_url = GetCloudPrintEnableURLWithSignin("123123").spec();
+ EXPECT_THAT(enable_url, HasSubstr("accounts.google.com"));
+ EXPECT_THAT(enable_url, HasSubstr("/ServiceLogin"));
+ EXPECT_THAT(enable_url, HasSubstr("service=cloudprint"));
+ EXPECT_THAT(enable_url, HasSubstr("continue="));
+ EXPECT_THAT(enable_url, HasSubstr("proxy%3D123123"));
+ EXPECT_THAT(enable_url, HasSubstr("%2Fenable_chrome_connector%2Fenable"));
+ EXPECT_THAT(enable_url, HasSubstr("%2Fcloudprint%2F"));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintSigninURL) {
+ std::string signin_url = GetCloudPrintSigninURL().spec();
+ EXPECT_THAT(signin_url, HasSubstr("accounts.google.com"));
+ EXPECT_THAT(signin_url, HasSubstr("/ServiceLogin"));
+ EXPECT_THAT(signin_url, HasSubstr("service=cloudprint"));
+ EXPECT_THAT(signin_url, HasSubstr("continue="));
+ EXPECT_THAT(signin_url, HasSubstr("%2Fcloudprint"));
+ EXPECT_THAT(signin_url, Not(HasSubstr("/cloudprint")));
+}
+
+TEST(CloudPrintURLTest, GetCloudPrintAddAccountURL) {
+ std::string add_url = GetCloudPrintAddAccountURL().spec();
+ EXPECT_THAT(add_url, HasSubstr("accounts.google.com"));
+ EXPECT_THAT(add_url, HasSubstr("/AddSession"));
+ EXPECT_THAT(add_url, HasSubstr("service=cloudprint"));
+ EXPECT_THAT(add_url, HasSubstr("continue="));
+ EXPECT_THAT(add_url, HasSubstr("%2Fcloudprint"));
+ EXPECT_THAT(add_url, Not(HasSubstr("/cloudprint")));
+}
+
+} // namespace cloud_devices
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index d9b67f8..cd07b05 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -64,6 +64,7 @@
'autofill/core/common/form_field_data_unittest.cc',
'autofill/core/common/password_form_fill_data_unittest.cc',
'autofill/core/common/save_password_progress_logger_unittest.cc',
+ 'cloud_devices/common/cloud_devices_urls_unittest.cc',
'cloud_devices/common/printer_description_unittest.cc',
'data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc',
'data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc',