Chromium Code Reviews| 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_SESSION_BLIMP_ENGINE_SESSION_H_ | 5 #ifndef BLIMP_ENGINE_SESSION_BLIMP_ENGINE_SESSION_H_ |
| 6 #define BLIMP_ENGINE_SESSION_BLIMP_ENGINE_SESSION_H_ | 6 #define BLIMP_ENGINE_SESSION_BLIMP_ENGINE_SESSION_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "blimp/common/proto/blimp_message.pb.h" | 14 #include "blimp/common/proto/blimp_message.pb.h" |
| 15 #include "blimp/engine/feature/engine_render_widget_feature.h" | 15 #include "blimp/engine/feature/engine_render_widget_feature.h" |
| 16 #include "blimp/engine/feature/engine_settings_feature.h" | 16 #include "blimp/engine/feature/engine_settings_feature.h" |
| 17 #include "blimp/engine/session/page_load_tracker.h" | |
| 18 #include "blimp/net/blimp_message_processor.h" | 17 #include "blimp/net/blimp_message_processor.h" |
| 19 #include "blimp/net/connection_error_observer.h" | 18 #include "blimp/net/connection_error_observer.h" |
| 20 #include "content/public/browser/invalidate_type.h" | 19 #include "content/public/browser/invalidate_type.h" |
| 21 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | |
| 23 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 24 #include "ui/base/ime/input_method_observer.h" | 22 #include "ui/base/ime/input_method_observer.h" |
| 25 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
| 26 | 24 |
| 27 namespace aura { | 25 namespace aura { |
| 28 class WindowTreeHost; | 26 class WindowTreeHost; |
| 29 | 27 |
| 30 namespace client { | 28 namespace client { |
| 31 class DefaultCaptureClient; | 29 class DefaultCaptureClient; |
| 32 class WindowTreeClient; | 30 class WindowTreeClient; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 60 class SettingsManager; | 58 class SettingsManager; |
| 61 | 59 |
| 62 namespace engine { | 60 namespace engine { |
| 63 | 61 |
| 64 class BlimpBrowserContext; | 62 class BlimpBrowserContext; |
| 65 class BlimpEngineConfig; | 63 class BlimpEngineConfig; |
| 66 class BlimpFocusClient; | 64 class BlimpFocusClient; |
| 67 class BlimpScreen; | 65 class BlimpScreen; |
| 68 class BlimpWindowTreeHost; | 66 class BlimpWindowTreeHost; |
| 69 class EngineNetworkComponents; | 67 class EngineNetworkComponents; |
| 68 class TabBlimp; | |
| 70 | 69 |
| 71 class BlimpEngineSession | 70 class BlimpEngineSession |
| 72 : public BlimpMessageProcessor, | 71 : public BlimpMessageProcessor, |
| 73 public content::WebContentsDelegate, | 72 public content::WebContentsDelegate, |
| 74 public content::WebContentsObserver, | |
| 75 public ui::InputMethodObserver, | 73 public ui::InputMethodObserver, |
| 76 public EngineRenderWidgetFeature::RenderWidgetMessageDelegate, | 74 public EngineRenderWidgetFeature::RenderWidgetMessageDelegate { |
| 77 public PageLoadTrackerClient { | |
| 78 public: | 75 public: |
| 79 using GetPortCallback = base::Callback<void(uint16_t)>; | 76 using GetPortCallback = base::Callback<void(uint16_t)>; |
| 80 | 77 |
| 81 BlimpEngineSession(std::unique_ptr<BlimpBrowserContext> browser_context, | 78 BlimpEngineSession(std::unique_ptr<BlimpBrowserContext> browser_context, |
| 82 net::NetLog* net_log, | 79 net::NetLog* net_log, |
| 83 BlimpEngineConfig* config, | 80 BlimpEngineConfig* config, |
| 84 SettingsManager* settings_manager); | 81 SettingsManager* settings_manager); |
| 85 ~BlimpEngineSession() override; | 82 ~BlimpEngineSession() override; |
| 86 | 83 |
| 87 // Starts the network stack on the IO thread, and sets default placeholder | 84 // Starts the network stack on the IO thread, and sets default placeholder |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 107 // TabControlMessage handler methods. | 104 // TabControlMessage handler methods. |
| 108 // Creates a new WebContents, which will be indexed by |target_tab_id|. | 105 // Creates a new WebContents, which will be indexed by |target_tab_id|. |
| 109 // Returns true if a new WebContents is created, false otherwise. | 106 // Returns true if a new WebContents is created, false otherwise. |
| 110 bool CreateWebContents(const int target_tab_id); | 107 bool CreateWebContents(const int target_tab_id); |
| 111 | 108 |
| 112 void CloseWebContents(const int target_tab_id); | 109 void CloseWebContents(const int target_tab_id); |
| 113 void HandleResize(float device_pixel_ratio, const gfx::Size& size); | 110 void HandleResize(float device_pixel_ratio, const gfx::Size& size); |
| 114 | 111 |
| 115 // NavigationMessage handler methods. | 112 // NavigationMessage handler methods. |
| 116 // Navigates the target tab to the |url|. | 113 // Navigates the target tab to the |url|. |
| 117 void LoadUrl(const int target_tab_id, const GURL& url); | 114 void LoadUrl(const int target_tab_id, const GURL& url); |
|
Kevin M
2016/06/02 18:38:50
Please factor these out into a separate Navigation
haibinlu
2016/06/02 20:24:37
Not sure if we need separate nav feature since it
| |
| 118 void GoBack(const int target_tab_id); | 115 void GoBack(const int target_tab_id); |
| 119 void GoForward(const int target_tab_id); | 116 void GoForward(const int target_tab_id); |
| 120 void Reload(const int target_tab_id); | 117 void Reload(const int target_tab_id); |
| 121 | 118 |
| 122 // RenderWidgetMessage handler methods. | 119 // RenderWidgetMessage handler methods. |
| 123 // RenderWidgetMessageDelegate implementation. | 120 // RenderWidgetMessageDelegate implementation. |
| 124 void OnWebGestureEvent( | 121 void OnWebGestureEvent( |
| 125 content::RenderWidgetHost* render_widget_host, | 122 content::RenderWidgetHost* render_widget_host, |
| 126 std::unique_ptr<blink::WebGestureEvent> event) override; | 123 std::unique_ptr<blink::WebGestureEvent> event) override; |
| 127 void OnCompositorMessageReceived( | 124 void OnCompositorMessageReceived( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 151 | 148 |
| 152 // ui::InputMethodObserver overrides. | 149 // ui::InputMethodObserver overrides. |
| 153 void OnTextInputTypeChanged(const ui::TextInputClient* client) override; | 150 void OnTextInputTypeChanged(const ui::TextInputClient* client) override; |
| 154 void OnFocus() override; | 151 void OnFocus() override; |
| 155 void OnBlur() override; | 152 void OnBlur() override; |
| 156 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; | 153 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; |
| 157 void OnTextInputStateChanged(const ui::TextInputClient* client) override; | 154 void OnTextInputStateChanged(const ui::TextInputClient* client) override; |
| 158 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override; | 155 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override; |
| 159 void OnShowImeIfNeeded() override; | 156 void OnShowImeIfNeeded() override; |
| 160 | 157 |
| 161 // content::WebContentsObserver implementation. | |
| 162 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | |
| 163 void RenderViewHostChanged(content::RenderViewHost* old_host, | |
| 164 content::RenderViewHost* new_host) override; | |
| 165 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | |
| 166 | |
| 167 // PageLoadTrackerClient implementation. | |
| 168 void SendPageLoadStatusUpdate(PageLoadStatus load_status) override; | |
| 169 | |
| 170 // Sets up and owns |new_contents|. | 158 // Sets up and owns |new_contents|. |
| 171 void PlatformSetContents(std::unique_ptr<content::WebContents> new_contents); | 159 void PlatformSetContents(std::unique_ptr<content::WebContents> new_contents, |
| 160 const int target_tab_id); | |
| 172 | 161 |
| 173 // Presents the client's single screen. | 162 // Presents the client's single screen. |
| 174 // Screen should be deleted after browser context (crbug.com/613372). | 163 // Screen should be deleted after browser context (crbug.com/613372). |
| 175 std::unique_ptr<BlimpScreen> screen_; | 164 std::unique_ptr<BlimpScreen> screen_; |
| 176 | 165 |
| 177 // Content BrowserContext for this session. | 166 // Content BrowserContext for this session. |
| 178 std::unique_ptr<BlimpBrowserContext> browser_context_; | 167 std::unique_ptr<BlimpBrowserContext> browser_context_; |
| 179 | 168 |
| 180 // Engine configuration including assigned client token. | 169 // Engine configuration including assigned client token. |
| 181 BlimpEngineConfig* engine_config_; | 170 BlimpEngineConfig* engine_config_; |
| 182 | 171 |
| 183 // Represents the (currently single) browser window into which tab(s) will | 172 // Represents the (currently single) browser window into which tab(s) will |
| 184 // be rendered. | 173 // be rendered. |
| 185 std::unique_ptr<BlimpWindowTreeHost> window_tree_host_; | 174 std::unique_ptr<BlimpWindowTreeHost> window_tree_host_; |
| 186 | 175 |
| 187 // Used to apply standard focus conventions to the windows in the | 176 // Used to apply standard focus conventions to the windows in the |
| 188 // WindowTreeHost hierarchy. | 177 // WindowTreeHost hierarchy. |
| 189 std::unique_ptr<wm::FocusController> focus_client_; | 178 std::unique_ptr<wm::FocusController> focus_client_; |
| 190 | 179 |
| 191 // Used to manage input capture. | 180 // Used to manage input capture. |
| 192 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; | 181 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 193 | 182 |
| 194 // Used to attach null-parented windows (e.g. popups) to the root window. | 183 // Used to attach null-parented windows (e.g. popups) to the root window. |
| 195 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; | 184 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 196 | 185 |
| 197 // Only one web_contents is supported for blimp 0.5 | |
| 198 std::unique_ptr<content::WebContents> web_contents_; | |
| 199 | |
| 200 // Tracks the page load status for a tab. Each PageLoadTracker is tied to a | |
| 201 // WebContents. | |
| 202 std::unique_ptr<PageLoadTracker> page_load_tracker_; | |
| 203 | |
| 204 // Manages all global settings for the engine session. | 186 // Manages all global settings for the engine session. |
| 205 SettingsManager* settings_manager_; | 187 SettingsManager* settings_manager_; |
| 206 | 188 |
| 207 // Handles all incoming messages for type SETTINGS. | 189 // Handles all incoming messages for type SETTINGS. |
| 208 EngineSettingsFeature settings_feature_; | 190 std::unique_ptr<EngineSettingsFeature> settings_feature_; |
|
Kevin M
2016/06/02 18:38:50
Why is this a unique_ptr now?
haibinlu
2016/06/02 20:24:37
reverted. I was thinking about the flexibility of
| |
| 209 | 191 |
| 210 // Handles all incoming and outgoing messages related to RenderWidget, | 192 // Handles all incoming and outgoing messages related to RenderWidget, |
| 211 // including INPUT, COMPOSITOR and RENDER_WIDGET messages. | 193 // including INPUT, COMPOSITOR and RENDER_WIDGET messages. |
| 212 EngineRenderWidgetFeature render_widget_feature_; | 194 std::unique_ptr<EngineRenderWidgetFeature> render_widget_feature_; |
|
Kevin M
2016/06/02 18:38:50
Ditto
haibinlu
2016/06/02 20:24:37
reverted.
| |
| 213 | 195 |
| 214 // Container for connection manager, authentication handler, and | 196 // Container for connection manager, authentication handler, and |
| 215 // browser connection handler. The components run on the I/O thread, and | 197 // browser connection handler. The components run on the I/O thread, and |
| 216 // this object is destroyed there. | 198 // this object is destroyed there. |
| 217 std::unique_ptr<EngineNetworkComponents> net_components_; | 199 std::unique_ptr<EngineNetworkComponents> net_components_; |
| 218 | 200 |
| 219 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; | 201 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; |
| 220 | 202 |
| 221 // Used to send TAB_CONTROL or NAVIGATION messages to client. | 203 // Used to send TAB_CONTROL or NAVIGATION messages to client. |
| 222 std::unique_ptr<BlimpMessageProcessor> tab_control_message_sender_; | 204 std::unique_ptr<BlimpMessageProcessor> tab_control_message_sender_; |
| 223 std::unique_ptr<BlimpMessageProcessor> navigation_message_sender_; | 205 std::unique_ptr<BlimpMessageProcessor> navigation_message_sender_; |
| 224 | 206 |
| 207 // Only one tab is supported for blimp 0.5. | |
| 208 std::unique_ptr<TabBlimp> tab_; | |
| 209 | |
| 225 DISALLOW_COPY_AND_ASSIGN(BlimpEngineSession); | 210 DISALLOW_COPY_AND_ASSIGN(BlimpEngineSession); |
| 226 }; | 211 }; |
| 227 | 212 |
| 228 } // namespace engine | 213 } // namespace engine |
| 229 } // namespace blimp | 214 } // namespace blimp |
| 230 | 215 |
| 231 #endif // BLIMP_ENGINE_SESSION_BLIMP_ENGINE_SESSION_H_ | 216 #endif // BLIMP_ENGINE_SESSION_BLIMP_ENGINE_SESSION_H_ |
| OLD | NEW |