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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 WebContents* web_contents = GetWebContents(); | 168 WebContents* web_contents = GetWebContents(); |
169 if (!web_contents || !render_view_host()) { | 169 if (!web_contents || !render_view_host()) { |
170 ReturnFailure(kTabClosedError); | 170 ReturnFailure(kTabClosedError); |
171 return; | 171 return; |
172 } | 172 } |
173 | 173 |
174 int child_id = render_view_host()->GetProcess()->GetID(); | 174 int child_id = render_view_host()->GetProcess()->GetID(); |
175 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( | 175 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( |
176 child_id, mhtml_path_); | 176 child_id, mhtml_path_); |
177 | 177 |
178 DictionaryValue* dict = new DictionaryValue(); | 178 base::DictionaryValue* dict = new base::DictionaryValue(); |
179 SetResult(dict); | 179 SetResult(dict); |
180 dict->SetString("mhtmlFilePath", mhtml_path_.value()); | 180 dict->SetString("mhtmlFilePath", mhtml_path_.value()); |
181 dict->SetInteger("mhtmlFileLength", file_size); | 181 dict->SetInteger("mhtmlFileLength", file_size); |
182 | 182 |
183 SendResponse(true); | 183 SendResponse(true); |
184 | 184 |
185 // Note that we'll wait for a response ack message received in | 185 // Note that we'll wait for a response ack message received in |
186 // OnMessageReceivedFromRenderView before we call Release() (to prevent the | 186 // OnMessageReceivedFromRenderView before we call Release() (to prevent the |
187 // blob file from being deleted). | 187 // blob file from being deleted). |
188 } | 188 } |
189 | 189 |
190 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { | 190 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { |
191 Browser* browser = NULL; | 191 Browser* browser = NULL; |
192 content::WebContents* web_contents = NULL; | 192 content::WebContents* web_contents = NULL; |
193 | 193 |
194 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(), | 194 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(), |
195 include_incognito(), &browser, NULL, | 195 include_incognito(), &browser, NULL, |
196 &web_contents, NULL)) { | 196 &web_contents, NULL)) { |
197 return NULL; | 197 return NULL; |
198 } | 198 } |
199 return web_contents; | 199 return web_contents; |
200 } | 200 } |
OLD | NEW |