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

Side by Side Diff: content/browser/android/content_view_client.h

Issue 10536066: android content shell bringup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more jam feedback Created 8 years, 6 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) 2010 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 CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
7 #pragma once
8
9 #include "base/android/jni_helper.h"
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/native_web_keyboard_event.h"
12 #include "content/public/browser/web_contents_delegate.h"
13 #include "content/public/common/javascript_message_type.h"
14 #include "content/public/common/referrer.h"
15 #include "googleurl/src/gurl.h"
16 #include "net/base/net_errors.h"
17
18 class FindHelper;
19
20 namespace content {
21 class DownloadItem;
22 struct FindMatchRect;
23 class JavaScriptDialogCreator;
24 class NativeWebKeyboardEvent;
25 class RenderViewHost;
26 class WebContents;
27 }
28
29 // This enum must be kept in sync with ContentViewClient.java
30 enum ContentViewClientError {
jam 2012/06/14 01:31:41 why is this not in the content namespace?
31 // Success
32 CONTENT_VIEW_CLIENT_ERROR_OK = 0,
33 // Generic error
34 CONTENT_VIEW_CLIENT_ERROR_UNKNOWN = -1,
35 // Server or proxy hostname lookup failed
36 CONTENT_VIEW_CLIENT_ERROR_HOST_LOOKUP = -2,
37 // Unsupported authentication scheme (not basic or digest)
38 CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME = -3,
39 // User authentication failed on server
40 CONTENT_VIEW_CLIENT_ERROR_AUTHENTICATION = -4,
41 // User authentication failed on proxy
42 CONTENT_VIEW_CLIENT_ERROR_PROXY_AUTHENTICATION = -5,
43 // Failed to connect to the server
44 CONTENT_VIEW_CLIENT_ERROR_CONNECT = -6,
45 // Failed to read or write to the server
46 CONTENT_VIEW_CLIENT_ERROR_IO = -7,
47 // Connection timed out
48 CONTENT_VIEW_CLIENT_ERROR_TIMEOUT = -8,
49 // Too many redirects
50 CONTENT_VIEW_CLIENT_ERROR_REDIRECT_LOOP = -9,
51 // Unsupported URI scheme
52 CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_SCHEME = -10,
53 // Failed to perform SSL handshake
54 CONTENT_VIEW_CLIENT_ERROR_FAILED_SSL_HANDSHAKE = -11,
55 // Malformed URL
56 CONTENT_VIEW_CLIENT_ERROR_BAD_URL = -12,
57 // Generic file error
58 CONTENT_VIEW_CLIENT_ERROR_FILE = -13,
59 // File not found
60 CONTENT_VIEW_CLIENT_ERROR_FILE_NOT_FOUND = -14,
61 // Too many requests during this load
62 CONTENT_VIEW_CLIENT_ERROR_TOO_MANY_REQUESTS = -15,
63 };
64
65 namespace content {
66
67 // Native mirror of ContentViewClient.java. Uses as a client of
68 // ContentView, the main FrameLayout on Android.
69 class ContentViewClient : public content::WebContentsDelegate {
jam 2012/06/14 01:31:41 nit: in this whole class, get rid of "content::" n
70 public:
71 ContentViewClient(JNIEnv* env, jobject obj);
72
73 static ContentViewClient* CreateNativeContentViewClient(JNIEnv* env,
74 jobject obj);
75
76 // Called by ContentView:
77 void OnInternalPageLoadRequest(content::WebContents* source,
78 const GURL& url);
79 void OnPageStarted(const GURL& url);
80 void OnPageFinished(const GURL& url);
81 void OnLoadStarted();
82 void OnLoadStopped();
83 void OnReceivedError(int error_code,
84 const string16& description,
85 const GURL& url);
86 void OnReceivedHttpAuthRequest(jobject auth_handler,
87 const string16& host,
88 const string16& realm);
89 void OnDidCommitMainFrame(const GURL& url,
90 const GURL& base_url);
91 void OnInterstitialShown();
92 void OnInterstitialHidden();
93
94 void SetFindHelper(FindHelper* find_helper);
95 void SetJavaScriptDialogCreator(
96 content::JavaScriptDialogCreator* javascript_dialog_creator);
97
98 bool OnJSModalDialog(content::JavaScriptMessageType type,
99 bool is_before_unload_dialog,
100 const GURL& url,
101 const string16& message,
102 const string16& default_value);
103
104 // Overridden from WebContentsDelegate:
105 virtual content::WebContents* OpenURLFromTab(
106 content::WebContents* source,
107 const content::OpenURLParams& params) OVERRIDE;
108 virtual bool ShouldIgnoreNavigation(
109 content::WebContents* source,
110 const GURL& url,
111 const content::Referrer& referrer,
112 WindowOpenDisposition disposition,
113 content::PageTransition transition_type) OVERRIDE;
114 virtual void NavigationStateChanged(const content::WebContents* source,
115 unsigned changed_flags) OVERRIDE;
116 virtual void AddNewContents(content::WebContents* source,
117 content::WebContents* new_contents,
118 WindowOpenDisposition disposition,
119 const gfx::Rect& initial_pos,
120 bool user_gesture) OVERRIDE;
121 virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
122 virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
123 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
124 virtual void LoadProgressChanged(double load_progress) OVERRIDE;
125 virtual void CloseContents(content::WebContents* source) OVERRIDE;
126 virtual void MoveContents(content::WebContents* source,
127 const gfx::Rect& pos) OVERRIDE;
128 // TODO(merge): WARNING! method no longer available on the base class.
129 // See http://b/issue?id=5862108
130 virtual void URLStarredChanged(content::WebContents* source, bool starred);
131 virtual void UpdateTargetURL(content::WebContents* source,
132 int32 page_id,
133 const GURL& url) OVERRIDE;
134 virtual bool CanDownload(content::RenderViewHost* source,
135 int request_id,
136 const std::string& request_method) OVERRIDE;
137 virtual void OnStartDownload(content::WebContents* source,
138 content::DownloadItem* download) OVERRIDE;
139 virtual void FindReply(content::WebContents* tab,
140 int request_id,
141 int number_of_matches,
142 const gfx::Rect& selection_rect,
143 int active_match_ordinal,
144 bool final_update) OVERRIDE;
145 virtual void OnReceiveFindMatchRects(int version,
146 const std::vector<FindMatchRect>& rects,
147 const FindMatchRect& active_rect) OVERRIDE;
148 virtual bool ShouldOverrideLoading(const GURL& url) OVERRIDE;
149 virtual void HandleKeyboardEvent(
150 const NativeWebKeyboardEvent& event) OVERRIDE;
151 virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() OVERRID E;
152 virtual void RunFileChooser(
153 content::WebContents* tab,
154 const content::FileChooserParams& params) OVERRIDE;
155 virtual bool TakeFocus(bool reverse) OVERRIDE;
156
157 virtual ~ContentViewClient();
158
159 private:
160 // Get the closest ContentViewClient match to the given Chrome error code.
161 static ContentViewClientError ToContentViewClientError(int net_error);
162
163 // We use this to keep track of whether the navigation we get in
164 // ShouldIgnoreNavigation has been initiated by the ContentView or not. We
165 // need the GURL, because the active navigation entry doesn't change on
166 // redirects.
167 GURL last_requested_navigation_url_;
168
169 // We depend on ContentView.java to hold a ref to the client object. If we
170 // were to hold a hard ref from native we could end up with a cyclic
171 // ownership leak (the GC can't collect cycles if part of the cycle is caused
172 // by native).
173 JavaObjectWeakGlobalRef weak_java_client_;
174
175 // Used to process find replies. Owned by the ContentView. The ContentView
176 // NULLs this pointer when the FindHelper goes away.
177 FindHelper* find_helper_;
178
179 // The object responsible for creating JavaScript dialogs.
180 content::JavaScriptDialogCreator* javascript_dialog_creator_;
181 };
182
183 bool RegisterContentViewClient(JNIEnv* env);
184
185 } // namespace content
186
187 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698