From 44703cc73a24cc39b3e5e832f447d8261701fa4c Mon Sep 17 00:00:00 2001 From: "fsamuel@chromium.org" Date: Thu, 24 Jan 2013 04:56:06 +0000 Subject: : Implement ExecuteScript This patch implements executeScript for by using extensions bindings for forwarding requests to the browser process from the app process. The shim passes the ProcessId and the RouteID of the guest process to the ExecuteScriptFunction object in the browser process. From there, ExecuteScriptFunction grabs the guest web contents, and creates a ScriptExecutor object attached to the guest WebContents. The callback is supported trivially through the extension bindings. When a new guest web contents is created, we inject the Chrome App's extension information into the guest process, so that executeScript knows to bypass permission requests when attempting to execute script within the guest (as suggested by mpcomplete@). BUG=153530 Test=WebViewTest.Shim, webViewExecuteScript Review URL: https://codereview.chromium.org/11968054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178520 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/extensions/api/webview/webview_api.h | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 chrome/browser/extensions/api/webview/webview_api.h (limited to 'chrome/browser/extensions/api/webview/webview_api.h') diff --git a/chrome/browser/extensions/api/webview/webview_api.h b/chrome/browser/extensions/api/webview/webview_api.h new file mode 100644 index 0000000..794232f --- /dev/null +++ b/chrome/browser/extensions/api/webview/webview_api.h @@ -0,0 +1,31 @@ +// Copyright (c) 2013 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_API_WEBVIEW_WEBVIEW_API_H_ +#define CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEBVIEW_API_H_ + +#include "chrome/browser/extensions/extension_function.h" +#include "chrome/browser/extensions/script_executor.h" + +class WebviewExecuteScriptFunction : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webview.executeScript", WEBVIEW_EXECUTESCRIPT) + + WebviewExecuteScriptFunction(); + + protected: + virtual ~WebviewExecuteScriptFunction(); + + // ExtensionFunction implementation. + virtual bool RunImpl() OVERRIDE; + + private: + + void OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const ListValue& result); + +}; +#endif // CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEBVIEW_API_H_ -- cgit v1.1