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

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: whitespace change 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
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 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 bool WebContentsImpl::SavePage(const base::FilePath& main_file, 2287 bool WebContentsImpl::SavePage(const base::FilePath& main_file,
2288 const base::FilePath& dir_path, 2288 const base::FilePath& dir_path,
2289 SavePageType save_type) { 2289 SavePageType save_type) {
2290 // Stop the page from navigating. 2290 // Stop the page from navigating.
2291 Stop(); 2291 Stop();
2292 2292
2293 save_package_ = new SavePackage(this, save_type, main_file, dir_path); 2293 save_package_ = new SavePackage(this, save_type, main_file, dir_path);
2294 return save_package_->Init(SavePackageDownloadCreatedCallback()); 2294 return save_package_->Init(SavePackageDownloadCreatedCallback());
2295 } 2295 }
2296 2296
2297 void WebContentsImpl::SaveFrame(const GURL& url, 2297 void WebContentsImpl::SaveFrameWithHeader(const GURL& url,
2298 const Referrer& referrer) { 2298 const Referrer& referrer,
2299 const std::string& header) {
2299 if (!GetURL().is_valid()) 2300 if (!GetURL().is_valid())
2300 return; 2301 return;
2301 if (delegate_ && delegate_->SaveFrame(url, referrer)) 2302 if (delegate_ && delegate_->SaveFrame(url, referrer))
2302 return; 2303 return;
2303 2304
2304 bool is_main_frame = (url == GetURL()); 2305 bool is_main_frame = (url == GetURL());
2305 2306
2306 DownloadManager* dlm = 2307 DownloadManager* dlm =
2307 BrowserContext::GetDownloadManager(GetBrowserContext()); 2308 BrowserContext::GetDownloadManager(GetBrowserContext());
2308 if (!dlm) 2309 if (!dlm)
2309 return; 2310 return;
2310 int64 post_id = -1; 2311 int64 post_id = -1;
2311 if (is_main_frame) { 2312 if (is_main_frame) {
2312 const NavigationEntry* entry = controller_.GetLastCommittedEntry(); 2313 const NavigationEntry* entry = controller_.GetLastCommittedEntry();
2313 if (entry) 2314 if (entry)
2314 post_id = entry->GetPostID(); 2315 post_id = entry->GetPostID();
2315 } 2316 }
2316 scoped_ptr<DownloadUrlParameters> params( 2317 scoped_ptr<DownloadUrlParameters> params(
2317 DownloadUrlParameters::FromWebContents(this, url)); 2318 DownloadUrlParameters::FromWebContents(this, url));
2318 params->set_referrer(referrer); 2319 params->set_referrer(referrer);
2319 params->set_post_id(post_id); 2320 params->set_post_id(post_id);
2320 params->set_prefer_cache(true); 2321 params->set_prefer_cache(true);
2321 if (post_id >= 0) 2322 if (post_id >= 0)
2322 params->set_method("POST"); 2323 params->set_method("POST");
2323 params->set_prompt(true); 2324 params->set_prompt(true);
2325
2326 if (!header.empty()) {
2327 std::vector<std::string> keyValueList;
Avi (use Gerrit) 2015/03/05 20:35:39 style, please! key_value_list
Not at Google. Contact bengr 2015/03/06 22:23:48 Done.
2328 base::SplitString(header, '\n', &keyValueList);
2329 for (std::vector<std::string>::iterator it = keyValueList.begin();
Avi (use Gerrit) 2015/03/05 20:35:39 for (auto& ...)
Not at Google. Contact bengr 2015/03/06 22:23:48 Done.
2330 it != keyValueList.end(); it++) {
2331 std::vector<std::string> pair;
2332 base::SplitString(*it, ':', &pair);
2333 DCHECK(pair.size() == 2);
Avi (use Gerrit) 2015/03/05 20:35:39 DCHECK_EQ
Not at Google. Contact bengr 2015/03/06 22:23:48 Done.
2334 params->add_request_header(pair[0], pair[1]);
2335 }
2336 }
2324 dlm->DownloadUrl(params.Pass()); 2337 dlm->DownloadUrl(params.Pass());
2325 } 2338 }
2326 2339
2340 void WebContentsImpl::SaveFrame(const GURL& url,
2341 const Referrer& referrer) {
2342 SaveFrameWithHeader(url, referrer, "");
Avi (use Gerrit) 2015/03/05 20:35:39 "" -> std::string()
Not at Google. Contact bengr 2015/03/06 22:23:48 Done.
2343 }
2344
2327 void WebContentsImpl::GenerateMHTML( 2345 void WebContentsImpl::GenerateMHTML(
2328 const base::FilePath& file, 2346 const base::FilePath& file,
2329 const base::Callback<void(int64)>& callback) { 2347 const base::Callback<void(int64)>& callback) {
2330 MHTMLGenerationManager::GetInstance()->SaveMHTML(this, file, callback); 2348 MHTMLGenerationManager::GetInstance()->SaveMHTML(this, file, callback);
2331 } 2349 }
2332 2350
2333 const std::string& WebContentsImpl::GetContentsMimeType() const { 2351 const std::string& WebContentsImpl::GetContentsMimeType() const {
2334 return contents_mime_type_; 2352 return contents_mime_type_;
2335 } 2353 }
2336 2354
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4537 node->render_manager()->ResumeResponseDeferredAtStart(); 4555 node->render_manager()->ResumeResponseDeferredAtStart();
4538 } 4556 }
4539 4557
4540 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4558 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4541 force_disable_overscroll_content_ = force_disable; 4559 force_disable_overscroll_content_ = force_disable;
4542 if (view_) 4560 if (view_)
4543 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4561 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4544 } 4562 }
4545 4563
4546 } // namespace content 4564 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698