 Chromium Code Reviews
 Chromium Code Reviews Issue 10536066:
  android content shell bringup.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 10536066:
  android content shell bringup.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: content/browser/android/content_view_client.h | 
| diff --git a/content/browser/android/content_view_client.h b/content/browser/android/content_view_client.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..13c5c4a6f94cc3caed2f33b1b2b10b7fedff60bd | 
| --- /dev/null | 
| +++ b/content/browser/android/content_view_client.h | 
| @@ -0,0 +1,202 @@ | 
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ | 
| +#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ | 
| +#pragma once | 
| + | 
| +#include "base/android/jni_helper.h" | 
| +#include "base/compiler_specific.h" | 
| +#include "content/public/browser/native_web_keyboard_event.h" | 
| +#include "content/public/browser/web_contents_delegate.h" | 
| +#include "content/public/common/javascript_message_type.h" | 
| +#include "content/public/common/referrer.h" | 
| +#include "googleurl/src/gurl.h" | 
| +#include "net/base/net_errors.h" | 
| + | 
| +struct FindMatchRect; | 
| +class FindHelper; | 
| + | 
| +namespace content { | 
| +class DownloadItem; | 
| +class JavaScriptDialogCreator; | 
| +class RenderViewHost; | 
| +class WebContents; | 
| +} | 
| + | 
| +using content::NativeWebKeyboardEvent; | 
| 
jam
2012/06/08 23:45:09
nit: using statements aren't allowed in headers pe
 | 
| + | 
| +// This enum must be kept in sync with ContentViewClient.java | 
| +enum ContentViewClientError { | 
| + // Success | 
| 
jam
2012/06/08 23:45:09
nit: two space invent
 | 
| + ERROR_OK = 0, | 
| 
jam
2012/06/08 23:45:09
nit: the convention we try to follow in content is
 | 
| + // Generic error | 
| + ERROR_UNKNOWN = -1, | 
| + // Server or proxy hostname lookup failed | 
| + ERROR_HOST_LOOKUP = -2, | 
| + // Unsupported authentication scheme (not basic or digest) | 
| + ERROR_UNSUPPORTED_AUTH_SCHEME = -3, | 
| + // User authentication failed on server | 
| + ERROR_AUTHENTICATION = -4, | 
| + // User authentication failed on proxy | 
| + ERROR_PROXY_AUTHENTICATION = -5, | 
| + // Failed to connect to the server | 
| + ERROR_CONNECT = -6, | 
| + // Failed to read or write to the server | 
| + ERROR_IO = -7, | 
| + // Connection timed out | 
| + ERROR_TIMEOUT = -8, | 
| + // Too many redirects | 
| + ERROR_REDIRECT_LOOP = -9, | 
| + // Unsupported URI scheme | 
| + ERROR_UNSUPPORTED_SCHEME = -10, | 
| + // Failed to perform SSL handshake | 
| + ERROR_FAILED_SSL_HANDSHAKE = -11, | 
| + // Malformed URL | 
| + ERROR_BAD_URL = -12, | 
| + // Generic file error | 
| + ERROR_FILE = -13, | 
| + // File not found | 
| + ERROR_FILE_NOT_FOUND = -14, | 
| + // Too many requests during this load | 
| + ERROR_TOO_MANY_REQUESTS = -15, | 
| +}; | 
| + | 
| +// Native mirror of ContentViewClient.java. Uses as a client of | 
| +// ContentView, the main FrameLayout on Android. | 
| +class ContentViewClient : public content::WebContentsDelegate { | 
| 
jam
2012/06/08 23:45:09
nit: new code in content should be in the content
 | 
| + public: | 
| + ContentViewClient(JNIEnv* env, jobject obj); | 
| + | 
| + static ContentViewClient* CreateNativeContentViewClient(JNIEnv* env, | 
| + jobject obj); | 
| + | 
| + // Called by ContentView: | 
| + void OnInternalPageLoadRequest(content::WebContents* source, | 
| + const GURL& url); | 
| + void OnPageStarted(const GURL& url); | 
| + void OnPageFinished(const GURL& url); | 
| + void OnLoadStarted(); | 
| + void OnLoadStopped(); | 
| + void OnReceivedError(int error_code, | 
| + const string16& description, | 
| + const GURL& url); | 
| + void OnReceivedHttpAuthRequest(jobject auth_handler, | 
| + const string16& host, | 
| + const string16& realm); | 
| + void OnDidCommitMainFrame(const GURL& url, | 
| + const GURL& base_url); | 
| + void OnInterstitialShown(); | 
| + void OnInterstitialHidden(); | 
| + | 
| + void SetFindHelper(FindHelper* find_helper); | 
| + void SetJavaScriptDialogCreator( | 
| + content::JavaScriptDialogCreator* javascript_dialog_creator); | 
| + | 
| + bool OnJSModalDialog(content::JavaScriptMessageType type, | 
| + bool is_before_unload_dialog, | 
| + const GURL& url, | 
| + const string16& message, | 
| + const string16& default_value); | 
| + | 
| + // Overridden from WebContentsDelegate: | 
| + virtual content::WebContents* OpenURLFromTab( | 
| + content::WebContents* source, | 
| + const content::OpenURLParams& params) OVERRIDE; | 
| + | 
| 
jam
2012/06/08 23:45:09
nit: convention is to not have any blank lines bet
 | 
| + virtual bool ShouldIgnoreNavigation( | 
| + content::WebContents* source, | 
| + const GURL& url, | 
| + const content::Referrer& referrer, | 
| + WindowOpenDisposition disposition, | 
| + content::PageTransition transition_type) OVERRIDE; | 
| + | 
| + virtual void NavigationStateChanged(const content::WebContents* source, | 
| + unsigned changed_flags) OVERRIDE; | 
| + | 
| + virtual void AddNewContents(content::WebContents* source, | 
| + content::WebContents* new_contents, | 
| + WindowOpenDisposition disposition, | 
| + const gfx::Rect& initial_pos, | 
| + bool user_gesture) OVERRIDE; | 
| + | 
| + virtual void ActivateContents(content::WebContents* contents) OVERRIDE; | 
| + | 
| + virtual void DeactivateContents(content::WebContents* contents) OVERRIDE; | 
| + | 
| + virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; | 
| + | 
| + virtual void LoadProgressChanged(double load_progress) OVERRIDE; | 
| + | 
| + virtual void CloseContents(content::WebContents* source) OVERRIDE; | 
| + | 
| + virtual void MoveContents(content::WebContents* source, | 
| + const gfx::Rect& pos) OVERRIDE; | 
| + | 
| + // TODO(merge): WARNING! method no longer available on the base class. | 
| + // See http://b/issue?id=5862108 | 
| + virtual void URLStarredChanged(content::WebContents* source, bool starred); | 
| + | 
| + virtual void UpdateTargetURL(content::WebContents* source, | 
| + int32 page_id, | 
| + const GURL& url) OVERRIDE; | 
| + | 
| + virtual bool CanDownload(content::RenderViewHost* source, | 
| + int request_id, | 
| + const std::string& request_method) OVERRIDE; | 
| + | 
| + virtual void OnStartDownload(content::WebContents* source, | 
| + content::DownloadItem* download) OVERRIDE; | 
| + | 
| + virtual void FindReply(content::WebContents* tab, | 
| + int request_id, | 
| + int number_of_matches, | 
| + const gfx::Rect& selection_rect, | 
| + int active_match_ordinal, | 
| + bool final_update) OVERRIDE; | 
| + | 
| + virtual void OnReceiveFindMatchRects(int version, | 
| + const std::vector<FindMatchRect>& rects, | 
| + const FindMatchRect& active_rect) OVERRIDE; | 
| 
jam
2012/06/08 23:45:09
nit: here and below, 80 char limit. convention whe
 | 
| + | 
| + virtual bool ShouldOverrideLoading(const GURL& url) OVERRIDE; | 
| + | 
| + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) OVERRIDE; | 
| + | 
| + virtual content::JavaScriptDialogCreator* GetJavaScriptDialogCreator() OVERRIDE; | 
| + | 
| + virtual void RunFileChooser(content::WebContents* tab, | 
| + const content::FileChooserParams& params) OVERRIDE; | 
| + | 
| + virtual bool TakeFocus(bool reverse) OVERRIDE; | 
| + | 
| + virtual ~ContentViewClient(); | 
| + | 
| + private: | 
| + // Get the closest ContentViewClient match to the given Chrome error code. | 
| + static ContentViewClientError ToContentViewClientError(int netError); | 
| 
jam
2012/06/08 23:45:09
nit: style guide is net_error
 | 
| + | 
| + // We use this to keep track of whether the navigation we get in | 
| + // ShouldIgnoreNavigation has been initiated by the ContentView or not. We | 
| + // need the GURL, because the active navigation entry doesn't change on | 
| + // redirects. | 
| + GURL last_requested_navigation_url_; | 
| + | 
| + // We depend on ContentView.java to hold a ref to the client object. If we | 
| + // were to hold a hard ref from native we could end up with a cyclic | 
| + // ownership leak (the GC can't collect cycles if part of the cycle is caused | 
| + // by native). | 
| + JavaObjectWeakGlobalRef weak_java_client_; | 
| + | 
| + // Used to process find replies. Owned by the ContentView. The ContentView | 
| + // NULLs this pointer when the FindHelper goes away. | 
| + FindHelper* find_helper_; | 
| + | 
| + // The object responsible for creating JavaScript dialogs. | 
| + content::JavaScriptDialogCreator* javascript_dialog_creator_; | 
| +}; | 
| + | 
| +bool RegisterContentViewClient(JNIEnv* env); | 
| + | 
| +#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_ |