Refactor chrome.pageCapture to use JSON schema compiler

BUG=121174


Review URL: https://chromiumcodereview.appspot.com/10806072

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149110 0039d316-1c4b-4281-b951-d872f2087c98
parent c19003d9
......@@ -26,6 +26,8 @@ using content::WebContents;
using extensions::PageCaptureSaveAsMHTMLFunction;
using webkit_blob::ShareableFileReference;
namespace SaveAsMHTML = extensions::api::page_capture::SaveAsMHTML;
namespace {
// Error messages.
......@@ -40,7 +42,7 @@ const char* const kTabClosedError = "Cannot find the tab for thie request.";
static PageCaptureSaveAsMHTMLFunction::TestDelegate* test_delegate_ = NULL;
PageCaptureSaveAsMHTMLFunction::PageCaptureSaveAsMHTMLFunction() : tab_id_(0) {
PageCaptureSaveAsMHTMLFunction::PageCaptureSaveAsMHTMLFunction() {
}
PageCaptureSaveAsMHTMLFunction::~PageCaptureSaveAsMHTMLFunction() {
......@@ -55,13 +57,8 @@ void PageCaptureSaveAsMHTMLFunction::SetTestDelegate(TestDelegate* delegate) {
}
bool PageCaptureSaveAsMHTMLFunction::RunImpl() {
DictionaryValue* args;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
if (!args->HasKey("tabId"))
return false;
EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id_));
params_ = SaveAsMHTML::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
AddRef(); // Balanced in ReturnFailure/ReturnSuccess()
......@@ -193,8 +190,9 @@ WebContents* PageCaptureSaveAsMHTMLFunction::GetWebContents() {
Browser* browser = NULL;
TabContents* tab_contents = NULL;
if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(),
&browser, NULL, &tab_contents, NULL)) {
if (!ExtensionTabUtil::GetTabById(params_->details.tab_id, profile(),
include_incognito(), &browser, NULL,
&tab_contents, NULL)) {
return NULL;
}
return tab_contents->web_contents();
......
......@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/extension_function.h"
#include "chrome/common/extensions/api/page_capture.h"
#include "webkit/blob/shareable_file_reference.h"
class FilePath;
......@@ -52,7 +53,7 @@ class PageCaptureSaveAsMHTMLFunction : public AsyncExtensionFunction {
// Returns the WebContents we are associated with, NULL if it's been closed.
content::WebContents* GetWebContents();
int tab_id_;
scoped_ptr<extensions::api::page_capture::SaveAsMHTML::Params> params_;
// The path to the temporary file containing the MHTML data.
FilePath mhtml_path_;
......
......@@ -27,6 +27,7 @@
'i18n.json',
'font_settings.json',
'history.json',
'page_capture.json',
'permissions.json',
'storage.json',
'tabs.json',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment