OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 "http://www.google.com/landing/cloudprint/enable.html?print=true"; | 26 "http://www.google.com/landing/cloudprint/enable.html?print=true"; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Url must not be matched by "urls" section of | 30 // Url must not be matched by "urls" section of |
31 // cloud_print_app/manifest.json. If it's matched, print driver dialog will | 31 // cloud_print_app/manifest.json. If it's matched, print driver dialog will |
32 // open sign-in page in separate window. | 32 // open sign-in page in separate window. |
33 const char kCloudPrintURL[] = "https://www.google.com/cloudprint"; | 33 const char kCloudPrintURL[] = "https://www.google.com/cloudprint"; |
34 | 34 |
35 const char kCloudDevicesUrl[] = "https://www.googleapis.com/clouddevices/v1"; | 35 const char kCloudDevicesUrl[] = "https://www.googleapis.com/clouddevices/v1"; |
| 36 |
36 } | 37 } |
37 | 38 |
38 // Returns the root service URL for the cloud print service. The default is to | 39 // Returns the root service URL for the cloud print service. The default is to |
39 // point at the Google Cloud Print service. This can be overridden by the | 40 // point at the Google Cloud Print service. This can be overridden by the |
40 // command line or by the user preferences. | 41 // command line or by the user preferences. |
41 GURL GetCloudPrintURL() { | 42 GURL GetCloudPrintURL() { |
42 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 43 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
43 GURL cloud_print_url( | 44 GURL cloud_print_url( |
44 command_line->GetSwitchValueASCII(switches::kCloudPrintURL)); | 45 command_line->GetSwitchValueASCII(switches::kCloudPrintURL)); |
45 if (cloud_print_url.is_empty()) | 46 if (cloud_print_url.is_empty()) |
46 cloud_print_url = GURL(kCloudPrintURL); | 47 cloud_print_url = GURL(kCloudPrintURL); |
47 return cloud_print_url; | 48 return cloud_print_url; |
48 } | 49 } |
49 | 50 |
50 GURL GetCloudPrintRelativeURL(const std::string& relative_path) { | 51 GURL GetCloudPrintRelativeURL(const std::string& relative_path) { |
51 GURL url = GetCloudPrintURL(); | 52 GURL url = GetCloudPrintURL(); |
52 std::string path; | 53 std::string path; |
53 const char kURLPathSeparator[] = "/"; | 54 static const char kURLPathSeparator[] = "/"; |
54 base::TrimString(url.path(), kURLPathSeparator, &path); | 55 base::TrimString(url.path(), kURLPathSeparator, &path); |
55 std::string trimmed_path; | 56 std::string trimmed_path; |
56 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path); | 57 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path); |
57 path += kURLPathSeparator; | 58 path += kURLPathSeparator; |
58 path += trimmed_path; | 59 path += trimmed_path; |
59 GURL::Replacements replacements; | 60 GURL::Replacements replacements; |
60 replacements.SetPathStr(path); | 61 replacements.SetPathStr(path); |
61 return url.ReplaceComponents(replacements); | 62 return url.ReplaceComponents(replacements); |
62 } | 63 } |
63 | 64 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 std::string trimmed_path; | 118 std::string trimmed_path; |
118 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path); | 119 base::TrimString(relative_path, kURLPathSeparator, &trimmed_path); |
119 path += kURLPathSeparator; | 120 path += kURLPathSeparator; |
120 path += trimmed_path; | 121 path += trimmed_path; |
121 GURL::Replacements replacements; | 122 GURL::Replacements replacements; |
122 replacements.SetPathStr(path); | 123 replacements.SetPathStr(path); |
123 return url.ReplaceComponents(replacements); | 124 return url.ReplaceComponents(replacements); |
124 } | 125 } |
125 | 126 |
126 } // namespace cloud_devices | 127 } // namespace cloud_devices |
OLD | NEW |