diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 16:50:25 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 16:50:25 +0000 |
commit | 306d30a331a567b078488114b0d9762ab27c1b02 (patch) | |
tree | e868cce1dd42038d0a44e64b651b3b1e65190ca2 | |
parent | 41238a2269b7e131b0cd342d1df65f3a2fa6b2b1 (diff) | |
download | chromium_src-306d30a331a567b078488114b0d9762ab27c1b02.zip chromium_src-306d30a331a567b078488114b0d9762ab27c1b02.tar.gz chromium_src-306d30a331a567b078488114b0d9762ab27c1b02.tar.bz2 |
Revert 102505 - Adding the first one of the saveAs extension APIs.
The saveAsMHTML allows saving a tab as MHTML.
BUG=97306
TEST=Run the browser tests.
Review URL: http://codereview.chromium.org/7946008
TBR=jcivelli@chromium.org
Review URL: http://codereview.chromium.org/8008020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102508 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 26 insertions, 1149 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 74341d0..63791ab 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -39,7 +39,6 @@ #include "chrome/browser/extensions/extension_processes_api.h" #include "chrome/browser/extensions/extension_proxy_api.h" #include "chrome/browser/extensions/extension_rlz_module.h" -#include "chrome/browser/extensions/extension_save_page_api.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_settings_api.h" #include "chrome/browser/extensions/extension_sidebar_api.h" @@ -449,9 +448,6 @@ void FactoryRegistry::ResetFunctions() { RegisterFunction<DownloadsAcceptDangerFunction>(); RegisterFunction<DownloadsShowFunction>(); RegisterFunction<DownloadsDragFunction>(); - - // SavePage - RegisterFunction<SavePageAsMHTMLFunction>(); } void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { diff --git a/chrome/browser/extensions/extension_save_page_api.cc b/chrome/browser/extensions/extension_save_page_api.cc deleted file mode 100644 index 2aee2ce..0000000 --- a/chrome/browser/extensions/extension_save_page_api.cc +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/extension_save_page_api.h" - -#include "base/file_util.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/extension_tabs_module.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/child_process_security_policy.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/download/mhtml_generation_manager.h" -#include "content/common/content_notification_types.h" -#include "content/common/notification_service.h" - -// Error messages. -const char* const kFileTooBigError = "The MHTML file generated is too big."; -const char* const kMHTMLGenerationFailedError = "Failed to generate MHTML."; -const char* const kSizeRetrievalError = - "Failed to retrieve size of generated MHTML."; -const char* const kTemporaryFileError = "Failed to create a temporary file."; -const char* const kTabClosedError = "Cannot find the tab for thie request."; - -SavePageAsMHTMLFunction::SavePageAsMHTMLFunction() : tab_id_(0) { -} - -SavePageAsMHTMLFunction::~SavePageAsMHTMLFunction() { -} - -bool SavePageAsMHTMLFunction::RunImpl() { - EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id_)); - - AddRef(); // Balanced in ReturnFailure/ReturnSuccess() - - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - NewRunnableMethod(this, &SavePageAsMHTMLFunction::CreateTemporaryFile)); - return true; -} - -void SavePageAsMHTMLFunction::CreateTemporaryFile() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - // TODO(jcivelli): http://crbug.com/97489 we don't clean-up the temporary file - // at this point. It must be done before we can take that API - // out of experimental. - bool success = file_util::CreateTemporaryFile(&mhtml_path_); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &SavePageAsMHTMLFunction::TemporaryFileCreated, - success)); -} - -void SavePageAsMHTMLFunction::TemporaryFileCreated(bool success) { - if (!success) { - ReturnFailure(kTemporaryFileError); - return; - } - - Browser* browser = NULL; - TabContentsWrapper* tab_contents_wrapper = NULL; - - if (!ExtensionTabUtil::GetTabById(tab_id_, profile(), include_incognito(), - &browser, NULL, &tab_contents_wrapper, NULL)) { - ReturnFailure(kTabClosedError); - return; - } - - TabContents* tab_contents = tab_contents_wrapper->tab_contents(); - registrar_.Add(this, content::NOTIFICATION_MHTML_GENERATED, - Source<RenderViewHost>(tab_contents->render_view_host())); - // TODO(jcivelli): we should listen for navigation in the tab, tab closed, - // renderer died. - g_browser_process->mhtml_generation_manager()->GenerateMHTML( - tab_contents, mhtml_path_); -} - -void SavePageAsMHTMLFunction::Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_MHTML_GENERATED); - - const MHTMLGenerationManager::NotificationDetails* save_details = - Details<MHTMLGenerationManager::NotificationDetails>(details).ptr(); - - if (mhtml_path_ != save_details->file_path) { - // This could happen if there are concurrent MHTML generations going on for - // the same tab. - LOG(WARNING) << "Received a notification that MHTML was generated but for a" - " different file."; - return; - } - - registrar_.RemoveAll(); - - if (save_details->file_size <= 0) { - ReturnFailure(kMHTMLGenerationFailedError); - return; - } - - if (save_details->file_size > std::numeric_limits<int>::max()) { - ReturnFailure(kFileTooBigError); - return; - } - - ReturnSuccess(save_details->file_size); -} - -void SavePageAsMHTMLFunction::ReturnFailure(const std::string& error) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - error_ = error; - - SendResponse(false); - - Release(); // Balanced in Run() -} - -void SavePageAsMHTMLFunction::ReturnSuccess(int64 file_size) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - int child_id = render_view_host()->process()->id(); - ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( - child_id, mhtml_path_); - - DictionaryValue* dict = new DictionaryValue(); - result_.reset(dict); - dict->SetString("mhtmlFilePath", mhtml_path_.value()); - dict->SetInteger("mhtmlFileLength", file_size); - - SendResponse(true); - - Release(); // Balanced in Run() -} diff --git a/chrome/browser/extensions/extension_save_page_api.h b/chrome/browser/extensions/extension_save_page_api.h deleted file mode 100644 index 9de3f1b..0000000 --- a/chrome/browser/extensions/extension_save_page_api.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ - -#include <string> - -#include "chrome/browser/extensions/extension_function.h" -#include "content/browser/tab_contents/tab_contents_observer.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" - -class SavePageAsMHTMLFunction : public AsyncExtensionFunction, - public NotificationObserver { - public: - SavePageAsMHTMLFunction(); - - private: - virtual ~SavePageAsMHTMLFunction(); - - virtual bool RunImpl() OVERRIDE; - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) OVERRIDE; - - // Called on the file thread. - void CreateTemporaryFile(); - - // Called on the UI thread. - void TemporaryFileCreated(bool success); - void ReturnFailure(const std::string& error); - void ReturnSuccess(int64 file_size); - - int tab_id_; - - // The path to the temporary file containing the MHTML data. - FilePath mhtml_path_; - - NotificationRegistrar registrar_; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.savePage.saveAsMHTML") -}; - -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ diff --git a/chrome/browser/extensions/extension_save_page_apitest.cc b/chrome/browser/extensions/extension_save_page_apitest.cc deleted file mode 100644 index 489ccf6..0000000 --- a/chrome/browser/extensions/extension_save_page_apitest.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/base_switches.h" -#include "base/command_line.h" -#include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/common/chrome_switches.h" -#include "net/base/mock_host_resolver.h" - -class ExtensionSavePageApiTest : public ExtensionApiTest { - public: - // TODO(jcivelli): remove this once save-page APIs are no longer experimental. - virtual void SetUpCommandLine(CommandLine* command_line) { - ExtensionApiTest::SetUpCommandLine(command_line); - command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); - } - - virtual void SetUpInProcessBrowserTestFixture() { - ExtensionApiTest::SetUpInProcessBrowserTestFixture(); - - host_resolver()->AddRule("www.a.com", "127.0.0.1"); - - ASSERT_TRUE(StartTestServer()); - } -}; - -IN_PROC_BROWSER_TEST_F(ExtensionSavePageApiTest, SavePageAsMHTML) { - ASSERT_TRUE(RunExtensionTest("save_page")) << message_; -} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 3415ac2..1b88009 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1067,8 +1067,6 @@ 'browser/extensions/extension_proxy_api_helpers.h', 'browser/extensions/extension_rlz_module.cc', 'browser/extensions/extension_rlz_module.h', - 'browser/extensions/extension_save_page_api.cc', - 'browser/extensions/extension_save_page_api.h', 'browser/extensions/extension_setting_sync_data.cc', 'browser/extensions/extension_setting_sync_data.h', 'browser/extensions/extension_settings.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 817cf84..a5597f2 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2323,7 +2323,6 @@ 'browser/extensions/extension_proxy_apitest.cc', 'browser/extensions/extension_resource_request_policy_apitest.cc', 'browser/extensions/extension_rlz_apitest.cc', - 'browser/extensions/extension_save_page_apitest.cc', 'browser/extensions/extension_settings_apitest.cc', 'browser/extensions/extension_sidebar_apitest.cc', 'browser/extensions/extension_startup_browsertest.cc', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 25530ce..7f755fc 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -8494,36 +8494,5 @@ ] } ] - }, - { - "namespace": "experimental.savePage", - "functions": [ - { - "name": "saveAsMHTML", - "type": "function", - "description": "Saves the content of the tab with given id to MHTML.", - "parameters": [ - { - "name": "tabId", - "type": "integer", - "minimum": 0, - "description": "The id of the tab to save." - }, - { - "name": "callback", - "type": "function", - "description": "Called when the MHTML has been generated.", - "parameters": [ - { - "name": "mhtmlData", - "type": "blob", - "optional": "true", - "description": "The MHTML data as a Blob." - } - ] - } - ] - } - ] } ] diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html index 7b458470..ff4e8cb 100644 --- a/chrome/common/extensions/docs/experimental.html +++ b/chrome/common/extensions/docs/experimental.html @@ -371,7 +371,6 @@ on the following experimental APIs: <a href="experimental.infobars.html">experimental.infobars</a></li><li> <a href="experimental.permissions.html">experimental.permissions</a></li><li> <a href="experimental.privacy.html">experimental.privacy</a></li><li> - <a href="experimental.savePage.html">experimental.savePage</a></li><li> <a href="experimental.settings.html">experimental.settings</a></li><li> <a href="experimental.webNavigation.html">experimental.webNavigation</a></li><li> <a href="experimental.webRequest.html">experimental.webRequest</a></li> diff --git a/chrome/common/extensions/docs/experimental.savePage.html b/chrome/common/extensions/docs/experimental.savePage.html deleted file mode 100644 index e6aae1d..0000000 --- a/chrome/common/extensions/docs/experimental.savePage.html +++ /dev/null @@ -1,749 +0,0 @@ -<!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note: - 1) The <head> information in this page is significant, should be uniform - across api docs and should be edited only with knowledge of the - templating mechanism. - 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a - browser, it will be re-generated from the template, json schema and - authored overview content. - 4) The <body>.innerHTML is also generated by an offline step so that this - page may easily be indexed by search engines. ---><html xmlns="http://www.w3.org/1999/xhtml"><head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> - <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> - <script type="text/javascript" src="../../../third_party/jstemplate/jstemplate_compiled.js"> - </script> - <script type="text/javascript" src="js/api_page_generator.js"></script> - <script type="text/javascript" src="js/bootstrap.js"></script> - <script type="text/javascript" src="js/sidebar.js"></script> - <title>chrome.experimental.savePage - Google Chrome Extensions - Google Code</title></head> - <body> <div id="gc-container" class="labs"> - <div id="devModeWarning"> - You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files. - </div> - <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> - <!-- In particular, sub-templates that recurse, must be used by allowing - jstemplate to make a copy of the template in this section which - are not operated on by way of the jsskip="true" --> - <div style="display:none"> - - <!-- VALUE --> - <div id="valueTemplate"> - <dt> - <var>paramName</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional">optional</span> - <span class="enum">enumerated</span> - <span id="typeTemplate"> - <span> - <a> Type</a> - </span> - <span> - <span> - array of <span><span></span></span> - </span> - <span>paramType</span> - <span></span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo"> - Undocumented. - </dd> - <dd> - Description of this parameter from the json schema. - </dd> - <dd> - This parameter was added in version - <b><span></span></b>. - You must omit this parameter in earlier versions, - and you may omit it in any version. If you require this - parameter, the manifest key - <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> - can ensure that your extension won't be run in an earlier browser version. - </dd> - - <!-- OBJECT PROPERTIES --> - <dd> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - - <!-- OBJECT METHODS --> - <dd> - <div></div> - </dd> - - <!-- OBJECT EVENT FIELDS --> - <dd> - <div></div> - </dd> - - <!-- FUNCTION PARAMETERS --> - <dd> - <div></div> - </dd> - - </div> <!-- /VALUE --> - - <div id="functionParametersTemplate"> - <h5>Parameters</h5> - <dl> - <div> - <div> - </div> - </div> - </dl> - </div> - </div> <!-- /SUBTEMPLATES --> - - <a id="top"></a> - <div id="skipto"> - <a href="#gc-pagecontent">Skip to page content</a> - <a href="#gc-toc">Skip to main navigation</a> - </div> - <!-- API HEADER --> - <table id="header" width="100%" cellspacing="0" border="0"> - <tbody><tr> - <td valign="middle"><a href="http://code.google.com/"><img src="images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td> - <td valign="middle" width="100%" style="padding-left:0.6em;"> - <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em"> - <div id="gsc-search-box"> - <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno"> - <input type="hidden" name="ie" value="UTF-8"> - <input type="text" name="q" value="" size="55"> - <input class="gsc-search-button" type="submit" name="sa" value="Search"> - <br> - <span class="greytext">e.g. "page action" or "tabs"</span> - </div> - </form> - - <script type="text/javascript" src="http://www.google.com/jsapi"></script> - <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script> - <script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse&t13n_langs=en"></script> - <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse&lang=en"></script> - </td> - </tr> - </tbody></table> - - <div id="codesiteContent" class=""> - - <a id="gc-topnav-anchor"></a> - <div id="gc-topnav"> - <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1> - <ul id="home" class="gc-topnav-tabs"> - <li id="home_link"> - <a href="index.html" title="Google Chrome Extensions home page">Home</a> - </li> - <li id="docs_link"> - <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a> - </li> - <li id="faq_link"> - <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a> - </li> - <li id="samples_link"> - <a href="samples.html" title="Sample extensions (with source code)">Samples</a> - </li> - <li id="group_link"> - <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a> - </li> - </ul> - </div> <!-- end gc-topnav --> - - <div class="g-section g-tpl-170"> - <!-- SIDENAV --> - <div class="g-unit g-first" id="gc-toc"> - <ul> - <li><a href="getstarted.html">Getting Started</a></li> - <li><a href="overview.html">Overview</a></li> - <li><a href="whats_new.html">What's New?</a></li> - <li><h2><a href="devguide.html">Developer's Guide</a></h2> - <ul> - <li>Browser UI - <ul> - <li><a href="browserAction.html">Browser Actions</a></li> - <li><a href="contextMenus.html">Context Menus</a></li> - <li><a href="notifications.html">Desktop Notifications</a></li> - <li><a href="omnibox.html">Omnibox</a></li> - <li><a href="options.html">Options Pages</a></li> - <li><a href="override.html">Override Pages</a></li> - <li><a href="pageAction.html">Page Actions</a></li> - </ul> - </li> - <li>Browser Interaction - <ul> - <li><a href="bookmarks.html">Bookmarks</a></li> - <li><a href="cookies.html">Cookies</a></li> - <li><a href="events.html">Events</a></li> - <li><a href="history.html">History</a></li> - <li><a href="management.html">Management</a></li> - <li><a href="tabs.html">Tabs</a></li> - <li><a href="windows.html">Windows</a></li> - </ul> - </li> - <li>Implementation - <ul> - <li><a href="a11y.html">Accessibility</a></li> - <li><a href="background_pages.html">Background Pages</a></li> - <li><a href="content_scripts.html">Content Scripts</a></li> - <li><a href="xhr.html">Cross-Origin XHR</a></li> - <li><a href="i18n.html">Internationalization</a></li> - <li><a href="messaging.html">Message Passing</a></li> - <li><a href="npapi.html">NPAPI Plugins</a></li> - </ul> - </li> - <li>Finishing - <ul> - <li><a href="hosting.html">Hosting</a></li> - <li><a href="external_extensions.html">Other Deployment Options</a></li> - </ul> - </li> - </ul> - </li> - <li><h2><a href="apps.html">Packaged Apps</a></h2></li> - <li><h2><a href="tutorials.html">Tutorials</a></h2> - <ul> - <li><a href="tut_debugging.html">Debugging</a></li> - <li><a href="tut_analytics.html">Google Analytics</a></li> - <li><a href="tut_oauth.html">OAuth</a></li> - </ul> - </li> - <li><h2>Reference</h2> - <ul> - <li>Formats - <ul> - <li><a href="manifest.html">Manifest Files</a></li> - <li><a href="match_patterns.html">Match Patterns</a></li> - </ul> - </li> - <li><a href="permission_warnings.html">Permission Warnings</a></li> - <li><a href="api_index.html">chrome.* APIs</a></li> - <li><a href="api_other.html">Other APIs</a></li> - </ul> - </li> - <li><h2><a href="samples.html">Samples</a></h2></li> - <div class="line"> </div> - <li><h2>More</h2> - <ul> - <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li> - <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li> - <li><a href="themes.html">Themes</a></li> - </ul> - </li> - </ul> - </div> - <script> - initToggles(); - </script> - - <div class="g-unit" id="gc-pagecontent"> - <div id="pageTitle"> - <h1 class="page_title">chrome.experimental.savePage</h1> - </div> - <!-- TABLE OF CONTENTS --> - <div id="toc"> - <h2>Contents</h2> - <ol> - <li> - <a href="#manifest">Manifest</a> - <ol> - <li style="display: none; "> - <a>h3Name</a> - </li> - </ol> - </li> - <li> - <a href="#apiReference">API reference: chrome.experimental.savePage</a> - <ol> - <li style="display: none; "> - <a href="#properties">Properties</a> - <ol> - <li> - <a href="#property-anchor">propertyName</a> - </li> - </ol> - </li> - <li> - <a href="#global-methods">Methods</a> - <ol> - <li> - <a href="#method-saveAsMHTML">saveAsMHTML</a> - </li> - </ol> - </li> - <li style="display: none; "> - <a>Events</a> - <ol> - <li> - <a href="#event-anchor">eventName</a> - </li> - </ol> - </li> - <li style="display: none; "> - <a href="#types">Types</a> - <ol> - <li> - <a href="#id-anchor">id</a> - </li> - </ol> - </li> - </ol> - </li> - </ol> - </div> - <!-- /TABLE OF CONTENTS --> - - <!-- Standard content lead-in for experimental API pages --> - <p id="classSummary"> - For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. - </p> - - <!-- STATIC CONTENT PLACEHOLDER --> - <div id="static"><!-- BEGIN AUTHORED CONTENT --> -<p> -The savePage API allows you to save a tab as MHTML. -</p> - -<p> -MHTML is a <a href="http://tools.ietf.org/html/rfc2557">standard format</a> -supported by most browsers. It encapsulates in a single file a page and all -its resources (CSS files, images..). -</p> - -<p> -Note that for security reasons a MHTML file can only be loaded from the file -system and that it can only be loaded in the main frame. -</p> - -<h2 id="manifest">Manifest</h2> - -<p> -The infobars API is currently -experimental, so you must declare the "experimental" -permission to use it. - -<!-- END AUTHORED CONTENT --> -</p></div> - - <!-- API PAGE --> - <div class="apiPage"> - <a name="apiReference"></a> - <h2>API reference: chrome.experimental.savePage</h2> - - <!-- PROPERTIES --> - <div class="apiGroup" style="display: none; "> - <a name="properties"></a> - <h3 id="properties">Properties</h3> - - <div> - <a></a> - <h4>getLastError</h4> - <div class="summary"> - <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension</span><span>lastError</span> - </div> - <div> - </div> - </div> - - </div> <!-- /apiGroup --> - - <!-- METHODS --> - <div id="methodsTemplate" class="apiGroup"> - <a name="global-methods"></a> - <h3>Methods</h3> - - <!-- iterates over all functions --> - <div class="apiItem"> - <a name="method-saveAsMHTML"></a> <!-- method-anchor --> - <h4>saveAsMHTML</h4> - - <div class="summary"><span style="display: none; ">void</span> - <!-- Note: intentionally longer 80 columns --> - <span>chrome.experimental.savePage.saveAsMHTML</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span> - <var><span>tabId</span></var></span><span class="null"><span>, </span><span>function</span> - <var><span>callback</span></var></span>)</div> - - <div class="description"> - <p class="todo" style="display: none; ">Undocumented.</p> - <p>Saves the content of the tab with given id to MHTML.</p> - - <!-- PARAMETERS --> - <h4>Parameters</h4> - <dl> - <div> - <div> - <dt> - <var>tabId</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional" style="display: none; ">optional</span> - <span class="enum" style="display: none; ">enumerated</span> - <span id="typeTemplate"> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span style="display: none; "> - array of <span><span></span></span> - </span> - <span>integer</span> - <span style="display: none; "></span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo" style="display: none; "> - Undocumented. - </dd> - <dd>The id of the tab to save.</dd> - <dd style="display: none; "> - This parameter was added in version - <b><span></span></b>. - You must omit this parameter in earlier versions, - and you may omit it in any version. If you require this - parameter, the manifest key - <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> - can ensure that your extension won't be run in an earlier browser version. - </dd> - - <!-- OBJECT PROPERTIES --> - <dd style="display: none; "> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - - <!-- OBJECT METHODS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- OBJECT EVENT FIELDS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- FUNCTION PARAMETERS --> - <dd style="display: none; "> - <div></div> - </dd> - - </div> - </div><div> - <div> - <dt> - <var>callback</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional" style="display: none; ">optional</span> - <span class="enum" style="display: none; ">enumerated</span> - <span id="typeTemplate"> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span style="display: none; "> - array of <span><span></span></span> - </span> - <span>function</span> - <span style="display: none; "></span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo" style="display: none; "> - Undocumented. - </dd> - <dd>Called when the MHTML has been generated.</dd> - <dd style="display: none; "> - This parameter was added in version - <b><span></span></b>. - You must omit this parameter in earlier versions, - and you may omit it in any version. If you require this - parameter, the manifest key - <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> - can ensure that your extension won't be run in an earlier browser version. - </dd> - - <!-- OBJECT PROPERTIES --> - <dd style="display: none; "> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - - <!-- OBJECT METHODS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- OBJECT EVENT FIELDS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- FUNCTION PARAMETERS --> - <dd style="display: none; "> - <div></div> - </dd> - - </div> - </div> - </dl> - - <!-- RETURNS --> - <h4 style="display: none; ">Returns</h4> - <dl> - <div style="display: none; "> - <div> - </div> - </div> - </dl> - - <!-- CALLBACK --> - <div> - <div> - <h4>Callback function</h4> - <p> - The callback <em>parameter</em> should specify a function - that looks like this: - </p> - <p style="display: none; "> - If you specify the <em>callback</em> parameter, it should - specify a function that looks like this: - </p> - - <!-- Note: intentionally longer 80 columns --> - <pre>function(<span>blob mhtmlData</span>) <span class="subdued">{...}</span>;</pre> - <dl> - <div> - <div> - <dt> - <var>mhtmlData</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional">optional</span> - <span class="enum" style="display: none; ">enumerated</span> - <span id="typeTemplate"> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span style="display: none; "> - array of <span><span></span></span> - </span> - <span>blob</span> - <span style="display: none; "></span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo" style="display: none; "> - Undocumented. - </dd> - <dd>The MHTML data as a Blob.</dd> - <dd style="display: none; "> - This parameter was added in version - <b><span></span></b>. - You must omit this parameter in earlier versions, - and you may omit it in any version. If you require this - parameter, the manifest key - <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> - can ensure that your extension won't be run in an earlier browser version. - </dd> - - <!-- OBJECT PROPERTIES --> - <dd style="display: none; "> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - - <!-- OBJECT METHODS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- OBJECT EVENT FIELDS --> - <dd style="display: none; "> - <div></div> - </dd> - - <!-- FUNCTION PARAMETERS --> - <dd style="display: none; "> - <div></div> - </dd> - - </div> - </div> - </dl> - </div> - </div> - - <!-- MIN_VERSION --> - <p style="display: none; "> - This function was added in version <b><span></span></b>. - If you require this function, the manifest key - <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> - can ensure that your extension won't be run in an earlier browser version. - </p> - </div> <!-- /description --> - - </div> <!-- /apiItem --> - - </div> <!-- /apiGroup --> - - <!-- EVENTS --> - <div id="eventsTemplate" class="apiGroup" style="display: none; "> - <a></a> - <h3>Events</h3> - <!-- iterates over all events --> - <div class="apiItem"> - <a></a> - <h4>event name</h4> - - <div class="summary"> - <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span><span>, Type opt_param1, Type opt_param2</span>); - </div> - - <div class="description"> - <p class="todo">Undocumented.</p> - <p> - A description from the json schema def of the event goes here. - </p> - - <!-- LISTENER PARAMETERS --> - <div> - <h4>Listener parameters</h4> - <dl> - <div> - <div> - </div> - </div> - </dl> - </div> - - <!-- EXTRA PARAMETERS --> - <div> - <h4>Extra parameters to addListener</h4> - <dl> - <div> - <div> - </div> - </div> - </dl> - </div> - - <!-- LISTENER RETURN VALUE --> - <h4>Listener returns</h4> - <dl> - <div> - <div> - </div> - </div> - </dl> - - </div> <!-- /description --> - </div> <!-- /apiItem --> - - </div> <!-- /apiGroup --> - - <!-- TYPES --> - <div class="apiGroup" style="display: none; "> - <a name="types"></a> - <h3 id="types">Types</h3> - - <!-- iterates over all types --> - <div class="apiItem"> - <a></a> - <h4>type name</h4> - - <div> - </div> - - </div> <!-- /apiItem --> - - </div> <!-- /apiGroup --> - - </div> <!-- /apiPage --> - </div> <!-- /gc-pagecontent --> - </div> <!-- /g-section --> - </div> <!-- /codesiteContent --> - <div id="gc-footer" --=""> - <div class="text"> - <p> - Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>, - the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons - Attribution 3.0 License</a>, and code samples are licensed under the - <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>. - </p> - <p> - ©2011 Google - </p> - -<!-- begin analytics --> -<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> -<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script> - -<script type="text/javascript"> - // chrome doc tracking - try { - var engdocs = _gat._getTracker("YT-10763712-2"); - engdocs._trackPageview(); - } catch(err) {} - - // code.google.com site-wide tracking - try { - _uacct="UA-18071-1"; - _uanchor=1; - _uff=0; - urchinTracker(); - } - catch(e) {/* urchinTracker not available. */} -</script> -<!-- end analytics --> - </div> - </div> <!-- /gc-footer --> - </div> <!-- /gc-container --> -</body></html> diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json index f3e7484..2f4bdbe 100644 --- a/chrome/common/extensions/docs/samples.json +++ b/chrome/common/extensions/docs/samples.json @@ -72,7 +72,6 @@ "chrome.experimental.permissions.onRemoved": "experimental.permissions.html#event-onRemoved", "chrome.experimental.permissions.remove": "experimental.permissions.html#method-remove", "chrome.experimental.permissions.request": "experimental.permissions.html#method-request", - "chrome.experimental.savePage.saveAsMHTML": "experimental.savePage.html#method-saveAsMHTML", "chrome.experimental.settings.clear": "experimental.settings.html#method-clear", "chrome.experimental.settings.get": "experimental.settings.html#method-get", "chrome.experimental.settings.remove": "experimental.settings.html#method-remove", diff --git a/chrome/common/extensions/docs/static/experimental.savePage.html b/chrome/common/extensions/docs/static/experimental.savePage.html deleted file mode 100644 index 06910d4..0000000 --- a/chrome/common/extensions/docs/static/experimental.savePage.html +++ /dev/null @@ -1,24 +0,0 @@ -<!-- BEGIN AUTHORED CONTENT --> -<p> -The savePage API allows you to save a tab as MHTML. -</p> - -<p> -MHTML is a <a href="http://tools.ietf.org/html/rfc2557">standard format</a> -supported by most browsers. It encapsulates in a single file a page and all -its resources (CSS files, images..). -</p> - -<p> -Note that for security reasons a MHTML file can only be loaded from the file -system and that it can only be loaded in the main frame. -</p> - -<h2 id="manifest">Manifest</h2> - -<p> -The infobars API is currently -experimental, so you must declare the "experimental" -permission to use it. - -<!-- END AUTHORED CONTENT --> diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 2bbd4aa..5efb997 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -14,7 +14,6 @@ #include "base/memory/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_util.h" -#include "base/utf_string_conversions.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_action.h" #include "chrome/common/extensions/extension_constants.h" @@ -37,7 +36,6 @@ #include "content/renderer/render_view_visitor.h" #include "grit/common_resources.h" #include "grit/renderer_resources.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" @@ -185,8 +183,6 @@ class ExtensionImpl : public ExtensionBase { return v8::FunctionTemplate::New(GetLocalFileSystem); } else if (name->Equals(v8::String::New("DecodeJPEG"))) { return v8::FunctionTemplate::New(DecodeJPEG, v8::External::New(this)); - } else if (name->Equals(v8::String::New("CreateBlob"))) { - return v8::FunctionTemplate::New(CreateBlob, v8::External::New(this)); } return ExtensionBase::GetNativeFunction(name); @@ -345,17 +341,6 @@ class ExtensionImpl : public ExtensionBase { return bitmap_array; } - // Creates a Blob with the content of the specified file. - static v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args) { - CHECK(args.Length() == 2); - CHECK(args[0]->IsString()); - CHECK(args[1]->IsInt32()); - WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); - WebKit::WebBlob blob = - WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); - return blob.toV8Value(); - } - // Creates a new messaging channel to the tab with the given ID. static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) { // Get the current RenderView so that we can send a routed IPC message from diff --git a/chrome/renderer/resources/extensions/extension_process_bindings.js b/chrome/renderer/resources/extensions/extension_process_bindings.js index e6440af..75bbb02 100644 --- a/chrome/renderer/resources/extensions/extension_process_bindings.js +++ b/chrome/renderer/resources/extensions/extension_process_bindings.js @@ -22,8 +22,7 @@ var chrome = chrome || {}; native function SetIconCommon(); native function GetUniqueSubEventName(eventName); native function GetLocalFileSystem(name, path); - native function DecodeJPEG(jpegImage); - native function CreateBlob(filePath); + native function DecodeJPEG(jpeg_image); var chromeHidden = GetChromeHidden(); @@ -741,18 +740,6 @@ var chrome = chrome || {}; }); }; - apiFunctions["experimental.savePage.saveAsMHTML"].customCallback = - function(name, request, response) { - var params = chromeHidden.JSON.parse(response); - var path = params.mhtmlFilePath; - var size = params.mhtmlFileLength; - - if (request.callback) - request.callback(CreateBlob(path, size)); - - request.callback = null; - }; - apiFunctions["fileBrowserPrivate.requestLocalFileSystem"].customCallback = function(name, request, response) { var resp = response ? [chromeHidden.JSON.parse(response)] : []; diff --git a/chrome/renderer/resources/extensions/renderer_process_bindings.js b/chrome/renderer/resources/extensions/renderer_process_bindings.js index 32f5f2e..52327c3 100644 --- a/chrome/renderer/resources/extensions/renderer_process_bindings.js +++ b/chrome/renderer/resources/extensions/renderer_process_bindings.js @@ -324,7 +324,6 @@ var chrome = chrome || {}; "experimental.processes", "experimental.privacy", "experimental.rlz", - "experimental.savePage", "experimental.sidebar", "experimental.webNavigation", "experimental.webRequest", diff --git a/chrome/test/data/extensions/api_test/save_page/background.html b/chrome/test/data/extensions/api_test/save_page/background.html deleted file mode 100644 index 46f4d74..0000000 --- a/chrome/test/data/extensions/api_test/save_page/background.html +++ /dev/null @@ -1 +0,0 @@ -<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/save_page/google.html b/chrome/test/data/extensions/api_test/save_page/google.html deleted file mode 100644 index 3cb0e0e..0000000 --- a/chrome/test/data/extensions/api_test/save_page/google.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> - <body> - <h1>Welcome to the Google</h1> - <img src="logo.png"/> - <form> - <input type="text"/ name="seachQuery"><input type="submit"/> - </form> - </body> -</html> diff --git a/chrome/test/data/extensions/api_test/save_page/logo.png b/chrome/test/data/extensions/api_test/save_page/logo.png Binary files differdeleted file mode 100644 index 99b37d5..0000000 --- a/chrome/test/data/extensions/api_test/save_page/logo.png +++ /dev/null diff --git a/chrome/test/data/extensions/api_test/save_page/manifest.json b/chrome/test/data/extensions/api_test/save_page/manifest.json deleted file mode 100644 index 97e4eb7..0000000 --- a/chrome/test/data/extensions/api_test/save_page/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "chrome.extension.savePage", - "version": "0.1", - "description": "Tests that the savePage extension API work.", - "background_page": "background.html", - "permissions": ["experimental", "tabs"] -} diff --git a/chrome/test/data/extensions/api_test/save_page/test.js b/chrome/test/data/extensions/api_test/save_page/test.js deleted file mode 100644 index 9b69cd9..0000000 --- a/chrome/test/data/extensions/api_test/save_page/test.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// API test for chrome.extension.savePage. -// browser_tests.exe --gtest_filter=ExtensionApiTest.SavePage - -const assertEq = chrome.test.assertEq; -const assertTrue = chrome.test.assertTrue; - -var testUrl = 'http://www.a.com:PORT' + - '/files/extensions/api_test/save_page/google.html'; - -function waitForCurrentTabLoaded(callback) { - chrome.tabs.getSelected(null, function(tab) { - if (tab.status == "complete" && tab.url == testUrl) { - callback(); - return; - } - window.setTimeout(function() { waitForCurrentTabLoaded(callback); }, 100); - }); -} - -chrome.test.getConfig(function(config) { - testUrl = testUrl.replace(/PORT/, config.testServer.port); - - chrome.test.runTests([ - function savePageAsMHTML() { - chrome.tabs.getSelected(null, function(tab) { - chrome.tabs.update(null, { "url": testUrl }); - waitForCurrentTabLoaded(function() { - chrome.experimental.savePage.saveAsMHTML(tab.id, function(data) { - assertEq(undefined, chrome.extension.lastError); - assertTrue(data != null); - // It should contain few KBs of data. - assertTrue(data.size > 100); - // Let's make sure it contains some well known strings. - var reader = new FileReader(); - reader.onload = function(e) { - var text = e.target.result; - assertTrue(text.indexOf(testUrl) != -1); - assertTrue(text.indexOf("logo.png") != -1); - chrome.test.notifyPass(); - }; - reader.readAsText(data); - }); - }); - }); - } - ]); -}); - diff --git a/content/browser/download/mhtml_generation_browsertest.cc b/content/browser/download/mhtml_generation_browsertest.cc index 2d5e378..b0589a8 100644 --- a/content/browser/download/mhtml_generation_browsertest.cc +++ b/content/browser/download/mhtml_generation_browsertest.cc @@ -55,9 +55,9 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { MHTMLGenerationManager::NotificationDetails details; ASSERT_TRUE(signal.GetDetailsFor(source.map_key(), &details)); - ASSERT_GT(details.file_size, 0); + ASSERT_TRUE(details.success); - // Make sure the actual generated file has some contents. + // Make sure the generated file has some contents. int64 file_size; ASSERT_TRUE(file_util::GetFileSize(path, &file_size)); EXPECT_GT(file_size, 100); diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc index 1448569..fe60ed1 100644 --- a/content/browser/download/mhtml_generation_manager.cc +++ b/content/browser/download/mhtml_generation_manager.cc @@ -45,8 +45,8 @@ void MHTMLGenerationManager::GenerateMHTML(TabContents* tab_contents, job_id, file, renderer_process)); } -void MHTMLGenerationManager::MHTMLGenerated(int job_id, int64 mhtml_data_size) { - JobFinished(job_id, mhtml_data_size); +void MHTMLGenerationManager::MHTMLGenerated(int job_id, bool success) { + JobFinished(job_id, success); } void MHTMLGenerationManager::CreateFile(int job_id, const FilePath& file_path, @@ -74,7 +74,7 @@ void MHTMLGenerationManager::FileCreated(int job_id, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (browser_file == base::kInvalidPlatformFileValue) { LOG(ERROR) << "Failed to create file"; - JobFinished(job_id, -1); + JobFinished(job_id, false); return; } @@ -91,7 +91,7 @@ void MHTMLGenerationManager::FileCreated(int job_id, RenderViewHost* rvh = RenderViewHost::FromID(job.process_id, job.routing_id); if (!rvh) { // The tab went away. - JobFinished(job_id, -1); + JobFinished(job_id, false); return; } @@ -99,7 +99,7 @@ void MHTMLGenerationManager::FileCreated(int job_id, renderer_file)); } -void MHTMLGenerationManager::JobFinished(int job_id, int64 file_size) { +void MHTMLGenerationManager::JobFinished(int job_id, bool success) { IDToJobMap::iterator iter = id_to_job_.find(job_id); if (iter == id_to_job_.end()) { NOTREACHED(); @@ -112,7 +112,7 @@ void MHTMLGenerationManager::JobFinished(int job_id, int64 file_size) { if (rvh) { NotificationDetails details; details.file_path = job.file_path; - details.file_size = file_size; + details.success = success; NotificationService::current()->Notify( content::NOTIFICATION_MHTML_GENERATED, diff --git a/content/browser/download/mhtml_generation_manager.h b/content/browser/download/mhtml_generation_manager.h index 47c847e..9271327 100644 --- a/content/browser/download/mhtml_generation_manager.h +++ b/content/browser/download/mhtml_generation_manager.h @@ -28,15 +28,13 @@ class CONTENT_EXPORT MHTMLGenerationManager // page for |tab_contents|. void GenerateMHTML(TabContents* tab_contents, const FilePath& file); - // Notification from the renderer that the MHTML generation finished. - // |mhtml_data_size| contains the size in bytes of the generated MHTML data, - // or -1 in case of failure. - void MHTMLGenerated(int job_id, int64 mhtml_data_size); + // Notification from the renderer that the MHTML generation succeeded/failed. + void MHTMLGenerated(int job_id, bool success); // The details sent along with the MHTML_GENERATED notification. struct NotificationDetails { FilePath file_path; - int64 file_size; + bool success; }; private: @@ -73,8 +71,7 @@ class CONTENT_EXPORT MHTMLGenerationManager // Called on the UI thread when a job has been processed (successfully or // not). Closes the file and removes the job from the job map. - // |mhtml_data_size| is -1 if the MHTML generation failed. - void JobFinished(int job_id, int64 mhtml_data_size); + void JobFinished(int job_id, bool success); typedef std::map<int, Job> IDToJobMap; IDToJobMap id_to_job_; diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index d802c31..53ec7ba 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -995,7 +995,7 @@ void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { content::GetContentClient()->browser()->OpenItem(path); } -void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { +void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, bool success) { content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> - MHTMLGenerated(job_id, data_size); + MHTMLGenerated(job_id, success); } diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/browser_render_process_host.h index 456de48..97297e9 100644 --- a/content/browser/renderer_host/browser_render_process_host.h +++ b/content/browser/renderer_host/browser_render_process_host.h @@ -96,7 +96,7 @@ class BrowserRenderProcessHost : public RenderProcessHost, void SuddenTerminationChanged(bool enabled); void OnUserMetricsRecordAction(const std::string& action); void OnRevealFolderInOS(const FilePath& path); - void OnSavedPageAsMHTML(int job_id, int64 mhtml_file_size); + void OnSavedPageAsMHTML(int job_id, bool success); // Generates a command line to be used to spawn a renderer and appends the // results to |*command_line|. diff --git a/content/common/view_messages.h b/content/common/view_messages.h index eba3835..ea9b902 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1923,7 +1923,7 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_UserMetricsRecordAction, // Notifies the browser that the page was or was not saved as MHTML. IPC_MESSAGE_CONTROL2(ViewHostMsg_SavedPageAsMHTML, int /* job_id */, - int64 /* size of the MHTML file, -1 if error */) + bool /* success */) IPC_MESSAGE_ROUTED3(ViewHostMsg_SendCurrentPageAllSavableResourceLinks, std::vector<GURL> /* all savable resource links */, diff --git a/content/renderer/mhtml_generator.cc b/content/renderer/mhtml_generator.cc index 6c5f262..b5b9423 100644 --- a/content/renderer/mhtml_generator.cc +++ b/content/renderer/mhtml_generator.cc @@ -33,18 +33,18 @@ void MHTMLGenerator::OnSavePageAsMHTML( base::PlatformFile file = IPC::PlatformFileForTransitToPlatformFile(file_for_transit); file_ = file; - int64 size = GenerateMHTML(); - NotifyBrowser(job_id, size); + bool success = GenerateMHTML(); + NotifyBrowser(job_id, success); } -void MHTMLGenerator::NotifyBrowser(int job_id, int64 data_size) { - render_view()->Send(new ViewHostMsg_SavedPageAsMHTML(job_id, data_size)); +void MHTMLGenerator::NotifyBrowser(int job_id, bool success) { + render_view()->Send(new ViewHostMsg_SavedPageAsMHTML(job_id, success)); file_ = base::kInvalidPlatformFileValue; } // TODO(jcivelli): write the chunks in deferred tasks to give a chance to the // message loop to process other events. -int64 MHTMLGenerator::GenerateMHTML() { +bool MHTMLGenerator::GenerateMHTML() { WebKit::WebCString mhtml = WebKit::WebPageSerializer::serializeToMHTML(render_view()->webview()); const size_t chunk_size = 1024; @@ -57,8 +57,8 @@ int64 MHTMLGenerator::GenerateMHTML() { data + total_bytes_written, copy_size); if (bytes_written == -1) - return -1; + return false; total_bytes_written += bytes_written; } - return total_bytes_written; + return true; } diff --git a/content/renderer/mhtml_generator.h b/content/renderer/mhtml_generator.h index 96c2a8a..5531095 100644 --- a/content/renderer/mhtml_generator.h +++ b/content/renderer/mhtml_generator.h @@ -21,9 +21,8 @@ class MHTMLGenerator : public RenderViewObserver { void OnSavePageAsMHTML(int job_id, IPC::PlatformFileForTransit file_for_transit); - void NotifyBrowser(int job_id, int64 data_size); - // Returns the size of the generated MHTML, -1 if it failed. - int64 GenerateMHTML(); + void NotifyBrowser(int job_id, bool success); + bool GenerateMHTML(); base::PlatformFile file_; |