disable-webstore-urls.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # Disables Chrome Webstore-related URLs and other internal functionality. Mainly for disabling auto updates via the Chrome Webstore.
  2. --- a/chrome/browser/extensions/chrome_content_verifier_delegate.cc
  3. +++ b/chrome/browser/extensions/chrome_content_verifier_delegate.cc
  4. @@ -151,13 +151,7 @@ ContentVerifierDelegate::Mode ChromeCont
  5. // between which extensions are considered in-store.
  6. // See https://crbug.com/766806 for details.
  7. if (!InstallVerifier::IsFromStore(extension)) {
  8. - // It's possible that the webstore update url was overridden for testing
  9. - // so also consider extensions with the default (production) update url
  10. - // to be from the store as well.
  11. - if (ManifestURL::GetUpdateURL(&extension) !=
  12. - extension_urls::GetDefaultWebstoreUpdateUrl()) {
  13. - return ContentVerifierDelegate::NONE;
  14. - }
  15. + return ContentVerifierDelegate::NONE;
  16. }
  17. return default_mode_;
  18. --- a/extensions/common/extension_urls.cc
  19. +++ b/extensions/common/extension_urls.cc
  20. @@ -30,7 +30,7 @@ bool IsSourceFromAnExtension(const base:
  21. namespace extension_urls {
  22. -const char kChromeWebstoreBaseURL[] = "https://chrome.google.com/webstore";
  23. +const char kChromeWebstoreBaseURL[] = "trk:09:https://chrome.google.com/webstore";
  24. const char kChromeWebstoreUpdateURL[] =
  25. "trk:05:https://clients2.google.com/service/update2/crx";
  26. --- a/extensions/browser/updater/extension_downloader.cc
  27. +++ b/extensions/browser/updater/extension_downloader.cc
  28. @@ -95,27 +95,18 @@ const char kNotFromWebstoreInstallSource
  29. const char kDefaultInstallSource[] = "";
  30. const char kReinstallInstallSource[] = "reinstall";
  31. -const char kGoogleDotCom[] = "google.com";
  32. const char kTokenServiceConsumerId[] = "extension_downloader";
  33. const char kWebstoreOAuth2Scope[] =
  34. - "https://www.googleapis.com/auth/chromewebstore.readonly";
  35. + "trk:10:https://www.googleapis.com/auth/chromewebstore.readonly";
  36. ExtensionDownloaderTestDelegate* g_test_delegate = nullptr;
  37. #define RETRY_HISTOGRAM(name, retry_count, url) \
  38. - if ((url).DomainIs(kGoogleDotCom)) { \
  39. - UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions." name "RetryCountGoogleUrl", \
  40. - retry_count, \
  41. - 1, \
  42. - kMaxRetries, \
  43. - kMaxRetries + 1); \
  44. - } else { \
  45. UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions." name "RetryCountOtherUrl", \
  46. retry_count, \
  47. 1, \
  48. kMaxRetries, \
  49. - kMaxRetries + 1); \
  50. - }
  51. + kMaxRetries + 1);
  52. bool ShouldRetryRequest(const network::SimpleURLLoader* loader) {
  53. DCHECK(loader);
  54. @@ -298,12 +289,6 @@ void ExtensionDownloader::DoStartAllPend
  55. ReportStats();
  56. url_stats_ = URLStats();
  57. - for (auto it = fetches_preparing_.begin(); it != fetches_preparing_.end();
  58. - ++it) {
  59. - std::vector<std::unique_ptr<ManifestFetchData>>& list = it->second;
  60. - for (size_t i = 0; i < list.size(); ++i)
  61. - StartUpdateCheck(std::move(list[i]));
  62. - }
  63. fetches_preparing_.clear();
  64. }
  65. @@ -335,23 +320,16 @@ bool ExtensionDownloader::AddExtensionDa
  66. return false;
  67. }
  68. - // Make sure we use SSL for store-hosted extensions.
  69. - if (extension_urls::IsWebstoreUpdateUrl(update_url) &&
  70. - !update_url.SchemeIsCryptographic())
  71. - update_url = extension_urls::GetWebstoreUpdateUrl();
  72. -
  73. // Skip extensions with empty IDs.
  74. if (id.empty()) {
  75. DLOG(WARNING) << "Found extension with empty ID";
  76. return false;
  77. }
  78. - if (update_url.DomainIs(kGoogleDotCom)) {
  79. - url_stats_.google_url_count++;
  80. - } else if (update_url.is_empty()) {
  81. + if (update_url.is_empty()) {
  82. url_stats_.no_url_count++;
  83. // Fill in default update URL.
  84. - update_url = extension_urls::GetWebstoreUpdateUrl();
  85. + update_url = GURL("chrome://blank/");
  86. } else {
  87. url_stats_.other_url_count++;
  88. }
  89. @@ -616,13 +594,9 @@ void ExtensionDownloader::OnManifestLoad
  90. const int error =
  91. response_code == -1 ? loader->NetError() : response_code;
  92. const std::string uma_histogram_name =
  93. - url.DomainIs(kGoogleDotCom)
  94. - ? std::string(
  95. - "Extensions."
  96. - "ExtensionUpdaterFirstUpdateCheckErrorsGoogleUrl")
  97. - : std::string(
  98. - "Extensions."
  99. - "ExtensionUpdaterFirstUpdateCheckErrorsNonGoogleUrl");
  100. + std::string(
  101. + "Extensions."
  102. + "ExtensionUpdaterFirstUpdateCheckErrorsNonGoogleUrl");
  103. const auto& extension_ids =
  104. manifests_queue_.active_request()->extension_ids();
  105. for (auto it = extension_ids.begin(); it != extension_ids.end(); ++it) {
  106. @@ -680,20 +654,6 @@ void ExtensionDownloader::HandleManifest
  107. fetch_data->request_ids()));
  108. }
  109. - // If the manifest response included a <daystart> element, we want to save
  110. - // that value for any extensions which had sent a ping in the request.
  111. - if (fetch_data->base_url().DomainIs(kGoogleDotCom) &&
  112. - results->daystart_elapsed_seconds >= 0) {
  113. - Time day_start =
  114. - Time::Now() - TimeDelta::FromSeconds(results->daystart_elapsed_seconds);
  115. -
  116. - for (const std::string& id : fetch_data->extension_ids()) {
  117. - ExtensionDownloaderDelegate::PingResult& result = ping_results_[id];
  118. - result.did_ping = fetch_data->DidPing(id, ManifestFetchData::ROLLCALL);
  119. - result.day_start = day_start;
  120. - }
  121. - }
  122. -
  123. NotifyExtensionsDownloadFailed(
  124. no_updates, fetch_data->request_ids(),
  125. ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE);
  126. @@ -1108,11 +1068,7 @@ bool ExtensionDownloader::IterateFetchCr
  127. // fetch.
  128. switch (fetch->credentials) {
  129. case ExtensionFetch::CREDENTIALS_NONE:
  130. - if (fetch->url.DomainIs(kGoogleDotCom) && identity_manager_) {
  131. - fetch->credentials = ExtensionFetch::CREDENTIALS_OAUTH2_TOKEN;
  132. - } else {
  133. - fetch->credentials = ExtensionFetch::CREDENTIALS_COOKIES;
  134. - }
  135. + fetch->credentials = ExtensionFetch::CREDENTIALS_COOKIES;
  136. return true;
  137. case ExtensionFetch::CREDENTIALS_OAUTH2_TOKEN:
  138. fetch->oauth2_attempt_count++;
  139. --- a/chrome/browser/extensions/extension_migrator.cc
  140. +++ b/chrome/browser/extensions/extension_migrator.cc
  141. @@ -18,7 +18,9 @@ namespace extensions {
  142. ExtensionMigrator::ExtensionMigrator(Profile* profile,
  143. const std::string& old_id,
  144. const std::string& new_id)
  145. - : profile_(profile), old_id_(old_id), new_id_(new_id) {}
  146. + : profile_(profile), old_id_(old_id), new_id_(new_id) {
  147. + chrome_blank_ = GURL("chrome://blank/");
  148. +}
  149. ExtensionMigrator::~ExtensionMigrator() {
  150. }
  151. @@ -31,7 +33,7 @@ void ExtensionMigrator::StartLoading() {
  152. if (should_have_extension) {
  153. std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
  154. entry->SetKey(ExternalProviderImpl::kExternalUpdateUrl,
  155. - base::Value(extension_urls::GetWebstoreUpdateUrl().spec()));
  156. + base::Value(chrome_blank_.spec()));
  157. prefs->SetWithoutPathExpansion(new_id_, std::move(entry));
  158. }
  159. --- a/chrome/browser/extensions/extension_migrator.h
  160. +++ b/chrome/browser/extensions/extension_migrator.h
  161. @@ -9,6 +9,7 @@
  162. #include "base/macros.h"
  163. #include "chrome/browser/extensions/external_loader.h"
  164. +#include "url/gurl.h"
  165. class Profile;
  166. @@ -37,6 +38,7 @@ class ExtensionMigrator : public Externa
  167. Profile* profile_;
  168. const std::string old_id_;
  169. const std::string new_id_;
  170. + GURL chrome_blank_;
  171. DISALLOW_COPY_AND_ASSIGN(ExtensionMigrator);
  172. };