| 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 "chrome/browser/component_updater/chrome_component_updater_configurator
.h" | 5 #include "chrome/browser/component_updater/chrome_component_updater_configurator
.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "components/update_client/configurator.h" | 23 #include "components/update_client/configurator.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 using update_client::Configurator; | 28 using update_client::Configurator; |
| 29 using update_client::OutOfProcessPatcher; | 29 using update_client::OutOfProcessPatcher; |
| 30 | 30 |
| 31 namespace component_updater { | 31 namespace component_updater { |
| 32 | 32 |
| 33 namespace { | |
| 34 | |
| 35 // Default time constants. | |
| 36 const int kDelayOneMinute = 60; | |
| 37 const int kDelayOneHour = kDelayOneMinute * 60; | |
| 38 | |
| 39 // Debug values you can pass to --component-updater=value1,value2. | 33 // Debug values you can pass to --component-updater=value1,value2. |
| 40 // Speed up component checking. | 34 // Speed up component checking. |
| 41 const char kSwitchFastUpdate[] = "fast-update"; | 35 const char kSwitchFastUpdate[] = "fast-update"; |
| 42 | 36 |
| 43 // Add "testrequest=1" attribute to the update check request. | 37 // Add "testrequest=1" attribute to the update check request. |
| 44 const char kSwitchRequestParam[] = "test-request"; | 38 const char kSwitchRequestParam[] = "test-request"; |
| 45 | 39 |
| 46 // Disables pings. Pings are the requests sent to the update server that report | 40 // Disables pings. Pings are the requests sent to the update server that report |
| 47 // the success or the failure of component install or update attempts. | 41 // the success or the failure of component install or update attempts. |
| 48 extern const char kSwitchDisablePings[] = "disable-pings"; | 42 const char kSwitchDisablePings[] = "disable-pings"; |
| 49 | 43 |
| 50 // Sets the URL for updates. | 44 // Sets the URL for updates. |
| 51 const char kSwitchUrlSource[] = "url-source"; | 45 const char kSwitchUrlSource[] = "url-source"; |
| 52 | 46 |
| 47 // Disables differential updates. |
| 48 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; |
| 49 |
| 50 #if defined(OS_WIN) |
| 51 // Disables background downloads. |
| 52 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; |
| 53 #endif // defined(OS_WIN) |
| 54 |
| 55 namespace { |
| 56 |
| 57 // Default time constants. |
| 58 const int kDelayOneMinute = 60; |
| 59 const int kDelayOneHour = kDelayOneMinute * 60; |
| 60 |
| 53 #define COMPONENT_UPDATER_SERVICE_ENDPOINT \ | 61 #define COMPONENT_UPDATER_SERVICE_ENDPOINT \ |
| 54 "//clients2.google.com/service/update2" | 62 "//clients2.google.com/service/update2" |
| 55 | 63 |
| 56 // The default URL for the v3 protocol service endpoint. In some cases, the | 64 // The default URL for the v3 protocol service endpoint. In some cases, the |
| 57 // component updater is allowed to fall back to and alternate URL source, if | 65 // component updater is allowed to fall back to and alternate URL source, if |
| 58 // the request to the default URL source fails. | 66 // the request to the default URL source fails. |
| 59 // The value of |kDefaultUrlSource| can be overridden with | 67 // The value of |kDefaultUrlSource| can be overridden with |
| 60 // --component-updater=url-source=someurl. | 68 // --component-updater=url-source=someurl. |
| 61 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT; | 69 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT; |
| 62 const char kAltUrlSource[] = "http:" COMPONENT_UPDATER_SERVICE_ENDPOINT; | 70 const char kAltUrlSource[] = "http:" COMPONENT_UPDATER_SERVICE_ENDPOINT; |
| 63 | 71 |
| 64 // Disables differential updates. | |
| 65 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; | |
| 66 | |
| 67 #if defined(OS_WIN) | |
| 68 // Disables background downloads. | |
| 69 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; | |
| 70 #endif // defined(OS_WIN) | |
| 71 | |
| 72 // Returns true if and only if |test| is contained in |vec|. | 72 // Returns true if and only if |test| is contained in |vec|. |
| 73 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { | 73 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { |
| 74 if (vec.empty()) | 74 if (vec.empty()) |
| 75 return 0; | 75 return 0; |
| 76 return (std::find(vec.begin(), vec.end(), test) != vec.end()); | 76 return (std::find(vec.begin(), vec.end(), test) != vec.end()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Returns true if falling back on an alternate, unsafe, service URL is | 79 // Returns true if falling back on an alternate, unsafe, service URL is |
| 80 // allowed. In the fallback case, the security of the component update relies | 80 // allowed. In the fallback case, the security of the component update relies |
| 81 // only on the integrity of the CRX payloads, which is self-validating. | 81 // only on the integrity of the CRX payloads, which is self-validating. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 | 289 |
| 290 Configurator* MakeChromeComponentUpdaterConfigurator( | 290 Configurator* MakeChromeComponentUpdaterConfigurator( |
| 291 const base::CommandLine* cmdline, | 291 const base::CommandLine* cmdline, |
| 292 net::URLRequestContextGetter* context_getter) { | 292 net::URLRequestContextGetter* context_getter) { |
| 293 return new ChromeConfigurator(cmdline, context_getter); | 293 return new ChromeConfigurator(cmdline, context_getter); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace component_updater | 296 } // namespace component_updater |
| OLD | NEW |