exclude PluginsFieldTrialTest.NoPrefLeftBehind from valgrind bot
[chromium-blink-merge.git] / android_webview / browser / renderer_host / aw_render_view_host_ext.h
blob3abd8d84b6b0a5c6790398b313121b6802937236
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.
5 #ifndef ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_
6 #define ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_
8 #include "content/public/browser/web_contents_observer.h"
10 #include "android_webview/common/aw_hit_test_data.h"
11 #include "base/callback_forward.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/gfx/geometry/point_f.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/geometry/size_f.h"
18 class GURL;
20 namespace content {
21 struct FrameNavigateParams;
22 struct LoadCommittedDetails;
23 } // namespace content
25 namespace android_webview {
27 class AwRenderViewHostExtClient {
28 public:
29 // Called when the RenderView page scale changes.
30 virtual void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) = 0;
31 virtual void OnWebLayoutContentsSizeChanged(
32 const gfx::Size& contents_size) = 0;
34 protected:
35 virtual ~AwRenderViewHostExtClient() {}
38 // Provides RenderViewHost wrapper functionality for sending WebView-specific
39 // IPC messages to the renderer and from there to WebKit.
40 class AwRenderViewHostExt : public content::WebContentsObserver,
41 public base::NonThreadSafe {
42 public:
44 // To send receive messages to a RenderView we take the WebContents instance,
45 // as it internally handles RenderViewHost instances changing underneath us.
46 AwRenderViewHostExt(
47 AwRenderViewHostExtClient* client, content::WebContents* contents);
48 ~AwRenderViewHostExt() override;
50 // |result| will be invoked with the outcome of the request.
51 typedef base::Callback<void(bool)> DocumentHasImagesResult;
52 void DocumentHasImages(DocumentHasImagesResult result);
54 // Clear all WebCore memory cache (not only for this view).
55 void ClearCache();
57 // Do a hit test at the view port coordinates and asynchronously update
58 // |last_hit_test_data_|. Width and height in |touch_area| are in density
59 // independent pixels used by blink::WebView.
60 void RequestNewHitTestDataAt(const gfx::PointF& touch_center,
61 const gfx::SizeF& touch_area);
63 // Optimization to avoid unnecessary Java object creation on hit test.
64 bool HasNewHitTestData() const;
65 void MarkHitTestDataRead();
67 // Return |last_hit_test_data_|. Note that this is unavoidably racy;
68 // the corresponding public WebView API is as well.
69 const AwHitTestData& GetLastHitTestData() const;
71 // Sets the zoom factor for text only. Used in layout modes other than
72 // Text Autosizing.
73 void SetTextZoomFactor(float factor);
75 void ResetScrollAndScaleState();
77 // Sets the initial page scale. This overrides initial scale set by
78 // the meta viewport tag.
79 void SetInitialPageScale(double page_scale_factor);
80 void SetBackgroundColor(SkColor c);
81 void SetJsOnlineProperty(bool network_up);
83 private:
84 // content::WebContentsObserver implementation.
85 void RenderViewCreated(content::RenderViewHost* view_host) override;
86 void RenderProcessGone(base::TerminationStatus status) override;
87 void DidNavigateAnyFrame(content::RenderFrameHost* render_frame_host,
88 const content::LoadCommittedDetails& details,
89 const content::FrameNavigateParams& params) override;
90 bool OnMessageReceived(const IPC::Message& message) override;
92 void OnDocumentHasImagesResponse(int msg_id, bool has_images);
93 void OnUpdateHitTestData(const AwHitTestData& hit_test_data);
94 void OnPageScaleFactorChanged(float page_scale_factor);
95 void OnContentsSizeChanged(const gfx::Size& contents_size);
97 bool IsRenderViewReady() const;
99 AwRenderViewHostExtClient* client_;
101 SkColor background_color_;
103 std::map<int, DocumentHasImagesResult> pending_document_has_images_requests_;
105 // Master copy of hit test data on the browser side. This is updated
106 // as a result of DoHitTest called explicitly or when the FocusedNodeChanged
107 // is called in AwRenderViewExt.
108 AwHitTestData last_hit_test_data_;
110 bool has_new_hit_test_data_;
112 DISALLOW_COPY_AND_ASSIGN(AwRenderViewHostExt);
115 } // namespace android_webview
117 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_