OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_save_page_api.h" | 5 #include "chrome/browser/extensions/extension_save_page_api.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const char* const kTemporaryFileError = "Failed to create a temporary file."; | 26 const char* const kTemporaryFileError = "Failed to create a temporary file."; |
27 const char* const kTabClosedError = "Cannot find the tab for thie request."; | 27 const char* const kTabClosedError = "Cannot find the tab for thie request."; |
28 | 28 |
29 SavePageAsMHTMLFunction::SavePageAsMHTMLFunction() : tab_id_(0) { | 29 SavePageAsMHTMLFunction::SavePageAsMHTMLFunction() : tab_id_(0) { |
30 } | 30 } |
31 | 31 |
32 SavePageAsMHTMLFunction::~SavePageAsMHTMLFunction() { | 32 SavePageAsMHTMLFunction::~SavePageAsMHTMLFunction() { |
33 } | 33 } |
34 | 34 |
35 bool SavePageAsMHTMLFunction::RunImpl() { | 35 bool SavePageAsMHTMLFunction::RunImpl() { |
36 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id_)); | 36 DictionaryValue* args; |
| 37 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); |
| 38 |
| 39 if (!args->HasKey("tabId")) |
| 40 return false; |
| 41 |
| 42 EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id_)); |
37 | 43 |
38 AddRef(); // Balanced in ReturnFailure/ReturnSuccess() | 44 AddRef(); // Balanced in ReturnFailure/ReturnSuccess() |
39 | 45 |
40 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 46 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
41 NewRunnableMethod(this, &SavePageAsMHTMLFunction::CreateTemporaryFile)); | 47 NewRunnableMethod(this, &SavePageAsMHTMLFunction::CreateTemporaryFile)); |
42 return true; | 48 return true; |
43 } | 49 } |
44 | 50 |
45 void SavePageAsMHTMLFunction::CreateTemporaryFile() { | 51 void SavePageAsMHTMLFunction::CreateTemporaryFile() { |
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 136 |
131 DictionaryValue* dict = new DictionaryValue(); | 137 DictionaryValue* dict = new DictionaryValue(); |
132 result_.reset(dict); | 138 result_.reset(dict); |
133 dict->SetString("mhtmlFilePath", mhtml_path_.value()); | 139 dict->SetString("mhtmlFilePath", mhtml_path_.value()); |
134 dict->SetInteger("mhtmlFileLength", file_size); | 140 dict->SetInteger("mhtmlFileLength", file_size); |
135 | 141 |
136 SendResponse(true); | 142 SendResponse(true); |
137 | 143 |
138 Release(); // Balanced in Run() | 144 Release(); // Balanced in Run() |
139 } | 145 } |
OLD | NEW |