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 #include <memory> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "content/public/browser/child_process_security_policy.h" | 15 #include "content/public/browser/child_process_security_policy.h" |
15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
17 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 WebContents* web_contents = GetWebContents(); | 168 WebContents* web_contents = GetWebContents(); |
168 if (!web_contents || !render_frame_host()) { | 169 if (!web_contents || !render_frame_host()) { |
169 ReturnFailure(kTabClosedError); | 170 ReturnFailure(kTabClosedError); |
170 return; | 171 return; |
171 } | 172 } |
172 | 173 |
173 int child_id = render_frame_host()->GetProcess()->GetID(); | 174 int child_id = render_frame_host()->GetProcess()->GetID(); |
174 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( | 175 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( |
175 child_id, mhtml_path_); | 176 child_id, mhtml_path_); |
176 | 177 |
177 base::DictionaryValue* dict = new base::DictionaryValue(); | 178 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
178 SetResult(dict); | |
179 dict->SetString("mhtmlFilePath", mhtml_path_.value()); | 179 dict->SetString("mhtmlFilePath", mhtml_path_.value()); |
180 dict->SetInteger("mhtmlFileLength", file_size); | 180 dict->SetInteger("mhtmlFileLength", file_size); |
| 181 SetResult(std::move(dict)); |
181 | 182 |
182 SendResponse(true); | 183 SendResponse(true); |
183 | 184 |
184 // 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 |
185 // OnMessageReceived before we call Release() (to prevent the blob file from | 186 // OnMessageReceived before we call Release() (to prevent the blob file from |
186 // being deleted). | 187 // being deleted). |
187 } | 188 } |
188 | 189 |
189 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { | 190 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { |
190 Browser* browser = NULL; | 191 Browser* browser = NULL; |
191 content::WebContents* web_contents = NULL; | 192 content::WebContents* web_contents = NULL; |
192 | 193 |
193 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, | 194 if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, |
194 GetProfile(), | 195 GetProfile(), |
195 include_incognito(), | 196 include_incognito(), |
196 &browser, | 197 &browser, |
197 NULL, | 198 NULL, |
198 &web_contents, | 199 &web_contents, |
199 NULL)) { | 200 NULL)) { |
200 return NULL; | 201 return NULL; |
201 } | 202 } |
202 return web_contents; | 203 return web_contents; |
203 } | 204 } |
OLD | NEW |