| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ |
| 7 | 7 |
| 8 #include "content/public/browser/web_contents_observer.h" | 8 #include "content/public/browser/web_contents_observer.h" |
| 9 | 9 |
| 10 #include "android_webview/common/aw_hit_test_data.h" | 10 #include "android_webview/common/aw_hit_test_data.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 struct FrameNavigateParams; | 17 struct FrameNavigateParams; |
| 18 struct LoadCommittedDetails; | 18 struct LoadCommittedDetails; |
| 19 } // namespace content | 19 } // namespace content |
| 20 | 20 |
| 21 namespace android_webview { | 21 namespace android_webview { |
| 22 | 22 |
| 23 // Provides RenderViewHost wrapper functionality for sending WebView-specific | 23 // Provides RenderViewHost wrapper functionality for sending WebView-specific |
| 24 // IPC messages to the renderer and from there to WebKit. | 24 // IPC messages to the renderer and from there to WebKit. |
| 25 class AwRenderViewHostExt : public content::WebContentsObserver, | 25 class AwRenderViewHostExt : public content::WebContentsObserver, |
| 26 public base::NonThreadSafe { | 26 public base::NonThreadSafe { |
| 27 public: | 27 public: |
| 28 class Client { | |
| 29 public: | |
| 30 virtual void OnPictureUpdated(int process_id, int render_view_id) = 0; | |
| 31 | |
| 32 protected: | |
| 33 virtual ~Client() {} | |
| 34 }; | |
| 35 | |
| 36 // To send receive messages to a RenderView we take the WebContents instance, | 28 // To send receive messages to a RenderView we take the WebContents instance, |
| 37 // as it internally handles RenderViewHost instances changing underneath us. | 29 // as it internally handles RenderViewHost instances changing underneath us. |
| 38 AwRenderViewHostExt(content::WebContents* contents, Client* client); | 30 AwRenderViewHostExt(content::WebContents* contents); |
| 39 virtual ~AwRenderViewHostExt(); | 31 virtual ~AwRenderViewHostExt(); |
| 40 | 32 |
| 41 // |result| will be invoked with the outcome of the request. | 33 // |result| will be invoked with the outcome of the request. |
| 42 typedef base::Callback<void(bool)> DocumentHasImagesResult; | 34 typedef base::Callback<void(bool)> DocumentHasImagesResult; |
| 43 void DocumentHasImages(DocumentHasImagesResult result); | 35 void DocumentHasImages(DocumentHasImagesResult result); |
| 44 | 36 |
| 45 // Clear all WebCore memory cache (not only for this view). | 37 // Clear all WebCore memory cache (not only for this view). |
| 46 void ClearCache(); | 38 void ClearCache(); |
| 47 | 39 |
| 48 // Do a hit test at the view port coordinates and asynchronously update | 40 // Do a hit test at the view port coordinates and asynchronously update |
| 49 // |last_hit_test_data_|. |view_x| and |view_y| are in density independent | 41 // |last_hit_test_data_|. |view_x| and |view_y| are in density independent |
| 50 // pixels used by WebKit::WebView. | 42 // pixels used by WebKit::WebView. |
| 51 void RequestNewHitTestDataAt(int view_x, int view_y); | 43 void RequestNewHitTestDataAt(int view_x, int view_y); |
| 52 | 44 |
| 53 // Optimization to avoid unnecessary Java object creation on hit test. | 45 // Optimization to avoid unnecessary Java object creation on hit test. |
| 54 bool HasNewHitTestData() const; | 46 bool HasNewHitTestData() const; |
| 55 void MarkHitTestDataRead(); | 47 void MarkHitTestDataRead(); |
| 56 | 48 |
| 57 // Return |last_hit_test_data_|. Note that this is unavoidably racy; | 49 // Return |last_hit_test_data_|. Note that this is unavoidably racy; |
| 58 // the corresponding public WebView API is as well. | 50 // the corresponding public WebView API is as well. |
| 59 const AwHitTestData& GetLastHitTestData() const; | 51 const AwHitTestData& GetLastHitTestData() const; |
| 60 | 52 |
| 61 // Enables updating picture piles on every new frame. | |
| 62 // OnPictureUpdated is called when a new picture is available, | |
| 63 // stored by renderer id in RendererPictureMap. | |
| 64 void EnableCapturePictureCallback(bool enabled); | |
| 65 | |
| 66 // Captures the latest available picture pile synchronously. | |
| 67 void CapturePictureSync(); | |
| 68 | |
| 69 // Sets the zoom level for text only. Used in layout modes other than | 53 // Sets the zoom level for text only. Used in layout modes other than |
| 70 // Text Autosizing. | 54 // Text Autosizing. |
| 71 void SetTextZoomLevel(double level); | 55 void SetTextZoomLevel(double level); |
| 72 | 56 |
| 73 private: | 57 private: |
| 74 // content::WebContentsObserver implementation. | 58 // content::WebContentsObserver implementation. |
| 75 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 59 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 76 virtual void DidNavigateAnyFrame( | 60 virtual void DidNavigateAnyFrame( |
| 77 const content::LoadCommittedDetails& details, | 61 const content::LoadCommittedDetails& details, |
| 78 const content::FrameNavigateParams& params) OVERRIDE; | 62 const content::FrameNavigateParams& params) OVERRIDE; |
| 79 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 80 | 64 |
| 81 void OnDocumentHasImagesResponse(int msg_id, bool has_images); | 65 void OnDocumentHasImagesResponse(int msg_id, bool has_images); |
| 82 void OnUpdateHitTestData(const AwHitTestData& hit_test_data); | 66 void OnUpdateHitTestData(const AwHitTestData& hit_test_data); |
| 83 void OnPictureUpdated(); | 67 void OnPictureUpdated(); |
| 84 | 68 |
| 85 bool IsRenderViewReady() const; | 69 bool IsRenderViewReady() const; |
| 86 | 70 |
| 87 std::map<int, DocumentHasImagesResult> pending_document_has_images_requests_; | 71 std::map<int, DocumentHasImagesResult> pending_document_has_images_requests_; |
| 88 | 72 |
| 89 // Master copy of hit test data on the browser side. This is updated | 73 // Master copy of hit test data on the browser side. This is updated |
| 90 // as a result of DoHitTest called explicitly or when the FocusedNodeChanged | 74 // as a result of DoHitTest called explicitly or when the FocusedNodeChanged |
| 91 // is called in AwRenderViewExt. | 75 // is called in AwRenderViewExt. |
| 92 AwHitTestData last_hit_test_data_; | 76 AwHitTestData last_hit_test_data_; |
| 93 | 77 |
| 94 bool has_new_hit_test_data_; | 78 bool has_new_hit_test_data_; |
| 95 | 79 |
| 96 Client* client_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(AwRenderViewHostExt); | 80 DISALLOW_COPY_AND_ASSIGN(AwRenderViewHostExt); |
| 99 }; | 81 }; |
| 100 | 82 |
| 101 } // namespace android_webview | 83 } // namespace android_webview |
| 102 | 84 |
| 103 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ | 85 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_ |
| OLD | NEW |