OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 BLIMP_ENGINE_SESSION_TAB_H_ | |
6 #define BLIMP_ENGINE_SESSION_TAB_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "blimp/engine/feature/engine_render_widget_feature.h" | |
10 #include "blimp/engine/session/page_load_tracker.h" | |
11 #include "content/public/browser/invalidate_type.h" | |
12 #include "content/public/browser/web_contents_observer.h" | |
13 | |
14 namespace content { | |
15 class RenderViewHost; | |
16 class WebContents; | |
17 struct FormFieldData; | |
18 } | |
19 | |
20 namespace blimp { | |
21 | |
22 class BlimpMessageProcessor; | |
23 | |
24 namespace engine { | |
25 | |
26 class EngineRenderWidgetFeature; | |
27 | |
28 // Owns WebContents, handles operations such as navigation requests in the tab, | |
29 // and has one-to-one mapping to a client tab. | |
30 class Tab : public content::WebContentsObserver, | |
31 public PageLoadTrackerClient, | |
32 public EngineRenderWidgetFeature::RenderWidgetMessageDelegate { | |
33 public: | |
34 // Caller ensures |render_widget_feature| and |navigation_message_sender| | |
35 // outlives this object. | |
36 // |web_contents|: the WebContents this tab owns. | |
37 // |tab_id|: the ID of this tab. | |
38 // |render_widget_feature|: render widget feature. | |
39 // |navigation_message_sender|: for sending navigation messages to client. | |
40 Tab(std::unique_ptr<content::WebContents> web_contents, | |
41 const int tab_id, | |
42 EngineRenderWidgetFeature* render_widget_feature, | |
43 BlimpMessageProcessor* navigation_message_sender); | |
44 ~Tab() override; | |
45 | |
46 content::WebContents* web_contents() { return web_contents_.get(); } | |
47 int tab_id() const { return tab_id_; } | |
48 | |
49 // Resizes the tab to |size_in_dips| with |device_pixel_ratio|. | |
50 void Resize(float device_pixel_ratio, const gfx::Size& size_in_dips); | |
51 | |
52 // Handles tab navigation. | |
53 void LoadUrl(const GURL& url); | |
54 void GoBack(); | |
55 void GoForward(); | |
56 void Reload(); | |
57 | |
58 // Handles navigation state changed event. | |
59 void NavigationStateChanged(content::InvalidateTypes changed_flags); | |
60 | |
61 // PageLoadTrackerClient implementation. | |
62 void SendPageLoadStatusUpdate(PageLoadStatus load_status) override; | |
63 | |
64 // RenderWidgetMessage handler methods. | |
65 // RenderWidgetMessageDelegate implementation. | |
66 void OnWebGestureEvent( | |
67 content::RenderWidgetHost* render_widget_host, | |
68 std::unique_ptr<blink::WebGestureEvent> event) override; | |
69 void OnCompositorMessageReceived( | |
70 content::RenderWidgetHost* render_widget_host, | |
71 const std::vector<uint8_t>& message) override; | |
72 | |
73 // Text input related methods. | |
74 void ShowTextInputUI(); | |
75 void HideTextInputUI(); | |
76 | |
77 private: | |
78 // content::WebContentsObserver implementation. | |
79 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | |
80 void RenderViewHostChanged(content::RenderViewHost* old_host, | |
81 content::RenderViewHost* new_host) override; | |
82 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | |
83 | |
84 // Sends text input field related information to the client. | |
85 void ProcessTextInputInfo(int request_id, | |
86 const content::FormFieldData& field_data); | |
87 | |
88 std::unique_ptr<content::WebContents> web_contents_; | |
89 const int tab_id_; | |
90 EngineRenderWidgetFeature* render_widget_feature_; | |
91 BlimpMessageProcessor* navigation_message_sender_; | |
92 | |
93 // Tracks the page load status for a tab. | |
94 PageLoadTracker page_load_tracker_; | |
95 | |
96 // Tracks the number of text input requests. | |
97 int current_form_request_id_; | |
98 | |
99 base::WeakPtrFactory<Tab> weak_factory_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(Tab); | |
102 }; | |
103 | |
104 } // namespace engine | |
105 } // namespace blimp | |
106 | |
107 #endif // BLIMP_ENGINE_SESSION_TAB_H_ | |
OLD | NEW |