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

Side by Side Diff: chrome/browser/android/content_view_delegate.h

Issue 10702083: Add ContentViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: it builds (but other code in chrome/ doesn't...) Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_CONTENT_VIEW_DELEGATE_H_
6 #define CHROME_BROWSER_ANDROID_CONTENT_VIEW_DELEGATE_H_
7 #pragma once
8
9 #include "base/android/scoped_java_ref.h"
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12
13 class GURL;
14
15 namespace content {
16 class RenderViewHost;
17 struct Referrer;
18 class WebContents;
19 }
20
21 namespace net {
22 class URLRequest;
23 }
24
25 // This provides a way of accessing select methods of the Chrome on Android
26 // Java-side WebContents embedder from the chrome/ layer.
27 //
28 // It is preferable to use the static getter methods to obtain a new instance
29 // of the class rather than holding on to one for prolonged periods of time
30 // (see note fore more details).
31 //
32 // This class also provides a RenderViewHost->ContentViewDelegate mapping.
33 // The mapping should normally be used on the UI thread only with one
34 // exception: the ShouldInterceptRequest method, which should be called on the
35 // IO thread.
36 //
37 // Note: The native ContentViewDelegate instance has a Global ref to the Java
38 // object. By keeping the native ContentViewDelegate instance alive you're also
39 // prolonging the lifetime of the Java instance, so don't keep a
40 // ContentViewDelegate if you don't need to.
41 // It is also possible that ContentViewDelegate becomes invalid when you're
42 // holding on to it. This could happen if the WebContents is destroyed. In that
43 // case the instance methods will noop/return default values.
44 class ContentViewDelegate {
Yaron 2012/07/10 06:34:55 Is this pulling out functionality from ContentView
45 public:
46 // This will attempt to fetch the ContentViewDelegate for the given |rvh|.
47 // This method can be called from any thread.
48 // An empty scoped_ptr is a valid return value.
49 static scoped_ptr<ContentViewDelegate>
50 ForRenderViewHost(content::RenderViewHost* rvh);
51 // This will attempt to fetch the ContentViewDelegate for the given
52 // This method can be called from any thread.
53 // |contents|. An empty scoped_ptr is a valid return value.
54 static scoped_ptr<ContentViewDelegate>
55 ForWebContents(content::WebContents* contents);
56
57 static bool RegisterContentViewDelegate(JNIEnv* env);
58
59 // Called for top-level navigations to decide whether the navigation should
60 // be allowed to proceed.
61 // This method is called on the UI thread only.
62 bool ShouldIgnoreNavigation(
63 content::RenderViewHost* source,
64 const GURL& validated_url,
65 const content::Referrer& referrer,
66 bool is_content_initiated);
67
68 // TODO(mkosiba): Stub, implement.
69 // This method is called on the IO thread only.
70 bool ShouldInterceptRequest(const net::URLRequest* request);
71
72 ~ContentViewDelegate();
73
74 class WebContentsObserver;
75 private:
76 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate);
77
78 ContentViewDelegate(JNIEnv* env, jobject obj);
79 void OnWebContentsDestroyed();
80
81 base::android::ScopedJavaGlobalRef<jobject> java_object_;
82 };
83
84 #endif // CHROME_BROWSER_ANDROID_CONTENT_VIEW_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698