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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 59 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
60 | 60 |
61 AddRef(); // Balanced in ReturnFailure/ReturnSuccess() | 61 AddRef(); // Balanced in ReturnFailure/ReturnSuccess() |
62 | 62 |
63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
64 BrowserThread::FILE, FROM_HERE, | 64 BrowserThread::FILE, FROM_HERE, |
65 base::Bind(&PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile, this)); | 65 base::Bind(&PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile, this)); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 bool PageCaptureSaveAsMHTMLFunction::OnMessageReceivedFromRenderView( | 69 bool PageCaptureSaveAsMHTMLFunction::OnMessageReceived( |
70 const IPC::Message& message) { | 70 const IPC::Message& message) { |
71 if (message.type() != ExtensionHostMsg_ResponseAck::ID) | 71 if (message.type() != ExtensionHostMsg_ResponseAck::ID) |
72 return false; | 72 return false; |
73 | 73 |
74 int message_request_id; | 74 int message_request_id; |
75 PickleIterator iter(message); | 75 PickleIterator iter(message); |
76 if (!message.ReadInt(&iter, &message_request_id)) { | 76 if (!message.ReadInt(&iter, &message_request_id)) { |
77 NOTREACHED() << "malformed extension message"; | 77 NOTREACHED() << "malformed extension message"; |
78 return true; | 78 return true; |
79 } | 79 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 child_id, mhtml_path_); | 174 child_id, mhtml_path_); |
175 | 175 |
176 base::DictionaryValue* dict = new base::DictionaryValue(); | 176 base::DictionaryValue* dict = new base::DictionaryValue(); |
177 SetResult(dict); | 177 SetResult(dict); |
178 dict->SetString("mhtmlFilePath", mhtml_path_.value()); | 178 dict->SetString("mhtmlFilePath", mhtml_path_.value()); |
179 dict->SetInteger("mhtmlFileLength", file_size); | 179 dict->SetInteger("mhtmlFileLength", file_size); |
180 | 180 |
181 SendResponse(true); | 181 SendResponse(true); |
182 | 182 |
183 // Note that we'll wait for a response ack message received in | 183 // Note that we'll wait for a response ack message received in |
184 // OnMessageReceivedFromRenderView before we call Release() (to prevent the | 184 // OnMessageReceived before we call Release() (to prevent the blob file from |
185 // blob file from being deleted). | 185 // being deleted). |
186 } | 186 } |
187 | 187 |
188 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { | 188 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { |
189 Browser* browser = NULL; | 189 Browser* browser = NULL; |
190 content::WebContents* web_contents = NULL; | 190 content::WebContents* web_contents = NULL; |
191 | 191 |
192 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, | 192 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, |
193 GetProfile(), | 193 GetProfile(), |
194 include_incognito(), | 194 include_incognito(), |
195 &browser, | 195 &browser, |
196 NULL, | 196 NULL, |
197 &web_contents, | 197 &web_contents, |
198 NULL)) { | 198 NULL)) { |
199 return NULL; | 199 return NULL; |
200 } | 200 } |
201 return web_contents; | 201 return web_contents; |
202 } | 202 } |
OLD | NEW |