OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_SHELL_BROWSER_SHELL_H_ | 4 #ifndef CONTENT_SHELL_BROWSER_SHELL_H_ |
5 #define CONTENT_SHELL_BROWSER_SHELL_H_ | 5 #define CONTENT_SHELL_BROWSER_SHELL_H_ |
6 | 6 |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "content/public/browser/web_contents_delegate.h" | 15 #include "content/public/browser/web_contents_delegate.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "ipc/ipc_channel.h" | 17 #include "ipc/ipc_channel.h" |
18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
20 | 20 |
21 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
22 #include "base/android/scoped_java_ref.h" | 22 #include "base/android/scoped_java_ref.h" |
23 #elif defined(USE_AURA) | 23 #endif |
24 #if defined(OS_CHROMEOS) | 24 #if defined(USE_AURA) && defined(OS_ANDROID) |
| 25 #include "ui/aura/env_observer.h" |
| 26 #endif |
| 27 #if defined(USE_AURA) |
| 28 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
25 namespace gfx { | 29 namespace gfx { |
26 class Screen; | 30 class Screen; |
27 } | 31 } |
28 namespace wm { | 32 namespace wm { |
29 class WMTestHelper; | 33 class WMTestHelper; |
30 } | 34 } |
31 #endif // defined(OS_CHROMEOS) | 35 #endif // defined(OS_CHROMEOS) |
32 namespace views { | 36 namespace views { |
33 class Widget; | 37 class Widget; |
34 class ViewsDelegate; | 38 class ViewsDelegate; |
35 } | 39 } |
36 #endif // defined(USE_AURA) | 40 #endif // defined(USE_AURA) |
37 | 41 |
38 class GURL; | 42 class GURL; |
39 namespace content { | 43 namespace content { |
40 | 44 |
41 #if defined(USE_AURA) | 45 #if defined(USE_AURA) |
42 class ShellPlatformDataAura; | 46 class ShellPlatformDataAura; |
43 #endif | 47 #endif |
44 | 48 |
45 class BrowserContext; | 49 class BrowserContext; |
46 class ShellDevToolsFrontend; | 50 class ShellDevToolsFrontend; |
47 class ShellJavaScriptDialogManager; | 51 class ShellJavaScriptDialogManager; |
48 class SiteInstance; | 52 class SiteInstance; |
49 class WebContents; | 53 class WebContents; |
50 | 54 |
51 // This represents one window of the Content Shell, i.e. all the UI including | 55 // This represents one window of the Content Shell, i.e. all the UI including |
52 // buttons and url bar, as well as the web content area. | 56 // buttons and url bar, as well as the web content area. |
53 class Shell : public WebContentsDelegate, | 57 class Shell : public WebContentsDelegate, |
54 public WebContentsObserver { | 58 #if defined(USE_AURA) && defined(OS_ANDROID) |
| 59 public aura::EnvObserver, |
| 60 #endif |
| 61 public WebContentsObserver |
| 62 |
| 63 { |
55 public: | 64 public: |
56 ~Shell() override; | 65 ~Shell() override; |
57 | 66 |
58 void LoadURL(const GURL& url); | 67 void LoadURL(const GURL& url); |
59 void LoadURLForFrame(const GURL& url, const std::string& frame_name); | 68 void LoadURLForFrame(const GURL& url, const std::string& frame_name); |
60 void LoadDataWithBaseURL(const GURL& url, | 69 void LoadDataWithBaseURL(const GURL& url, |
61 const std::string& data, | 70 const std::string& data, |
62 const GURL& base_url); | 71 const GURL& base_url); |
63 void GoBackOrForward(int offset); | 72 void GoBackOrForward(int offset); |
64 void Reload(); | 73 void Reload(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 WebContents* OpenURLFromTab(WebContents* source, | 119 WebContents* OpenURLFromTab(WebContents* source, |
111 const OpenURLParams& params) override; | 120 const OpenURLParams& params) override; |
112 void AddNewContents(WebContents* source, | 121 void AddNewContents(WebContents* source, |
113 WebContents* new_contents, | 122 WebContents* new_contents, |
114 WindowOpenDisposition disposition, | 123 WindowOpenDisposition disposition, |
115 const gfx::Rect& initial_rect, | 124 const gfx::Rect& initial_rect, |
116 bool user_gesture, | 125 bool user_gesture, |
117 bool* was_blocked) override; | 126 bool* was_blocked) override; |
118 void LoadingStateChanged(WebContents* source, | 127 void LoadingStateChanged(WebContents* source, |
119 bool to_different_document) override; | 128 bool to_different_document) override; |
120 #if defined(OS_ANDROID) | 129 #if defined(OS_ANDROID) && !defined(USE_AURA) |
121 void LoadProgressChanged(WebContents* source, double progress) override; | 130 void LoadProgressChanged(WebContents* source, double progress) override; |
122 #endif | 131 #endif |
123 void EnterFullscreenModeForTab(WebContents* web_contents, | 132 void EnterFullscreenModeForTab(WebContents* web_contents, |
124 const GURL& origin) override; | 133 const GURL& origin) override; |
125 void ExitFullscreenModeForTab(WebContents* web_contents) override; | 134 void ExitFullscreenModeForTab(WebContents* web_contents) override; |
126 bool IsFullscreenForTabOrPending( | 135 bool IsFullscreenForTabOrPending( |
127 const WebContents* web_contents) const override; | 136 const WebContents* web_contents) const override; |
128 blink::WebDisplayMode GetDisplayMode( | 137 blink::WebDisplayMode GetDisplayMode( |
129 const WebContents* web_contents) const override; | 138 const WebContents* web_contents) const override; |
130 void RequestToLockMouse(WebContents* web_contents, | 139 void RequestToLockMouse(WebContents* web_contents, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Set the title of shell window | 206 // Set the title of shell window |
198 void PlatformSetTitle(const base::string16& title); | 207 void PlatformSetTitle(const base::string16& title); |
199 // User right-clicked on the web view | 208 // User right-clicked on the web view |
200 bool PlatformHandleContextMenu(const content::ContextMenuParams& params); | 209 bool PlatformHandleContextMenu(const content::ContextMenuParams& params); |
201 #if defined(OS_ANDROID) | 210 #if defined(OS_ANDROID) |
202 void PlatformToggleFullscreenModeForTab(WebContents* web_contents, | 211 void PlatformToggleFullscreenModeForTab(WebContents* web_contents, |
203 bool enter_fullscreen); | 212 bool enter_fullscreen); |
204 bool PlatformIsFullscreenForTabOrPending( | 213 bool PlatformIsFullscreenForTabOrPending( |
205 const WebContents* web_contents) const; | 214 const WebContents* web_contents) const; |
206 #endif | 215 #endif |
| 216 #if defined(USE_AURA) && defined(OS_ANDROID) |
| 217 // aura::EnvObserver: |
| 218 void OnWindowInitialized(aura::Window* window) override {} |
| 219 void OnHostInitialized(aura::WindowTreeHost* host) override; |
| 220 #endif |
207 | 221 |
208 gfx::NativeView GetContentView(); | 222 gfx::NativeView GetContentView(); |
209 | 223 |
210 void ToggleFullscreenModeForTab(WebContents* web_contents, | 224 void ToggleFullscreenModeForTab(WebContents* web_contents, |
211 bool enter_fullscreen); | 225 bool enter_fullscreen); |
212 // WebContentsObserver | 226 // WebContentsObserver |
213 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override; | 227 void TitleWasSet(NavigationEntry* entry, bool explicit_set) override; |
214 | 228 |
215 void InnerShowDevTools(); | 229 void InnerShowDevTools(); |
216 void OnDevToolsWebContentsDestroyed(); | 230 void OnDevToolsWebContentsDestroyed(); |
217 | 231 |
218 scoped_ptr<ShellJavaScriptDialogManager> dialog_manager_; | 232 scoped_ptr<ShellJavaScriptDialogManager> dialog_manager_; |
219 | 233 |
220 scoped_ptr<WebContents> web_contents_; | 234 scoped_ptr<WebContents> web_contents_; |
221 | 235 |
222 scoped_ptr<DevToolsWebContentsObserver> devtools_observer_; | 236 scoped_ptr<DevToolsWebContentsObserver> devtools_observer_; |
223 ShellDevToolsFrontend* devtools_frontend_; | 237 ShellDevToolsFrontend* devtools_frontend_; |
224 | 238 |
225 bool is_fullscreen_; | 239 bool is_fullscreen_; |
226 | 240 |
227 gfx::NativeWindow window_; | 241 gfx::NativeWindow window_; |
228 gfx::NativeEditView url_edit_view_; | 242 gfx::NativeEditView url_edit_view_; |
229 | 243 |
230 gfx::Size content_size_; | 244 gfx::Size content_size_; |
231 | 245 |
232 #if defined(OS_ANDROID) | 246 #if defined(OS_ANDROID) && !defined(USE_AURA) |
233 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 247 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
234 #elif defined(USE_AURA) | 248 #endif |
235 #if defined(OS_CHROMEOS) | 249 #if defined(USE_AURA) |
| 250 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
236 static wm::WMTestHelper* wm_test_helper_; | 251 static wm::WMTestHelper* wm_test_helper_; |
237 static gfx::Screen* test_screen_; | 252 static gfx::Screen* test_screen_; |
238 #endif | 253 #endif |
239 #if defined(TOOLKIT_VIEWS) | 254 #if defined(TOOLKIT_VIEWS) |
240 static views::ViewsDelegate* views_delegate_; | 255 static views::ViewsDelegate* views_delegate_; |
241 | 256 |
242 views::Widget* window_widget_; | 257 views::Widget* window_widget_; |
243 #endif // defined(TOOLKIT_VIEWS) | 258 #endif // defined(TOOLKIT_VIEWS) |
244 static ShellPlatformDataAura* platform_; | 259 static ShellPlatformDataAura* platform_; |
245 #endif // defined(USE_AURA) | 260 #endif // defined(USE_AURA) |
246 | 261 |
247 bool headless_; | 262 bool headless_; |
248 | 263 |
249 // A container of all the open windows. We use a vector so we can keep track | 264 // A container of all the open windows. We use a vector so we can keep track |
250 // of ordering. | 265 // of ordering. |
251 static std::vector<Shell*> windows_; | 266 static std::vector<Shell*> windows_; |
252 | 267 |
253 static base::Callback<void(Shell*)> shell_created_callback_; | 268 static base::Callback<void(Shell*)> shell_created_callback_; |
254 | 269 |
255 // True if the destructur of Shell should post a quit closure on the current | 270 // True if the destructur of Shell should post a quit closure on the current |
256 // message loop if the destructed Shell object was the last one. | 271 // message loop if the destructed Shell object was the last one. |
257 static bool quit_message_loop_; | 272 static bool quit_message_loop_; |
| 273 |
| 274 #if defined(USE_AURA) && defined(OS_ANDROID) |
| 275 // Closure for quitting nested message loop. |
| 276 base::Closure quit_closure_; |
| 277 #endif |
258 }; | 278 }; |
259 | 279 |
260 } // namespace content | 280 } // namespace content |
261 | 281 |
262 #endif // CONTENT_SHELL_BROWSER_SHELL_H_ | 282 #endif // CONTENT_SHELL_BROWSER_SHELL_H_ |
OLD | NEW |