OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/test/app_remoting_service_urls.h" | 5 #include "remoting/test/app_remoting_service_urls.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 // The placeholder is the environment endpoint qualifier. No trailing slash | 11 // The placeholder is the environment endpoint qualifier. No trailing slash |
12 // is added as it will be appended as needed later. | 12 // is added as it will be appended as needed later. |
13 const char kAppRemotingTestEndpointBase[] = | 13 const char kAppRemotingTestEndpointBase[] = |
14 "https://www-googleapis-test.sandbox.google.com/appremoting/%s"; | 14 "https://www-googleapis-test.sandbox.google.com/appremoting/%s"; |
15 const char kAppRemotingDevEndpointQualifier[] = "v1beta1_dev"; | 15 const char kAppRemotingDevEndpointQualifier[] = "v1beta1_dev"; |
16 const char kAppRemotingTestEndpointQualifier[] = "v1beta1"; | |
17 const char kAppRemotingStagingEndpointQualifier[] = "v1beta1_staging"; | |
18 | 16 |
19 // Placeholder value is for the Application ID. | 17 // Placeholder value is for the Application ID. |
20 const char kRunApplicationApi[] = "applications/%s/run"; | 18 const char kRunApplicationApi[] = "applications/%s/run"; |
21 | 19 |
22 // First placeholder value is for the Application ID. Second placeholder is for | 20 // First placeholder value is for the Application ID. Second placeholder is for |
23 // the Host ID to report the issue for. | 21 // the Host ID to report the issue for. |
24 const char kReportIssueApi[] = "applications/%s/hosts/%s/reportIssue"; | 22 const char kReportIssueApi[] = "applications/%s/hosts/%s/reportIssue"; |
25 } // namespace | 23 } // namespace |
26 | 24 |
27 namespace remoting { | 25 namespace remoting { |
28 namespace test { | 26 namespace test { |
29 | 27 |
30 bool IsSupportedServiceEnvironment(ServiceEnvironment service_environment) { | 28 bool IsSupportedServiceEnvironment(ServiceEnvironment service_environment) { |
31 return (service_environment >= 0 && | 29 return (service_environment >= 0 && |
32 service_environment < kUnknownEnvironment); | 30 service_environment < kUnknownEnvironment); |
33 } | 31 } |
34 | 32 |
35 std::string GetBaseUrl(ServiceEnvironment service_environment) { | 33 std::string GetBaseUrl(ServiceEnvironment service_environment) { |
36 std::string base_service_url; | 34 std::string base_service_url; |
37 | 35 |
38 const char* environment_qualifier = nullptr; | 36 if (service_environment == kDeveloperEnvironment) { |
39 switch (service_environment) { | 37 base_service_url = base::StringPrintf(kAppRemotingTestEndpointBase, |
40 case kDeveloperEnvironment: | 38 kAppRemotingDevEndpointQualifier); |
41 environment_qualifier = kAppRemotingDevEndpointQualifier; | |
42 break; | |
43 | |
44 case kTestingEnvironment: | |
45 environment_qualifier = kAppRemotingTestEndpointQualifier; | |
46 break; | |
47 | |
48 case kStagingEnvironment: | |
49 environment_qualifier = kAppRemotingStagingEndpointQualifier; | |
50 break; | |
51 | |
52 default: | |
53 NOTREACHED(); | |
54 } | |
55 | |
56 if (environment_qualifier) { | |
57 base_service_url = | |
58 base::StringPrintf(kAppRemotingTestEndpointBase, environment_qualifier); | |
59 } | 39 } |
60 | 40 |
61 return base_service_url; | 41 return base_service_url; |
62 } | 42 } |
63 | 43 |
64 std::string GetRunApplicationUrl(const std::string& extension_id, | 44 std::string GetRunApplicationUrl(const std::string& extension_id, |
65 ServiceEnvironment service_environment) { | 45 ServiceEnvironment service_environment) { |
66 std::string service_url; | 46 std::string service_url; |
67 if (!IsSupportedServiceEnvironment(service_environment)) { | 47 if (!IsSupportedServiceEnvironment(service_environment)) { |
68 return service_url; | 48 return service_url; |
(...skipping 24 matching lines...) Expand all Loading... |
93 kReportIssueApi, extension_id.c_str(), host_id.c_str()); | 73 kReportIssueApi, extension_id.c_str(), host_id.c_str()); |
94 service_url = | 74 service_url = |
95 base::StringPrintf("%s/%s", service_url.c_str(), api_string.c_str()); | 75 base::StringPrintf("%s/%s", service_url.c_str(), api_string.c_str()); |
96 } | 76 } |
97 | 77 |
98 return service_url; | 78 return service_url; |
99 } | 79 } |
100 | 80 |
101 } // namespace test | 81 } // namespace test |
102 } // namespace remoting | 82 } // namespace remoting |
OLD | NEW |