OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/component_updater/component_updater_service.h" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 virtual size_t UrlSizeLimit() OVERRIDE; | 103 virtual size_t UrlSizeLimit() OVERRIDE; |
104 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; | 104 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; |
105 virtual bool InProcess() OVERRIDE; | 105 virtual bool InProcess() OVERRIDE; |
106 virtual void OnEvent(Events event, int val) OVERRIDE; | 106 virtual void OnEvent(Events event, int val) OVERRIDE; |
107 | 107 |
108 private: | 108 private: |
109 net::URLRequestContextGetter* url_request_getter_; | 109 net::URLRequestContextGetter* url_request_getter_; |
110 std::string extra_info_; | 110 std::string extra_info_; |
111 bool fast_update_; | 111 bool fast_update_; |
112 bool out_of_process_; | 112 bool out_of_process_; |
| 113 GURL app_update_url_; |
113 }; | 114 }; |
114 | 115 |
115 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, | 116 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, |
116 net::URLRequestContextGetter* url_request_getter) | 117 net::URLRequestContextGetter* url_request_getter) |
117 : url_request_getter_(url_request_getter), | 118 : url_request_getter_(url_request_getter), |
118 extra_info_(kExtraInfo) { | 119 extra_info_(kExtraInfo) { |
119 // Parse comma-delimited debug flags. | 120 // Parse comma-delimited debug flags. |
120 std::vector<std::string> debug_values; | 121 std::vector<std::string> debug_values; |
121 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug), | 122 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug), |
122 ",", &debug_values); | 123 ",", &debug_values); |
123 fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate); | 124 fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate); |
124 out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess); | 125 out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess); |
| 126 |
| 127 // Allow switch to override update URL (piggyback on AppsGalleryUpdateURL). |
| 128 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) { |
| 129 app_update_url_ = |
| 130 GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL)); |
| 131 } else { |
| 132 app_update_url_ = GURL("http://clients2.google.com/service/update2/crx"); |
| 133 } |
| 134 |
125 // Make the extra request params, they are necessary so omaha does | 135 // Make the extra request params, they are necessary so omaha does |
126 // not deliver components that are going to be rejected at install time. | 136 // not deliver components that are going to be rejected at install time. |
127 extra_info_ += chrome::VersionInfo().Version(); | 137 extra_info_ += chrome::VersionInfo().Version(); |
128 if (HasDebugValue(debug_values, kDebugRequestParam)) | 138 if (HasDebugValue(debug_values, kDebugRequestParam)) |
129 extra_info_ += "&testrequest=1"; | 139 extra_info_ += "&testrequest=1"; |
130 } | 140 } |
131 | 141 |
132 int ChromeConfigurator::InitialDelay() { | 142 int ChromeConfigurator::InitialDelay() { |
133 return fast_update_ ? 1 : (6 * kDelayOneMinute); | 143 return fast_update_ ? 1 : (6 * kDelayOneMinute); |
134 } | 144 } |
135 | 145 |
136 int ChromeConfigurator::NextCheckDelay() { | 146 int ChromeConfigurator::NextCheckDelay() { |
137 return fast_update_ ? 3 : (4 * kDelayOneHour); | 147 return fast_update_ ? 3 : (4 * kDelayOneHour); |
138 } | 148 } |
139 | 149 |
140 int ChromeConfigurator::StepDelay() { | 150 int ChromeConfigurator::StepDelay() { |
141 return fast_update_ ? 1 : 4; | 151 return fast_update_ ? 1 : 4; |
142 } | 152 } |
143 | 153 |
144 int ChromeConfigurator::MinimumReCheckWait() { | 154 int ChromeConfigurator::MinimumReCheckWait() { |
145 return fast_update_ ? 30 : (6 * kDelayOneHour); | 155 return fast_update_ ? 30 : (6 * kDelayOneHour); |
146 } | 156 } |
147 | 157 |
148 GURL ChromeConfigurator::UpdateUrl() { | 158 GURL ChromeConfigurator::UpdateUrl() { |
149 return GURL("http://clients2.google.com/service/update2/crx"); | 159 return app_update_url_; |
150 } | 160 } |
151 | 161 |
152 const char* ChromeConfigurator::ExtraRequestParams() { | 162 const char* ChromeConfigurator::ExtraRequestParams() { |
153 return extra_info_.c_str(); | 163 return extra_info_.c_str(); |
154 } | 164 } |
155 | 165 |
156 size_t ChromeConfigurator::UrlSizeLimit() { | 166 size_t ChromeConfigurator::UrlSizeLimit() { |
157 return 1024ul; | 167 return 1024ul; |
158 } | 168 } |
159 | 169 |
(...skipping 28 matching lines...) Expand all Loading... |
188 default: | 198 default: |
189 NOTREACHED(); | 199 NOTREACHED(); |
190 break; | 200 break; |
191 } | 201 } |
192 } | 202 } |
193 | 203 |
194 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( | 204 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( |
195 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { | 205 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { |
196 return new ChromeConfigurator(cmdline, context_getter); | 206 return new ChromeConfigurator(cmdline, context_getter); |
197 } | 207 } |
OLD | NEW |