Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 988453002: Request uncompressed images from data reduction proxy when saving. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 SavePageType save_type) { 2295 SavePageType save_type) {
2296 // Stop the page from navigating. 2296 // Stop the page from navigating.
2297 Stop(); 2297 Stop();
2298 2298
2299 save_package_ = new SavePackage(this, save_type, main_file, dir_path); 2299 save_package_ = new SavePackage(this, save_type, main_file, dir_path);
2300 return save_package_->Init(SavePackageDownloadCreatedCallback()); 2300 return save_package_->Init(SavePackageDownloadCreatedCallback());
2301 } 2301 }
2302 2302
2303 void WebContentsImpl::SaveFrame(const GURL& url, 2303 void WebContentsImpl::SaveFrame(const GURL& url,
2304 const Referrer& referrer) { 2304 const Referrer& referrer) {
2305 SaveFrameWithHeaders(url, referrer, std::string());
2306 }
2307
2308 void WebContentsImpl::SaveFrameWithHeaders(const GURL& url,
2309 const Referrer& referrer,
2310 const std::string& headers) {
2305 if (!GetLastCommittedURL().is_valid()) 2311 if (!GetLastCommittedURL().is_valid())
2306 return; 2312 return;
2307 if (delegate_ && delegate_->SaveFrame(url, referrer)) 2313 if (delegate_ && delegate_->SaveFrame(url, referrer))
2308 return; 2314 return;
2309 2315
2310 // TODO(nasko): This check for main frame is incorrect and should be fixed 2316 // TODO(nasko): This check for main frame is incorrect and should be fixed
2311 // by explicitly passing in which frame this method should target. 2317 // by explicitly passing in which frame this method should target.
2312 bool is_main_frame = (url == GetLastCommittedURL()); 2318 bool is_main_frame = (url == GetLastCommittedURL());
2313 2319
2314 DownloadManager* dlm = 2320 DownloadManager* dlm =
2315 BrowserContext::GetDownloadManager(GetBrowserContext()); 2321 BrowserContext::GetDownloadManager(GetBrowserContext());
2316 if (!dlm) 2322 if (!dlm)
2317 return; 2323 return;
2318 int64 post_id = -1; 2324 int64 post_id = -1;
2319 if (is_main_frame) { 2325 if (is_main_frame) {
2320 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); 2326 const NavigationEntry* entry = controller_.GetLastCommittedEntry();
2321 if (entry) 2327 if (entry)
2322 post_id = entry->GetPostID(); 2328 post_id = entry->GetPostID();
2323 } 2329 }
2324 scoped_ptr<DownloadUrlParameters> params( 2330 scoped_ptr<DownloadUrlParameters> params(
2325 DownloadUrlParameters::FromWebContents(this, url)); 2331 DownloadUrlParameters::FromWebContents(this, url));
2326 params->set_referrer(referrer); 2332 params->set_referrer(referrer);
2327 params->set_post_id(post_id); 2333 params->set_post_id(post_id);
2328 params->set_prefer_cache(true);
2329 if (post_id >= 0) 2334 if (post_id >= 0)
2330 params->set_method("POST"); 2335 params->set_method("POST");
2331 params->set_prompt(true); 2336 params->set_prompt(true);
2337
2338 if (headers.empty()) {
2339 params->set_prefer_cache(true);
2340 } else {
2341 std::vector<std::string> key_value_list;
2342 base::SplitString(headers, '\n', &key_value_list);
2343 for (const auto& key_value : key_value_list) {
2344 std::vector<std::string> pair;
2345 base::SplitString(key_value, ':', &pair);
2346 DCHECK_EQ(2ul, pair.size());
2347 params->add_request_header(pair[0], pair[1]);
2348 }
2349 }
2332 dlm->DownloadUrl(params.Pass()); 2350 dlm->DownloadUrl(params.Pass());
2333 } 2351 }
2334 2352
2335 void WebContentsImpl::GenerateMHTML( 2353 void WebContentsImpl::GenerateMHTML(
2336 const base::FilePath& file, 2354 const base::FilePath& file,
2337 const base::Callback<void(int64)>& callback) { 2355 const base::Callback<void(int64)>& callback) {
2338 MHTMLGenerationManager::GetInstance()->SaveMHTML(this, file, callback); 2356 MHTMLGenerationManager::GetInstance()->SaveMHTML(this, file, callback);
2339 } 2357 }
2340 2358
2341 const std::string& WebContentsImpl::GetContentsMimeType() const { 2359 const std::string& WebContentsImpl::GetContentsMimeType() const {
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 node->render_manager()->ResumeResponseDeferredAtStart(); 4574 node->render_manager()->ResumeResponseDeferredAtStart();
4557 } 4575 }
4558 4576
4559 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4577 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4560 force_disable_overscroll_content_ = force_disable; 4578 force_disable_overscroll_content_ = force_disable;
4561 if (view_) 4579 if (view_)
4562 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4580 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4563 } 4581 }
4564 4582
4565 } // namespace content 4583 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698