diff options
23 files changed, 108 insertions, 80 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 443f299..1e1fd1c 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -3899,6 +3899,9 @@ are declared in build/common.gypi. <message name="IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT" desc="Permisson string for access to extension management."> Your list of installed apps, extensions, and themes </message> + <message name="IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT" desc="Permisson string for access to page capture."> + The content of pages you visit + </message> <message name="IDS_EXTENSION_PROMPT_WARNING_TABS" desc="Permission string for access to tabs."> Your tabs and browsing activity </message> diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 19e0c2ad..7d922e4 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -32,11 +32,11 @@ #include "chrome/browser/extensions/extension_module.h" #include "chrome/browser/extensions/extension_omnibox_api.h" #include "chrome/browser/extensions/extension_page_actions_module.h" +#include "chrome/browser/extensions/extension_page_capture_api.h" #include "chrome/browser/extensions/extension_permissions_api.h" #include "chrome/browser/extensions/extension_preference_api.h" #include "chrome/browser/extensions/extension_processes_api.h" #include "chrome/browser/extensions/extension_proxy_api.h" -#include "chrome/browser/extensions/extension_save_page_api.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/settings/settings_api.h" #include "chrome/browser/extensions/extension_sidebar_api.h" @@ -463,8 +463,8 @@ void FactoryRegistry::ResetFunctions() { RegisterFunction<DownloadsShowFunction>(); RegisterFunction<DownloadsDragFunction>(); - // SavePage - RegisterFunction<SavePageAsMHTMLFunction>(); + // PageCapture + RegisterFunction<PageCaptureSaveAsMHTMLFunction>(); // TopSites RegisterFunction<GetTopSitesFunction>(); diff --git a/chrome/browser/extensions/extension_save_page_api.cc b/chrome/browser/extensions/extension_page_capture_api.cc index 6a8bde6..351c92c 100644 --- a/chrome/browser/extensions/extension_save_page_api.cc +++ b/chrome/browser/extensions/extension_page_capture_api.cc @@ -2,7 +2,7 @@ // 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 "chrome/browser/extensions/extension_page_capture_api.h" #include "base/bind.h" #include "base/file_util.h" @@ -28,19 +28,19 @@ const char* const kSizeRetrievalError = const char* const kTemporaryFileError = "Failed to create a temporary file."; const char* const kTabClosedError = "Cannot find the tab for thie request."; -static SavePageAsMHTMLFunction::TestDelegate* test_delegate_ = NULL; +static PageCaptureSaveAsMHTMLFunction::TestDelegate* test_delegate_ = NULL; -SavePageAsMHTMLFunction::SavePageAsMHTMLFunction() : tab_id_(0) { +PageCaptureSaveAsMHTMLFunction::PageCaptureSaveAsMHTMLFunction() : tab_id_(0) { } -SavePageAsMHTMLFunction::~SavePageAsMHTMLFunction() { +PageCaptureSaveAsMHTMLFunction::~PageCaptureSaveAsMHTMLFunction() { } -void SavePageAsMHTMLFunction::SetTestDelegate(TestDelegate* delegate) { +void PageCaptureSaveAsMHTMLFunction::SetTestDelegate(TestDelegate* delegate) { test_delegate_ = delegate; } -bool SavePageAsMHTMLFunction::RunImpl() { +bool PageCaptureSaveAsMHTMLFunction::RunImpl() { DictionaryValue* args; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); @@ -52,11 +52,12 @@ bool SavePageAsMHTMLFunction::RunImpl() { AddRef(); // Balanced in ReturnFailure/ReturnSuccess() BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - NewRunnableMethod(this, &SavePageAsMHTMLFunction::CreateTemporaryFile)); + NewRunnableMethod(this, + &PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile)); return true; } -bool SavePageAsMHTMLFunction::OnMessageReceivedFromRenderView( +bool PageCaptureSaveAsMHTMLFunction::OnMessageReceivedFromRenderView( const IPC::Message& message) { if (message.type() != ExtensionHostMsg_ResponseAck::ID) return false; @@ -78,15 +79,16 @@ bool SavePageAsMHTMLFunction::OnMessageReceivedFromRenderView( return true; } -void SavePageAsMHTMLFunction::CreateTemporaryFile() { +void PageCaptureSaveAsMHTMLFunction::CreateTemporaryFile() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); bool success = file_util::CreateTemporaryFile(&mhtml_path_); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &SavePageAsMHTMLFunction::TemporaryFileCreated, + NewRunnableMethod(this, + &PageCaptureSaveAsMHTMLFunction::TemporaryFileCreated, success)); } -void SavePageAsMHTMLFunction::TemporaryFileCreated(bool success) { +void PageCaptureSaveAsMHTMLFunction::TemporaryFileCreated(bool success) { if (!success) { ReturnFailure(kTemporaryFileError); return; @@ -107,14 +109,14 @@ void SavePageAsMHTMLFunction::TemporaryFileCreated(bool success) { } MHTMLGenerationManager::GenerateMHTMLCallback callback = - base::Bind(&SavePageAsMHTMLFunction::MHTMLGenerated, this); + base::Bind(&PageCaptureSaveAsMHTMLFunction::MHTMLGenerated, this); g_browser_process->mhtml_generation_manager()->GenerateMHTML( tab_contents, mhtml_path_, callback); } -void SavePageAsMHTMLFunction::MHTMLGenerated(const FilePath& file_path, - int64 mhtml_file_size) { +void PageCaptureSaveAsMHTMLFunction::MHTMLGenerated(const FilePath& file_path, + int64 mhtml_file_size) { DCHECK(mhtml_path_ == file_path); if (mhtml_file_size <= 0) { ReturnFailure(kMHTMLGenerationFailedError); @@ -129,7 +131,7 @@ void SavePageAsMHTMLFunction::MHTMLGenerated(const FilePath& file_path, ReturnSuccess(mhtml_file_size); } -void SavePageAsMHTMLFunction::ReturnFailure(const std::string& error) { +void PageCaptureSaveAsMHTMLFunction::ReturnFailure(const std::string& error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); error_ = error; @@ -139,7 +141,7 @@ void SavePageAsMHTMLFunction::ReturnFailure(const std::string& error) { Release(); // Balanced in Run() } -void SavePageAsMHTMLFunction::ReturnSuccess(int64 file_size) { +void PageCaptureSaveAsMHTMLFunction::ReturnSuccess(int64 file_size) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); TabContents* tab_contents = GetTabContents(); @@ -164,7 +166,7 @@ void SavePageAsMHTMLFunction::ReturnSuccess(int64 file_size) { // blob file from being deleted). } -TabContents* SavePageAsMHTMLFunction::GetTabContents() { +TabContents* PageCaptureSaveAsMHTMLFunction::GetTabContents() { Browser* browser = NULL; TabContentsWrapper* tab_contents_wrapper = NULL; diff --git a/chrome/browser/extensions/extension_save_page_api.h b/chrome/browser/extensions/extension_page_capture_api.h index fc7ce9a..00fde76 100644 --- a/chrome/browser/extensions/extension_save_page_api.h +++ b/chrome/browser/extensions/extension_page_capture_api.h @@ -2,8 +2,8 @@ // 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_ +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_CAPTURE_API_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_CAPTURE_API_H_ #include <string> @@ -14,9 +14,9 @@ class FilePath; -class SavePageAsMHTMLFunction : public AsyncExtensionFunction { +class PageCaptureSaveAsMHTMLFunction : public AsyncExtensionFunction { public: - SavePageAsMHTMLFunction(); + PageCaptureSaveAsMHTMLFunction(); // Test specific delegate used to test that the temporary file gets deleted. class TestDelegate { @@ -28,7 +28,7 @@ class SavePageAsMHTMLFunction : public AsyncExtensionFunction { static void SetTestDelegate(TestDelegate* delegate); private: - virtual ~SavePageAsMHTMLFunction(); + virtual ~PageCaptureSaveAsMHTMLFunction(); virtual bool RunImpl() OVERRIDE; virtual bool OnMessageReceivedFromRenderView( const IPC::Message& message) OVERRIDE; @@ -55,7 +55,7 @@ class SavePageAsMHTMLFunction : public AsyncExtensionFunction { // The file containing the MHTML. scoped_refptr<webkit_blob::DeletableFileReference> mhtml_file_; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.savePage.saveAsMHTML") + DECLARE_EXTENSION_FUNCTION_NAME("pageCapture.saveAsMHTML") }; -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SAVE_PAGE_API_H_ +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_CAPTURE_API_H_ diff --git a/chrome/browser/extensions/extension_save_page_apitest.cc b/chrome/browser/extensions/extension_page_capture_apitest.cc index b01b942..a5db063 100644 --- a/chrome/browser/extensions/extension_save_page_apitest.cc +++ b/chrome/browser/extensions/extension_page_capture_apitest.cc @@ -5,17 +5,15 @@ #include "base/base_switches.h" #include "base/command_line.h" #include "chrome/browser/extensions/extension_apitest.h" -#include "chrome/browser/extensions/extension_save_page_api.h" +#include "chrome/browser/extensions/extension_page_capture_api.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" #include "net/base/mock_host_resolver.h" -class ExtensionSavePageApiTest : public ExtensionApiTest { +class ExtensionPageCaptureApiTest : 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); command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); } @@ -30,19 +28,20 @@ class ExtensionSavePageApiTest : public ExtensionApiTest { // Disabled on Linux http://crbug.com/98194 #if defined(OS_LINUX) -#define MAYBE_SavePageAsMHTML DISABLED_SavePageAsMHTML +#define MAYBE_SaveAsMHTML DISABLED_SaveAsMHTML #else -#define MAYBE_SavePageAsMHTML SavePageAsMHTML +#define MAYBE_SaveAsMHTML SaveAsMHTML #endif // defined(OS_LINUX) -class SavePageAsMHTMLDelegate : public SavePageAsMHTMLFunction::TestDelegate { +class PageCaptureSaveAsMHTMLDelegate + : public PageCaptureSaveAsMHTMLFunction::TestDelegate { public: - SavePageAsMHTMLDelegate() { - SavePageAsMHTMLFunction::SetTestDelegate(this); + PageCaptureSaveAsMHTMLDelegate() { + PageCaptureSaveAsMHTMLFunction::SetTestDelegate(this); } - virtual ~SavePageAsMHTMLDelegate() { - SavePageAsMHTMLFunction::SetTestDelegate(NULL); + virtual ~PageCaptureSaveAsMHTMLDelegate() { + PageCaptureSaveAsMHTMLFunction::SetTestDelegate(NULL); } virtual void OnTemporaryFileCreated(const FilePath& temp_file) OVERRIDE { @@ -52,12 +51,11 @@ class SavePageAsMHTMLDelegate : public SavePageAsMHTMLFunction::TestDelegate { FilePath temp_file_; }; -IN_PROC_BROWSER_TEST_F(ExtensionSavePageApiTest, MAYBE_SavePageAsMHTML) { - SavePageAsMHTMLDelegate delegate; - ASSERT_TRUE(RunExtensionTest("save_page")) << message_; +IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, MAYBE_SaveAsMHTML) { + PageCaptureSaveAsMHTMLDelegate delegate; + ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; ASSERT_FALSE(delegate.temp_file_.empty()); // Flush the file message loop to make sure the delete happens. ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE); ASSERT_FALSE(file_util::PathExists(delegate.temp_file_)); - } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 22ec93e..2de763b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1069,6 +1069,8 @@ 'browser/extensions/extension_page_actions_module.h', 'browser/extensions/extension_page_actions_module_constants.cc', 'browser/extensions/extension_page_actions_module_constants.h', + 'browser/extensions/extension_page_capture_api.cc', + 'browser/extensions/extension_page_capture_api.h', 'browser/extensions/extension_permissions_api.cc', 'browser/extensions/extension_permissions_api.h', 'browser/extensions/extension_pref_store.cc', @@ -1098,8 +1100,6 @@ 'browser/extensions/extension_proxy_api_constants.h', 'browser/extensions/extension_proxy_api_helpers.cc', 'browser/extensions/extension_proxy_api_helpers.h', - 'browser/extensions/extension_save_page_api.cc', - 'browser/extensions/extension_save_page_api.h', 'browser/extensions/extension_service.cc', 'browser/extensions/extension_service.h', 'browser/extensions/extension_sidebar_api.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index cd9f4ed..c7a8692 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2578,11 +2578,11 @@ 'browser/extensions/extension_module_apitest.cc', 'browser/extensions/extension_omnibox_apitest.cc', 'browser/extensions/extension_override_apitest.cc', + 'browser/extensions/extension_page_capture_apitest.cc', 'browser/extensions/extension_preference_apitest.cc', 'browser/extensions/extension_processes_apitest.cc', 'browser/extensions/extension_proxy_apitest.cc', 'browser/extensions/extension_resource_request_policy_apitest.cc', - 'browser/extensions/extension_save_page_apitest.cc', 'browser/extensions/extension_sidebar_apitest.cc', 'browser/extensions/extension_startup_browsertest.cc', 'browser/extensions/extension_storage_apitest.cc', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index db981d3..6c58334 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -9078,7 +9078,7 @@ ] }, { - "namespace": "experimental.savePage", + "namespace": "pageCapture", "functions": [ { "name": "saveAsMHTML", diff --git a/chrome/common/extensions/docs/api_index.html b/chrome/common/extensions/docs/api_index.html index 1f80710..98b4e11 100644 --- a/chrome/common/extensions/docs/api_index.html +++ b/chrome/common/extensions/docs/api_index.html @@ -357,7 +357,7 @@ Here are the supported chrome.* APIs: </p> <ul> - <li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="windows.html" js="">windows</a></li> + <li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="pageCapture.html" js="">pageCapture</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="windows.html" js="">windows</a></li> </ul> <h2 id="experimental">Experimental APIs</h2> diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html index 9cd6174..ef5a4c4 100644 --- a/chrome/common/extensions/docs/experimental.html +++ b/chrome/common/extensions/docs/experimental.html @@ -385,7 +385,6 @@ on the following experimental APIs: <a href="experimental.devtools.panels.html">experimental.devtools.panels</a></li><li> <a href="experimental.infobars.html">experimental.infobars</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.speechInput.html">experimental.speechInput</a></li><li> <a href="experimental.storage.html">experimental.storage</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/pageCapture.html index 7a98ddc..8e2a7a8 100644 --- a/chrome/common/extensions/docs/experimental.savePage.html +++ b/chrome/common/extensions/docs/pageCapture.html @@ -16,7 +16,7 @@ <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> + <title>chrome.pageCapture - 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. @@ -294,7 +294,7 @@ <div class="g-unit" id="gc-pagecontent"> <div id="pageTitle"> - <h1 class="page_title">chrome.experimental.savePage</h1> + <h1 class="page_title">chrome.pageCapture</h1> </div> <!-- TABLE OF CONTENTS --> <div id="toc"> @@ -309,7 +309,7 @@ </ol> </li> <li> - <a href="#apiReference">API reference: chrome.experimental.savePage</a> + <a href="#apiReference">API reference: chrome.pageCapture</a> <ol> <li style="display: none; "> <a href="#properties">Properties</a> @@ -354,14 +354,14 @@ <!-- /TABLE OF CONTENTS --> <!-- Standard content lead-in for experimental API pages --> - <p id="classSummary"> + <p id="classSummary" style="display: none; "> 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. +The pageCapture API allows you to save a tab as MHTML. </p> <p> @@ -377,18 +377,27 @@ system and that it can only be loaded in the main frame. <h2 id="manifest">Manifest</h2> -<p> -The savePage API is currently -experimental, so you must declare the "experimental" -permission to use it. + +<p>You must declare the "pageCapture" permission +in the <a href="manifest.html">extension manifest</a> +to use the history API. +For example:</p> +<pre>{ + "name": "My extension", + ... + <b>"permissions": [ + "pageCapture" + ]</b>, + ... +}</pre> <!-- END AUTHORED CONTENT --> -</p></div> +</div> <!-- API PAGE --> <div class="apiPage"> <a name="apiReference"></a> - <h2>API reference: chrome.experimental.savePage</h2> + <h2>API reference: chrome.pageCapture</h2> <!-- PROPERTIES --> <div class="apiGroup" style="display: none; "> @@ -420,7 +429,7 @@ permission to use it. <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>object</span> + <span>chrome.pageCapture.saveAsMHTML</span>(<span class="null"><span style="display: none; ">, </span><span>object</span> <var><span>details</span></var></span><span class="null"><span>, </span><span>function</span> <var><span>callback</span></var></span>)</div> diff --git a/chrome/common/extensions/docs/samples.html b/chrome/common/extensions/docs/samples.html index 633d028..e8b86b3 100644 --- a/chrome/common/extensions/docs/samples.html +++ b/chrome/common/extensions/docs/samples.html @@ -440,6 +440,8 @@ </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.pageAction', this)">chrome.pageAction</a><span>, </span> </span><span> + <a href="javascript:void(0);" onclick="setFilter('chrome.pageCapture', this)">chrome.pageCapture</a><span>, </span> + </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.permissions', this)">chrome.permissions</a><span>, </span> </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.proxy', this)">chrome.proxy</a><span>, </span> diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json index 20dfcd1..7d13a12 100644 --- a/chrome/common/extensions/docs/samples.json +++ b/chrome/common/extensions/docs/samples.json @@ -67,7 +67,6 @@ "chrome.experimental.devtools.panels.create": "experimental.devtools.panels.html#method-create", "chrome.experimental.devtools.panels.setOpenResourceHandler": "experimental.devtools.panels.html#method-setOpenResourceHandler", "chrome.experimental.infobars.show": "experimental.infobars.html#method-show", - "chrome.experimental.savePage.saveAsMHTML": "experimental.savePage.html#method-saveAsMHTML", "chrome.experimental.speechInput.isRecording": "experimental.speechInput.html#method-isRecording", "chrome.experimental.speechInput.onError": "experimental.speechInput.html#event-onError", "chrome.experimental.speechInput.onResult": "experimental.speechInput.html#event-onResult", @@ -137,6 +136,7 @@ "chrome.pageAction.setPopup": "pageAction.html#method-setPopup", "chrome.pageAction.setTitle": "pageAction.html#method-setTitle", "chrome.pageAction.show": "pageAction.html#method-show", + "chrome.pageCapture.saveAsMHTML": "pageCapture.html#method-saveAsMHTML", "chrome.permissions.contains": "permissions.html#method-contains", "chrome.permissions.getAll": "permissions.html#method-getAll", "chrome.permissions.onAdded": "permissions.html#event-onAdded", @@ -2476,4 +2476,4 @@ "zip_path": "examples\/api\/extension\/isAllowedAccess.zip" } ] -}
\ No newline at end of file +} diff --git a/chrome/common/extensions/docs/static/experimental.savePage.html b/chrome/common/extensions/docs/static/pageCapture.html index 1db3947..5d5267d 100644 --- a/chrome/common/extensions/docs/static/experimental.savePage.html +++ b/chrome/common/extensions/docs/static/pageCapture.html @@ -1,6 +1,6 @@ <!-- BEGIN AUTHORED CONTENT --> <p> -The savePage API allows you to save a tab as MHTML. +The pageCapture API allows you to save a tab as MHTML. </p> <p> @@ -16,9 +16,18 @@ system and that it can only be loaded in the main frame. <h2 id="manifest">Manifest</h2> -<p> -The savePage API is currently -experimental, so you must declare the "experimental" -permission to use it. + +<p>You must declare the "pageCapture" permission +in the <a href="manifest.html">extension manifest</a> +to use the history API. +For example:</p> +<pre>{ + "name": "My extension", + ... + <b>"permissions": [ + "pageCapture" + ]</b>, + ... +}</pre> <!-- END AUTHORED CONTENT --> diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc index 0e36ed4..f561579 100644 --- a/chrome/common/extensions/extension_permission_set.cc +++ b/chrome/common/extensions/extension_permission_set.cc @@ -302,6 +302,10 @@ ExtensionPermissionsInfo::ExtensionPermissionsInfo() IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT, ExtensionPermissionMessage::kManagement, optional); RegisterPermission( + ExtensionAPIPermission::kPageCapture, "pageCapture", + IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT, + ExtensionPermissionMessage::kAllPageContent, none); + RegisterPermission( ExtensionAPIPermission::kTab, "tabs", IDS_EXTENSION_PROMPT_WARNING_TABS, ExtensionPermissionMessage::kTabs, optional); diff --git a/chrome/common/extensions/extension_permission_set.h b/chrome/common/extensions/extension_permission_set.h index 6e9d3b9..e427b4c 100644 --- a/chrome/common/extensions/extension_permission_set.h +++ b/chrome/common/extensions/extension_permission_set.h @@ -46,6 +46,7 @@ class ExtensionPermissionMessage { kClipboard, kTtsEngine, kContentSettings, + kAllPageContent, kEnumBoundary }; @@ -112,6 +113,7 @@ class ExtensionAPIPermission { kMediaPlayerPrivate, kMetricsPrivate, kNotification, + kPageCapture, kPlugin, kProxy, kTab, diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js index fb95edb..b16a487 100644 --- a/chrome/renderer/resources/extensions/schema_generated_bindings.js +++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js @@ -814,7 +814,7 @@ var chrome = chrome || {}; }); }; - apiFunctions["experimental.savePage.saveAsMHTML"].customCallback = + apiFunctions["pageCapture.saveAsMHTML"].customCallback = function(name, request, response) { var params = chromeHidden.JSON.parse(response); var path = params.mhtmlFilePath; diff --git a/chrome/test/data/extensions/api_test/save_page/background.html b/chrome/test/data/extensions/api_test/page_capture/background.html index 46f4d74..46f4d74 100644 --- a/chrome/test/data/extensions/api_test/save_page/background.html +++ b/chrome/test/data/extensions/api_test/page_capture/background.html diff --git a/chrome/test/data/extensions/api_test/save_page/google.html b/chrome/test/data/extensions/api_test/page_capture/google.html index 3cb0e0e..3cb0e0e 100644 --- a/chrome/test/data/extensions/api_test/save_page/google.html +++ b/chrome/test/data/extensions/api_test/page_capture/google.html diff --git a/chrome/test/data/extensions/api_test/save_page/logo.png b/chrome/test/data/extensions/api_test/page_capture/logo.png Binary files differindex 99b37d5..99b37d5 100644 --- a/chrome/test/data/extensions/api_test/save_page/logo.png +++ b/chrome/test/data/extensions/api_test/page_capture/logo.png diff --git a/chrome/test/data/extensions/api_test/page_capture/manifest.json b/chrome/test/data/extensions/api_test/page_capture/manifest.json new file mode 100644 index 0000000..7c6592f --- /dev/null +++ b/chrome/test/data/extensions/api_test/page_capture/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "chrome.extension.pageCapture", + "version": "0.1", + "description": "Tests that the pageCapture extension API work.", + "background_page": "background.html", + "permissions": ["pageCapture", "tabs"] +} diff --git a/chrome/test/data/extensions/api_test/save_page/test.js b/chrome/test/data/extensions/api_test/page_capture/test.js index b19121f..dec1342 100644 --- a/chrome/test/data/extensions/api_test/save_page/test.js +++ b/chrome/test/data/extensions/api_test/page_capture/test.js @@ -2,14 +2,14 @@ // 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 +// API test for chrome.extension.pageCapture. +// browser_tests.exe --gtest_filter=ExtensionApiTest.PageCapture 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'; + '/files/extensions/api_test/page_capture/google.html'; function waitForCurrentTabLoaded(callback) { chrome.tabs.getSelected(null, function(tab) { @@ -25,11 +25,11 @@ chrome.test.getConfig(function(config) { testUrl = testUrl.replace(/PORT/, config.testServer.port); chrome.test.runTests([ - function savePageAsMHTML() { + function saveAsMHTML() { chrome.tabs.getSelected(null, function(tab) { chrome.tabs.update(null, { "url": testUrl }); waitForCurrentTabLoaded(function() { - chrome.experimental.savePage.saveAsMHTML({ "tabId": tab.id }, + chrome.pageCapture.saveAsMHTML({ "tabId": tab.id }, function(data) { assertEq(undefined, chrome.extension.lastError); assertTrue(data != 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"] -} |