Fix race condition in gyp/ninja builds.
[chromium-blink-merge.git] / android_webview / browser / renderer_host / aw_render_view_host_ext.h
blobf56d0a68f90c198d3301a82fdf74e3b2354804e7
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/size.h"
16 class GURL;
18 namespace content {
19 struct FrameNavigateParams;
20 struct LoadCommittedDetails;
21 } // namespace content
23 namespace android_webview {
25 class AwRenderViewHostExtClient {
26 public:
27 // Called when the RenderView page scale changes.
28 virtual void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) = 0;
29 virtual void OnWebLayoutContentsSizeChanged(
30 const gfx::Size& contents_size) = 0;
32 protected:
33 virtual ~AwRenderViewHostExtClient() {}
36 // Provides RenderViewHost wrapper functionality for sending WebView-specific
37 // IPC messages to the renderer and from there to WebKit.
38 class AwRenderViewHostExt : public content::WebContentsObserver,
39 public base::NonThreadSafe {
40 public:
42 // To send receive messages to a RenderView we take the WebContents instance,
43 // as it internally handles RenderViewHost instances changing underneath us.
44 AwRenderViewHostExt(
45 AwRenderViewHostExtClient* client, content::WebContents* contents);
46 virtual ~AwRenderViewHostExt();
48 // |result| will be invoked with the outcome of the request.
49 typedef base::Callback<void(bool)> DocumentHasImagesResult;
50 void DocumentHasImages(DocumentHasImagesResult result);
52 // Clear all WebCore memory cache (not only for this view).
53 void ClearCache();
55 // Do a hit test at the view port coordinates and asynchronously update
56 // |last_hit_test_data_|. |view_x| and |view_y| are in density independent
57 // pixels used by blink::WebView.
58 void RequestNewHitTestDataAt(int view_x, int view_y);
60 // Optimization to avoid unnecessary Java object creation on hit test.
61 bool HasNewHitTestData() const;
62 void MarkHitTestDataRead();
64 // Return |last_hit_test_data_|. Note that this is unavoidably racy;
65 // the corresponding public WebView API is as well.
66 const AwHitTestData& GetLastHitTestData() const;
68 // Sets the zoom factor for text only. Used in layout modes other than
69 // Text Autosizing.
70 void SetTextZoomFactor(float factor);
72 void SetFixedLayoutSize(const gfx::Size& size);
74 void ResetScrollAndScaleState();
76 // Sets the initial page scale. This overrides initial scale set by
77 // the meta viewport tag.
78 void SetInitialPageScale(double page_scale_factor);
79 void SetBackgroundColor(SkColor c);
80 void SetJsOnlineProperty(bool network_up);
82 void SendCheckRenderThreadResponsiveness();
84 private:
85 // content::WebContentsObserver implementation.
86 virtual void RenderViewCreated(content::RenderViewHost* view_host) OVERRIDE;
87 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
88 virtual void DidNavigateAnyFrame(
89 const content::LoadCommittedDetails& details,
90 const content::FrameNavigateParams& params) OVERRIDE;
91 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
93 void OnDocumentHasImagesResponse(int msg_id, bool has_images);
94 void OnUpdateHitTestData(const AwHitTestData& hit_test_data);
95 void OnPageScaleFactorChanged(float page_scale_factor);
96 void OnContentsSizeChanged(const gfx::Size& contents_size);
98 bool IsRenderViewReady() const;
100 AwRenderViewHostExtClient* client_;
102 SkColor background_color_;
104 std::map<int, DocumentHasImagesResult> pending_document_has_images_requests_;
106 // Master copy of hit test data on the browser side. This is updated
107 // as a result of DoHitTest called explicitly or when the FocusedNodeChanged
108 // is called in AwRenderViewExt.
109 AwHitTestData last_hit_test_data_;
111 bool has_new_hit_test_data_;
113 DISALLOW_COPY_AND_ASSIGN(AwRenderViewHostExt);
116 } // namespace android_webview
118 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_RENDER_VIEW_HOST_EXT_H_