| 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/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 test_delegate_->OnTemporaryFileCreated(mhtml_path_); | 126 test_delegate_->OnTemporaryFileCreated(mhtml_path_); |
| 127 | 127 |
| 128 WebContents* web_contents = GetWebContents(); | 128 WebContents* web_contents = GetWebContents(); |
| 129 if (!web_contents) { | 129 if (!web_contents) { |
| 130 ReturnFailure(kTabClosedError); | 130 ReturnFailure(kTabClosedError); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 web_contents->GenerateMHTML( | 134 web_contents->GenerateMHTML( |
| 135 mhtml_path_, | 135 mhtml_path_, |
| 136 false /* use_binary_encoding */, |
| 136 base::Bind(&PageCaptureSaveAsMHTMLFunction::MHTMLGenerated, this)); | 137 base::Bind(&PageCaptureSaveAsMHTMLFunction::MHTMLGenerated, this)); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void PageCaptureSaveAsMHTMLFunction::MHTMLGenerated(int64_t mhtml_file_size) { | 140 void PageCaptureSaveAsMHTMLFunction::MHTMLGenerated(int64_t mhtml_file_size) { |
| 140 if (mhtml_file_size <= 0) { | 141 if (mhtml_file_size <= 0) { |
| 141 ReturnFailure(kMHTMLGenerationFailedError); | 142 ReturnFailure(kMHTMLGenerationFailedError); |
| 142 return; | 143 return; |
| 143 } | 144 } |
| 144 | 145 |
| 145 if (mhtml_file_size > std::numeric_limits<int>::max()) { | 146 if (mhtml_file_size > std::numeric_limits<int>::max()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 GetProfile(), | 194 GetProfile(), |
| 194 include_incognito(), | 195 include_incognito(), |
| 195 &browser, | 196 &browser, |
| 196 NULL, | 197 NULL, |
| 197 &web_contents, | 198 &web_contents, |
| 198 NULL)) { | 199 NULL)) { |
| 199 return NULL; | 200 return NULL; |
| 200 } | 201 } |
| 201 return web_contents; | 202 return web_contents; |
| 202 } | 203 } |
| OLD | NEW |