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

Side by Side Diff: chrome/browser/extensions/api/page_capture/page_capture_api.cc

Issue 22920005: Refactor MHTMLGenerator to allow getting sending the data to a file descriptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 "chrome/browser/extensions/api/page_capture/page_capture_api.h" 5 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ReturnFailure(kTabClosedError); 129 ReturnFailure(kTabClosedError);
130 return; 130 return;
131 } 131 }
132 132
133 web_contents->GenerateMHTML( 133 web_contents->GenerateMHTML(
134 mhtml_path_, 134 mhtml_path_,
135 base::Bind(&PageCaptureSaveAsMHTMLFunction::MHTMLGenerated, this)); 135 base::Bind(&PageCaptureSaveAsMHTMLFunction::MHTMLGenerated, this));
136 } 136 }
137 137
138 void PageCaptureSaveAsMHTMLFunction::MHTMLGenerated( 138 void PageCaptureSaveAsMHTMLFunction::MHTMLGenerated(
139 const base::FilePath& file_path,
140 int64 mhtml_file_size) { 139 int64 mhtml_file_size) {
141 DCHECK(mhtml_path_ == file_path);
142 if (mhtml_file_size <= 0) { 140 if (mhtml_file_size <= 0) {
143 ReturnFailure(kMHTMLGenerationFailedError); 141 ReturnFailure(kMHTMLGenerationFailedError);
144 return; 142 return;
145 } 143 }
146 144
147 if (mhtml_file_size > std::numeric_limits<int>::max()) { 145 if (mhtml_file_size > std::numeric_limits<int>::max()) {
148 ReturnFailure(kFileTooBigError); 146 ReturnFailure(kFileTooBigError);
149 return; 147 return;
150 } 148 }
151 149
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 Browser* browser = NULL; 189 Browser* browser = NULL;
192 content::WebContents* web_contents = NULL; 190 content::WebContents* web_contents = NULL;
193 191
194 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(), 192 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(),
195 include_incognito(), &browser, NULL, 193 include_incognito(), &browser, NULL,
196 &web_contents, NULL)) { 194 &web_contents, NULL)) {
197 return NULL; 195 return NULL;
198 } 196 }
199 return web_contents; 197 return web_contents;
200 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698