| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/common/chrome_utility_messages.h" | 33 #include "chrome/common/chrome_utility_messages.h" |
| 34 #include "chrome/common/chrome_version_info.h" | 34 #include "chrome/common/chrome_version_info.h" |
| 35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 36 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
| 37 #include "chrome/common/extensions/extension_file_util.h" | 37 #include "chrome/common/extensions/extension_file_util.h" |
| 38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 39 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 39 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
| 42 #include "content/public/browser/utility_process_host.h" | 42 #include "content/public/browser/utility_process_host.h" |
| 43 #include "content/public/common/content_url_request_user_data.h" |
| 43 #include "content/public/common/url_fetcher.h" | 44 #include "content/public/common/url_fetcher.h" |
| 44 #include "crypto/sha2.h" | 45 #include "crypto/sha2.h" |
| 45 #include "googleurl/src/gurl.h" | 46 #include "googleurl/src/gurl.h" |
| 46 #include "net/base/escape.h" | 47 #include "net/base/escape.h" |
| 47 #include "net/base/load_flags.h" | 48 #include "net/base/load_flags.h" |
| 48 #include "net/url_request/url_request_status.h" | 49 #include "net/url_request/url_request_status.h" |
| 49 | 50 |
| 50 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
| 51 #include "base/sys_string_conversions.h" | 52 #include "base/sys_string_conversions.h" |
| 52 #endif | 53 #endif |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 std::string id_list = JoinString(id_vector, ','); | 1220 std::string id_list = JoinString(id_vector, ','); |
| 1220 VLOG(2) << "Fetching " << fetch_data->full_url() << " for " | 1221 VLOG(2) << "Fetching " << fetch_data->full_url() << " for " |
| 1221 << id_list; | 1222 << id_list; |
| 1222 } | 1223 } |
| 1223 | 1224 |
| 1224 current_manifest_fetch_.swap(scoped_fetch_data); | 1225 current_manifest_fetch_.swap(scoped_fetch_data); |
| 1225 manifest_fetcher_.reset(content::URLFetcher::Create( | 1226 manifest_fetcher_.reset(content::URLFetcher::Create( |
| 1226 kManifestFetcherId, fetch_data->full_url(), content::URLFetcher::GET, | 1227 kManifestFetcherId, fetch_data->full_url(), content::URLFetcher::GET, |
| 1227 this)); | 1228 this)); |
| 1228 manifest_fetcher_->SetRequestContext(profile_->GetRequestContext()); | 1229 manifest_fetcher_->SetRequestContext(profile_->GetRequestContext()); |
| 1230 // No user data, as the request will be cookie-less. |
| 1231 manifest_fetcher_->SetContentURLRequestUserData( |
| 1232 new content::ContentURLRequestUserData()); |
| 1229 manifest_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 1233 manifest_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 1230 net::LOAD_DO_NOT_SAVE_COOKIES | | 1234 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 1231 net::LOAD_DISABLE_CACHE); | 1235 net::LOAD_DISABLE_CACHE); |
| 1232 manifest_fetcher_->Start(); | 1236 manifest_fetcher_->Start(); |
| 1233 } | 1237 } |
| 1234 } | 1238 } |
| 1235 | 1239 |
| 1236 void ExtensionUpdater::FetchUpdatedExtension(const std::string& id, | 1240 void ExtensionUpdater::FetchUpdatedExtension(const std::string& id, |
| 1237 const GURL& url, | 1241 const GURL& url, |
| 1238 const std::string& hash, | 1242 const std::string& hash, |
| 1239 const std::string& version) { | 1243 const std::string& version) { |
| 1240 for (std::deque<ExtensionFetch>::const_iterator iter = | 1244 for (std::deque<ExtensionFetch>::const_iterator iter = |
| 1241 extensions_pending_.begin(); | 1245 extensions_pending_.begin(); |
| 1242 iter != extensions_pending_.end(); ++iter) { | 1246 iter != extensions_pending_.end(); ++iter) { |
| 1243 if (iter->id == id || iter->url == url) { | 1247 if (iter->id == id || iter->url == url) { |
| 1244 return; // already scheduled | 1248 return; // already scheduled |
| 1245 } | 1249 } |
| 1246 } | 1250 } |
| 1247 | 1251 |
| 1248 if (extension_fetcher_.get() != NULL) { | 1252 if (extension_fetcher_.get() != NULL) { |
| 1249 if (extension_fetcher_->GetURL() != url) { | 1253 if (extension_fetcher_->GetURL() != url) { |
| 1250 extensions_pending_.push_back(ExtensionFetch(id, url, hash, version)); | 1254 extensions_pending_.push_back(ExtensionFetch(id, url, hash, version)); |
| 1251 } | 1255 } |
| 1252 } else { | 1256 } else { |
| 1253 extension_fetcher_.reset(content::URLFetcher::Create( | 1257 extension_fetcher_.reset(content::URLFetcher::Create( |
| 1254 kExtensionFetcherId, url, content::URLFetcher::GET, this)); | 1258 kExtensionFetcherId, url, content::URLFetcher::GET, this)); |
| 1255 extension_fetcher_->SetRequestContext( | 1259 extension_fetcher_->SetRequestContext( |
| 1256 profile_->GetRequestContext()); | 1260 profile_->GetRequestContext()); |
| 1261 // No user data, as the request will be cookie-less. |
| 1262 extension_fetcher_->SetContentURLRequestUserData( |
| 1263 new content::ContentURLRequestUserData()); |
| 1257 extension_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 1264 extension_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 1258 net::LOAD_DO_NOT_SAVE_COOKIES | | 1265 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 1259 net::LOAD_DISABLE_CACHE); | 1266 net::LOAD_DISABLE_CACHE); |
| 1260 // Download CRX files to a temp file. The blacklist is small and will be | 1267 // Download CRX files to a temp file. The blacklist is small and will be |
| 1261 // processed in memory, so it is fetched into a string. | 1268 // processed in memory, so it is fetched into a string. |
| 1262 if (id != ExtensionUpdater::kBlacklistAppID) { | 1269 if (id != ExtensionUpdater::kBlacklistAppID) { |
| 1263 extension_fetcher_->SaveResponseToTemporaryFile( | 1270 extension_fetcher_->SaveResponseToTemporaryFile( |
| 1264 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 1271 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 1265 } | 1272 } |
| 1266 | 1273 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 std::set<std::string>::const_iterator i; | 1306 std::set<std::string>::const_iterator i; |
| 1300 for (i = ids.begin(); i != ids.end(); ++i) | 1307 for (i = ids.begin(); i != ids.end(); ++i) |
| 1301 in_progress_ids_.insert(*i); | 1308 in_progress_ids_.insert(*i); |
| 1302 } | 1309 } |
| 1303 | 1310 |
| 1304 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1311 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1305 std::set<std::string>::const_iterator i; | 1312 std::set<std::string>::const_iterator i; |
| 1306 for (i = ids.begin(); i != ids.end(); ++i) | 1313 for (i = ids.begin(); i != ids.end(); ++i) |
| 1307 in_progress_ids_.erase(*i); | 1314 in_progress_ids_.erase(*i); |
| 1308 } | 1315 } |
| OLD | NEW |