summaryrefslogtreecommitdiffstats
path: root/android_webview/native
diff options
context:
space:
mode:
authorsgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 17:14:48 +0000
committersgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 17:14:48 +0000
commit041ab0a767a02383bad48aaa51fdc0a598afc34c (patch)
tree0527c081f9fc1d90fb97daaad0a0e1989c0538fc /android_webview/native
parent3858a38ebc3f1c39da1ee19bd3506992b8ff3c47 (diff)
downloadchromium_src-041ab0a767a02383bad48aaa51fdc0a598afc34c.zip
chromium_src-041ab0a767a02383bad48aaa51fdc0a598afc34c.tar.gz
chromium_src-041ab0a767a02383bad48aaa51fdc0a598afc34c.tar.bz2
Add a utility method to receive an AwContents from a render_process_id and a render_host_id. We need to do this conversion in multiple (at least two) places so having the utility method helps.
BUG= Review URL: https://chromiumcodereview.appspot.com/12207061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native')
-rw-r--r--android_webview/native/aw_contents.cc13
-rw-r--r--android_webview/native/aw_contents.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index ff8483c..a0438a31d 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -36,6 +36,7 @@
#include "content/public/browser/cert_store.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "jni/AwContents_jni.h"
@@ -161,6 +162,18 @@ AwContents* AwContents::FromWebContents(WebContents* web_contents) {
return AwContentsUserData::GetContents(web_contents);
}
+// static
+AwContents* AwContents::FromID(int render_process_id, int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ const content::RenderViewHost* rvh =
+ content::RenderViewHost::FromID(render_process_id, render_view_id);
+ if (!rvh) return NULL;
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderViewHost(rvh);
+ if (!web_contents) return NULL;
+ return FromWebContents(web_contents);
+}
+
AwContents::AwContents(JNIEnv* env,
jobject obj,
jobject web_contents_delegate)
diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h
index c2b7e49..31a921d 100644
--- a/android_webview/native/aw_contents.h
+++ b/android_webview/native/aw_contents.h
@@ -56,6 +56,10 @@ class AwContents : public FindHelper::Listener,
// Returns the AwContents instance associated with |web_contents|, or NULL.
static AwContents* FromWebContents(content::WebContents* web_contents);
+ // Returns the AwContents instance associated with with the given
+ // render_process_id and render_view_id, or NULL.
+ static AwContents* FromID(int render_process_id, int render_view_id);
+
AwContents(JNIEnv* env,
jobject obj,
jobject web_contents_delegate);