Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: components/cloud_devices/common/cloud_devices_urls.cc

Issue 258623004: Fixed url to manage specific cloud printers. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cloud_devices/common/cloud_devices_urls.h" 5 #include "components/cloud_devices/common/cloud_devices_urls.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "components/cloud_devices/common/cloud_devices_switches.h" 10 #include "components/cloud_devices/common/cloud_devices_switches.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 url = net::AppendQueryParameter(url, "continue", continue_str); 78 url = net::AppendQueryParameter(url, "continue", continue_str);
79 return url; 79 return url;
80 } 80 }
81 81
82 GURL GetCloudPrintEnableURL(const std::string& proxy_id) { 82 GURL GetCloudPrintEnableURL(const std::string& proxy_id) {
83 GURL url = GetCloudPrintRelativeURL("enable_chrome_connector/enable.html"); 83 GURL url = GetCloudPrintRelativeURL("enable_chrome_connector/enable.html");
84 url = net::AppendQueryParameter(url, "proxy", proxy_id); 84 url = net::AppendQueryParameter(url, "proxy", proxy_id);
85 return url; 85 return url;
86 } 86 }
87 87
88 GURL GetCloudPrintEnableURLWithSignin(const std::string& proxy_id) { 88 GURL GetCloudPrintEnableWithSigninURL(const std::string& proxy_id) {
89 GURL url(GaiaUrls::GetInstance()->service_login_url()); 89 GURL url(GaiaUrls::GetInstance()->service_login_url());
90 url = net::AppendQueryParameter(url, "service", "cloudprint"); 90 url = net::AppendQueryParameter(url, "service", "cloudprint");
91 url = net::AppendQueryParameter(url, "sarp", "1"); 91 url = net::AppendQueryParameter(url, "sarp", "1");
92 std::string continue_str = GetCloudPrintEnableURL(proxy_id).spec(); 92 std::string continue_str = GetCloudPrintEnableURL(proxy_id).spec();
93 return net::AppendQueryParameter(url, "continue", continue_str); 93 return net::AppendQueryParameter(url, "continue", continue_str);
94 } 94 }
95 95
96 GURL GetCloudPrintManageDeviceURL(const std::string& device_id) {
97 std::string ref = "printers/" + device_id;
98 GURL::Replacements replacements;
99 replacements.SetRefStr(ref);
100 return GetCloudPrintURL().ReplaceComponents(replacements);
101 }
102
96 GURL GetCloudDevicesURL() { 103 GURL GetCloudDevicesURL() {
97 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 104 const CommandLine* command_line = CommandLine::ForCurrentProcess();
98 GURL cloud_print_url( 105 GURL cloud_print_url(
99 command_line->GetSwitchValueASCII(switches::kCloudDevicesURL)); 106 command_line->GetSwitchValueASCII(switches::kCloudDevicesURL));
100 if (cloud_print_url.is_empty()) 107 if (cloud_print_url.is_empty())
101 cloud_print_url = GURL(kCloudDevicesUrl); 108 cloud_print_url = GURL(kCloudDevicesUrl);
102 return cloud_print_url; 109 return cloud_print_url;
103 } 110 }
104 111
105 GURL GetCloudDevicesRelativeURL(const std::string& relative_path) { 112 GURL GetCloudDevicesRelativeURL(const std::string& relative_path) {
106 GURL url = GetCloudDevicesURL(); 113 GURL url = GetCloudDevicesURL();
107 std::string path; 114 std::string path;
108 const char kURLPathSeparator[] = "/"; 115 const char kURLPathSeparator[] = "/";
109 base::TrimString(url.path(), kURLPathSeparator, &path); 116 base::TrimString(url.path(), kURLPathSeparator, &path);
110 std::string trimmed_path; 117 std::string trimmed_path;
111 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path); 118 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path);
112 path += kURLPathSeparator; 119 path += kURLPathSeparator;
113 path += trimmed_path; 120 path += trimmed_path;
114 GURL::Replacements replacements; 121 GURL::Replacements replacements;
115 replacements.SetPathStr(path); 122 replacements.SetPathStr(path);
116 return url.ReplaceComponents(replacements); 123 return url.ReplaceComponents(replacements);
117 } 124 }
118 125
119 } // namespace cloud_devices 126 } // namespace cloud_devices
OLDNEW
« no previous file with comments | « components/cloud_devices/common/cloud_devices_urls.h ('k') | components/cloud_devices/common/cloud_devices_urls_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698