| 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/extension_page_capture_api.h" | 5 #include "chrome/browser/extensions/extension_page_capture_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 void PageCaptureSaveAsMHTMLFunction::ReturnSuccess(int64 file_size) { | 160 void PageCaptureSaveAsMHTMLFunction::ReturnSuccess(int64 file_size) { |
| 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 162 | 162 |
| 163 WebContents* web_contents = GetWebContents(); | 163 WebContents* web_contents = GetWebContents(); |
| 164 if (!web_contents || !render_view_host()) { | 164 if (!web_contents || !render_view_host()) { |
| 165 ReturnFailure(kTabClosedError); | 165 ReturnFailure(kTabClosedError); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 int child_id = render_view_host()->process()->GetID(); | 169 int child_id = render_view_host()->GetProcess()->GetID(); |
| 170 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( | 170 ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( |
| 171 child_id, mhtml_path_); | 171 child_id, mhtml_path_); |
| 172 | 172 |
| 173 DictionaryValue* dict = new DictionaryValue(); | 173 DictionaryValue* dict = new DictionaryValue(); |
| 174 result_.reset(dict); | 174 result_.reset(dict); |
| 175 dict->SetString("mhtmlFilePath", mhtml_path_.value()); | 175 dict->SetString("mhtmlFilePath", mhtml_path_.value()); |
| 176 dict->SetInteger("mhtmlFileLength", file_size); | 176 dict->SetInteger("mhtmlFileLength", file_size); |
| 177 | 177 |
| 178 SendResponse(true); | 178 SendResponse(true); |
| 179 | 179 |
| 180 // Note that we'll wait for a response ack message received in | 180 // Note that we'll wait for a response ack message received in |
| 181 // OnMessageReceivedFromRenderView before we call Release() (to prevent the | 181 // OnMessageReceivedFromRenderView before we call Release() (to prevent the |
| 182 // blob file from being deleted). | 182 // blob file from being deleted). |
| 183 } | 183 } |
| 184 | 184 |
| 185 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { | 185 WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() { |
| 186 Browser* browser = NULL; | 186 Browser* browser = NULL; |
| 187 TabContentsWrapper* tab_contents_wrapper = NULL; | 187 TabContentsWrapper* tab_contents_wrapper = NULL; |
| 188 | 188 |
| 189 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), | 189 if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), |
| 190 &browser, NULL, &tab_contents_wrapper, NULL)) { | 190 &browser, NULL, &tab_contents_wrapper, NULL)) { |
| 191 return NULL; | 191 return NULL; |
| 192 } | 192 } |
| 193 return tab_contents_wrapper->web_contents(); | 193 return tab_contents_wrapper->web_contents(); |
| 194 } | 194 } |
| OLD | NEW |