Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Unified Diff: chrome/browser/extensions/api/webview/webview_api.cc

Issue 24243007: Allow webview API in an unblessed extension process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed style error Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/webview/webview_api.cc
diff --git a/chrome/browser/extensions/api/webview/webview_api.cc b/chrome/browser/extensions/api/webview/webview_api.cc
index d7a402dda9f46e4241e4e957a08fae3539565568..14e98a870553e7f02c1db82f7fcb3f3fbe74d10a 100644
--- a/chrome/browser/extensions/api/webview/webview_api.cc
+++ b/chrome/browser/extensions/api/webview/webview_api.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
#include "chrome/browser/extensions/tab_helper.h"
-#include "chrome/browser/guestview/webview/webview_guest.h"
#include "chrome/common/extensions/api/webview.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -39,6 +38,17 @@ int MaskForKey(const char* key) {
} // namespace
+bool WebviewExtensionFunction::RunImpl() {
+ int instance_id = 0;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id));
+ WebViewGuest* guest = WebViewGuest::From(
+ render_view_host()->GetProcess()->GetID(), instance_id);
+ if (!guest)
+ return false;
+
+ return RunImplSafe(guest);
+}
+
WebviewClearDataFunction::WebviewClearDataFunction()
: remove_mask_(0),
bad_message_(false) {
@@ -75,10 +85,8 @@ uint32 WebviewClearDataFunction::GetRemovalMask() {
// TODO(lazyboy): Parameters in this extension function are similar (or a
// sub-set) to BrowsingDataRemoverFunction. How can we share this code?
-bool WebviewClearDataFunction::RunImpl() {
+bool WebviewClearDataFunction::RunImplSafe(WebViewGuest* guest) {
content::RecordAction(content::UserMetricsAction("WebView.ClearData"));
- int instance_id = 0;
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id));
// Grab the initial |options| parameter, and parse out the arguments.
base::DictionaryValue* options;
@@ -104,11 +112,6 @@ bool WebviewClearDataFunction::RunImpl() {
if (bad_message_)
return false;
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), instance_id);
- if (!guest)
- return false;
-
AddRef(); // Balanced below or in WebviewClearDataFunction::Done().
bool scheduled = false;
@@ -211,16 +214,11 @@ WebviewGoFunction::WebviewGoFunction() {
WebviewGoFunction::~WebviewGoFunction() {
}
-bool WebviewGoFunction::RunImpl() {
+bool WebviewGoFunction::RunImplSafe(WebViewGuest* guest) {
content::RecordAction(content::UserMetricsAction("WebView.Go"));
scoped_ptr<webview::Go::Params> params(webview::Go::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), params->instance_id);
- if (!guest)
- return false;
-
guest->Go(params->relative_index);
return true;
}
@@ -231,17 +229,12 @@ WebviewReloadFunction::WebviewReloadFunction() {
WebviewReloadFunction::~WebviewReloadFunction() {
}
-bool WebviewReloadFunction::RunImpl() {
+bool WebviewReloadFunction::RunImplSafe(WebViewGuest* guest) {
content::RecordAction(content::UserMetricsAction("WebView.Reload"));
scoped_ptr<webview::Reload::Params> params(
webview::Reload::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), params->instance_id);
- if (!guest)
- return false;
-
guest->Reload();
return true;
}
@@ -252,16 +245,11 @@ WebviewSetPermissionFunction::WebviewSetPermissionFunction() {
WebviewSetPermissionFunction::~WebviewSetPermissionFunction() {
}
-bool WebviewSetPermissionFunction::RunImpl() {
+bool WebviewSetPermissionFunction::RunImplSafe(WebViewGuest* guest) {
scoped_ptr<webview::SetPermission::Params> params(
webview::SetPermission::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), params->instance_id);
- if (!guest)
- return false;
-
EXTENSION_FUNCTION_VALIDATE(
guest->SetPermission(params->request_id,
params->should_allow,
@@ -297,17 +285,12 @@ WebviewStopFunction::WebviewStopFunction() {
WebviewStopFunction::~WebviewStopFunction() {
}
-bool WebviewStopFunction::RunImpl() {
+bool WebviewStopFunction::RunImplSafe(WebViewGuest* guest) {
content::RecordAction(content::UserMetricsAction("WebView.Stop"));
scoped_ptr<webview::Stop::Params> params(
webview::Stop::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), params->instance_id);
- if (!guest)
- return false;
-
guest->Stop();
return true;
}
@@ -318,17 +301,12 @@ WebviewTerminateFunction::WebviewTerminateFunction() {
WebviewTerminateFunction::~WebviewTerminateFunction() {
}
-bool WebviewTerminateFunction::RunImpl() {
+bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) {
content::RecordAction(content::UserMetricsAction("WebView.Terminate"));
scoped_ptr<webview::Terminate::Params> params(
webview::Terminate::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- WebViewGuest* guest = WebViewGuest::From(
- render_view_host()->GetProcess()->GetID(), params->instance_id);
- if (!guest)
- return false;
-
guest->Terminate();
return true;
}
« no previous file with comments | « chrome/browser/extensions/api/webview/webview_api.h ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698