OLD | NEW |
| (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 CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ | |
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ | |
7 | |
8 #include "base/android/jni_helper.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "content/public/browser/native_web_keyboard_event.h" | |
11 #include "content/public/common/referrer.h" | |
12 #include "googleurl/src/gurl.h" | |
13 #include "net/base/net_errors.h" | |
14 | |
15 namespace content { | |
16 | |
17 class DownloadItem; | |
18 class JavaScriptDialogCreator; | |
19 struct NativeWebKeyboardEvent; | |
20 class RenderViewHost; | |
21 class WebContents; | |
22 | |
23 // These enums must be kept in sync with ContentViewClient.java | |
24 enum ContentViewClientError { | |
25 // Success | |
26 CONTENT_VIEW_CLIENT_ERROR_OK = 0, | |
27 // Generic error | |
28 CONTENT_VIEW_CLIENT_ERROR_UNKNOWN = -1, | |
29 // Server or proxy hostname lookup failed | |
30 CONTENT_VIEW_CLIENT_ERROR_HOST_LOOKUP = -2, | |
31 // Unsupported authentication scheme (not basic or digest) | |
32 CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME = -3, | |
33 // User authentication failed on server | |
34 CONTENT_VIEW_CLIENT_ERROR_AUTHENTICATION = -4, | |
35 // User authentication failed on proxy | |
36 CONTENT_VIEW_CLIENT_ERROR_PROXY_AUTHENTICATION = -5, | |
37 // Failed to connect to the server | |
38 CONTENT_VIEW_CLIENT_ERROR_CONNECT = -6, | |
39 // Failed to read or write to the server | |
40 CONTENT_VIEW_CLIENT_ERROR_IO = -7, | |
41 // Connection timed out | |
42 CONTENT_VIEW_CLIENT_ERROR_TIMEOUT = -8, | |
43 // Too many redirects | |
44 CONTENT_VIEW_CLIENT_ERROR_REDIRECT_LOOP = -9, | |
45 // Unsupported URI scheme | |
46 CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_SCHEME = -10, | |
47 // Failed to perform SSL handshake | |
48 CONTENT_VIEW_CLIENT_ERROR_FAILED_SSL_HANDSHAKE = -11, | |
49 // Malformed URL | |
50 CONTENT_VIEW_CLIENT_ERROR_BAD_URL = -12, | |
51 // Generic file error | |
52 CONTENT_VIEW_CLIENT_ERROR_FILE = -13, | |
53 // File not found | |
54 CONTENT_VIEW_CLIENT_ERROR_FILE_NOT_FOUND = -14, | |
55 // Too many requests during this load | |
56 CONTENT_VIEW_CLIENT_ERROR_TOO_MANY_REQUESTS = -15, | |
57 }; | |
58 | |
59 // Native mirror of ContentViewClient.java. Used as a client of | |
60 // ContentView, the main FrameLayout on Android. | |
61 // TODO(joth): Delete this C++ class, to make it Java-only. All the callbacks | |
62 // defined here originate in WebContentsObserver; we should have a dedicated | |
63 // bridge class for that rather than overloading ContentViewClient with this. | |
64 // See http://crbug.com/137967 | |
65 class ContentViewClient { | |
66 public: | |
67 ContentViewClient(JNIEnv* env, jobject obj); | |
68 ~ContentViewClient(); | |
69 | |
70 static ContentViewClient* CreateNativeContentViewClient(JNIEnv* env, | |
71 jobject obj); | |
72 | |
73 // Called by ContentView: | |
74 void OnPageStarted(const GURL& url); | |
75 void OnPageFinished(const GURL& url); | |
76 void OnLoadStarted(); | |
77 void OnLoadStopped(); | |
78 void OnReceivedError(int error_code, | |
79 const string16& description, | |
80 const GURL& url); | |
81 void OnDidCommitMainFrame(const GURL& url, | |
82 const GURL& base_url); | |
83 void OnInterstitialShown(); | |
84 void OnInterstitialHidden(); | |
85 | |
86 private: | |
87 // Get the closest ContentViewClient match to the given Chrome error code. | |
88 static ContentViewClientError ToContentViewClientError(int net_error); | |
89 | |
90 // We depend on ContentView.java to hold a ref to the client object. If we | |
91 // were to hold a hard ref from native we could end up with a cyclic | |
92 // ownership leak (the GC can't collect cycles if part of the cycle is caused | |
93 // by native). | |
94 JavaObjectWeakGlobalRef weak_java_client_; | |
95 }; | |
96 | |
97 bool RegisterContentViewClient(JNIEnv* env); | |
98 | |
99 } // namespace content | |
100 | |
101 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ | |
OLD | NEW |