| 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/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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |