OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ | 5 #ifndef BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ |
6 #define BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ | 6 #define BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "blimp/engine/browser/engine_render_widget_message_processor.h" |
10 #include "blimp/net/blimp_message_processor.h" | 11 #include "blimp/net/blimp_message_processor.h" |
11 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 13 #include "content/public/browser/web_contents_observer.h" |
12 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
13 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
14 | 16 |
15 namespace aura { | 17 namespace aura { |
16 class WindowTreeHost; | 18 class WindowTreeHost; |
17 | 19 |
18 namespace client { | 20 namespace client { |
19 class DefaultCaptureClient; | 21 class DefaultCaptureClient; |
20 class WindowTreeClient; | 22 class WindowTreeClient; |
21 } // namespace client | 23 } // namespace client |
22 } // namespace aura | 24 } // namespace aura |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 class BrowserContext; | 27 class BrowserContext; |
| 28 class RenderViewHost; |
26 class WebContents; | 29 class WebContents; |
27 } | 30 } |
28 | 31 |
| 32 namespace gfx { |
| 33 class Size; |
| 34 } |
| 35 |
29 namespace wm { | 36 namespace wm { |
30 class FocusController; | 37 class FocusController; |
31 } | 38 } |
32 | 39 |
33 namespace blimp { | 40 namespace blimp { |
34 | 41 |
35 class BlimpConnection; | 42 class BlimpConnection; |
36 class BlimpMessage; | 43 class BlimpMessage; |
37 | 44 |
38 namespace engine { | 45 namespace engine { |
39 | 46 |
40 class BlimpBrowserContext; | 47 class BlimpBrowserContext; |
41 class BlimpFocusClient; | 48 class BlimpFocusClient; |
42 class BlimpScreen; | 49 class BlimpScreen; |
43 class BlimpUiContextFactory; | 50 class BlimpUiContextFactory; |
44 class BlimpWindowTreeHost; | 51 class BlimpWindowTreeHost; |
45 | 52 |
46 class BlimpEngineSession : public BlimpMessageProcessor, | 53 class BlimpEngineSession |
47 public content::WebContentsDelegate { | 54 : public BlimpMessageProcessor, |
| 55 public content::WebContentsDelegate, |
| 56 public content::WebContentsObserver, |
| 57 public EngineRenderWidgetMessageProcessor::RenderWidgetMessageDelegate { |
48 public: | 58 public: |
49 explicit BlimpEngineSession(scoped_ptr<BlimpBrowserContext> browser_context); | 59 explicit BlimpEngineSession(scoped_ptr<BlimpBrowserContext> browser_context); |
50 ~BlimpEngineSession() override; | 60 ~BlimpEngineSession() override; |
51 | 61 |
52 void Initialize(); | 62 void Initialize(); |
53 | 63 |
54 BlimpBrowserContext* browser_context() { return browser_context_.get(); } | 64 BlimpBrowserContext* browser_context() { return browser_context_.get(); } |
55 | 65 |
56 // BlimpMessageProcessor implementation. | 66 // BlimpMessageProcessor implementation. |
57 // TODO(haibinlu): Delete this and move to BlimpMessageDemultiplexer. | 67 // TODO(haibinlu): Delete this and move to BlimpMessageDemultiplexer. |
58 void ProcessMessage(scoped_ptr<BlimpMessage> message, | 68 void ProcessMessage(scoped_ptr<BlimpMessage> message, |
59 const net::CompletionCallback& callback) override; | 69 const net::CompletionCallback& callback) override; |
60 | 70 |
61 private: | 71 private: |
62 // ControlMessage handler methods. | 72 // ControlMessage handler methods. |
63 // Creates a new WebContents, which will be indexed by |target_tab_id|. | 73 // Creates a new WebContents, which will be indexed by |target_tab_id|. |
64 void CreateWebContents(const int target_tab_id); | 74 void CreateWebContents(const int target_tab_id); |
65 void CloseWebContents(const int target_tab_id); | 75 void CloseWebContents(const int target_tab_id); |
| 76 void HandleResize(const gfx::Size& size); |
66 | 77 |
67 // NavigationMessage handler methods. | 78 // NavigationMessage handler methods. |
68 // Navigates the target tab to the |url|. | 79 // Navigates the target tab to the |url|. |
69 void LoadUrl(const int target_tab_id, const GURL& url); | 80 void LoadUrl(const int target_tab_id, const GURL& url); |
70 void GoBack(const int target_tab_id); | 81 void GoBack(const int target_tab_id); |
71 void GoForward(const int target_tab_id); | 82 void GoForward(const int target_tab_id); |
72 void Reload(const int target_tab_id); | 83 void Reload(const int target_tab_id); |
73 | 84 |
| 85 // RenderWidgetMessage handler methods. |
| 86 // RenderWidgetMessageDelegate implementation. |
| 87 void OnWebInputEvent(scoped_ptr<blink::WebInputEvent> event) override; |
| 88 void OnCompositorMessageReceived( |
| 89 const std::vector<uint8_t>& message) override; |
| 90 |
74 // content::WebContentsDelegate implementation. | 91 // content::WebContentsDelegate implementation. |
75 content::WebContents* OpenURLFromTab( | 92 content::WebContents* OpenURLFromTab( |
76 content::WebContents* source, | 93 content::WebContents* source, |
77 const content::OpenURLParams& params) override; | 94 const content::OpenURLParams& params) override; |
78 void AddNewContents(content::WebContents* source, | 95 void AddNewContents(content::WebContents* source, |
79 content::WebContents* new_contents, | 96 content::WebContents* new_contents, |
80 WindowOpenDisposition disposition, | 97 WindowOpenDisposition disposition, |
81 const gfx::Rect& initial_rect, | 98 const gfx::Rect& initial_rect, |
82 bool user_gesture, | 99 bool user_gesture, |
83 bool* was_blocked) override; | 100 bool* was_blocked) override; |
84 void RequestToLockMouse(content::WebContents* web_contents, | 101 void RequestToLockMouse(content::WebContents* web_contents, |
85 bool user_gesture, | 102 bool user_gesture, |
86 bool last_unlocked_by_target) override; | 103 bool last_unlocked_by_target) override; |
87 void CloseContents(content::WebContents* source) override; | 104 void CloseContents(content::WebContents* source) override; |
88 void ActivateContents(content::WebContents* contents) override; | 105 void ActivateContents(content::WebContents* contents) override; |
89 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override; | 106 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override; |
90 | 107 |
| 108 // content::WebContentsObserver implementation. |
| 109 void RenderViewHostChanged(content::RenderViewHost* old_host, |
| 110 content::RenderViewHost* new_host) override; |
| 111 |
91 // Sets up and owns |new_contents|. | 112 // Sets up and owns |new_contents|. |
92 void PlatformSetContents(scoped_ptr<content::WebContents> new_contents); | 113 void PlatformSetContents(scoped_ptr<content::WebContents> new_contents); |
93 | 114 |
94 scoped_ptr<BlimpBrowserContext> browser_context_; | 115 scoped_ptr<BlimpBrowserContext> browser_context_; |
95 scoped_ptr<BlimpScreen> screen_; | 116 scoped_ptr<BlimpScreen> screen_; |
96 | 117 |
97 // Context factory for compositor. | 118 // Context factory for compositor. |
98 scoped_ptr<BlimpUiContextFactory> context_factory_; | 119 scoped_ptr<BlimpUiContextFactory> context_factory_; |
99 | 120 |
100 // Represents the (currently single) browser window into which tab(s) will | 121 // Represents the (currently single) browser window into which tab(s) will |
101 // be rendered. | 122 // be rendered. |
102 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 123 scoped_ptr<aura::WindowTreeHost> window_tree_host_; |
103 | 124 |
104 // Used to apply standard focus conventions to the windows in the | 125 // Used to apply standard focus conventions to the windows in the |
105 // WindowTreeHost hierarchy. | 126 // WindowTreeHost hierarchy. |
106 scoped_ptr<wm::FocusController> focus_client_; | 127 scoped_ptr<wm::FocusController> focus_client_; |
107 | 128 |
108 // Used to manage input capture. | 129 // Used to manage input capture. |
109 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 130 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
110 | 131 |
111 // Only one web_contents is supported for blimp 0.5 | 132 // Only one web_contents is supported for blimp 0.5 |
112 scoped_ptr<content::WebContents> web_contents_; | 133 scoped_ptr<content::WebContents> web_contents_; |
113 | 134 |
114 // Currently attached client connection. | 135 // Currently attached client connection. |
115 scoped_ptr<BlimpConnection> client_connection_; | 136 scoped_ptr<BlimpConnection> client_connection_; |
116 | 137 |
| 138 // The bridge to the network layer that does the RenderWidget proto/id work. |
| 139 // TODO(dtrainor, haibinlu): Move this to a higher level once we start dealing |
| 140 // with multiple tabs. |
| 141 EngineRenderWidgetMessageProcessor render_widget_processor_; |
| 142 |
117 DISALLOW_COPY_AND_ASSIGN(BlimpEngineSession); | 143 DISALLOW_COPY_AND_ASSIGN(BlimpEngineSession); |
118 }; | 144 }; |
119 | 145 |
120 } // namespace engine | 146 } // namespace engine |
121 } // namespace blimp | 147 } // namespace blimp |
122 | 148 |
123 #endif // BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ | 149 #endif // BLIMP_ENGINE_BROWSER_BLIMP_ENGINE_SESSION_H_ |
OLD | NEW |