Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 8417008: aura: Add fullscreen/popups to RenderWidgetHostViewAura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use aura::WindowType Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/backing_store_skia.h" 8 #include "content/browser/renderer_host/backing_store_skia.h"
9 #include "content/browser/renderer_host/web_input_event_aura.h" 9 #include "content/browser/renderer_host/web_input_event_aura.h"
10 #include "content/browser/renderer_host/render_widget_host.h" 10 #include "content/browser/renderer_host/render_widget_host.h"
11 #include "content/public/browser/native_web_keyboard_event.h" 11 #include "content/public/browser/native_web_keyboard_event.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
13 #include "ui/aura/aura_constants.h" 14 #include "ui/aura/aura_constants.h"
14 #include "ui/aura/desktop.h" 15 #include "ui/aura/desktop.h"
15 #include "ui/aura/event.h" 16 #include "ui/aura/event.h"
16 #include "ui/aura/hit_test.h" 17 #include "ui/aura/hit_test.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/aura/window_types.h"
18 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/compositor/layer.h" 21 #include "ui/gfx/compositor/layer.h"
22 #include "ui/gfx/screen.h"
20 23
21 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 24 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
22 #include "base/bind.h" 25 #include "base/bind.h"
23 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 26 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
24 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" 27 #include "content/browser/renderer_host/accelerated_surface_container_linux.h"
25 #include "content/common/gpu/gpu_messages.h" 28 #include "content/common/gpu/gpu_messages.h"
26 #include "ui/gfx/gl/gl_bindings.h" 29 #include "ui/gfx/gl/gl_bindings.h"
27 #endif 30 #endif
28 31
29 using WebKit::WebTouchEvent; 32 using WebKit::WebTouchEvent;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 74 }
72 75
73 } // namespace 76 } // namespace
74 77
75 //////////////////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////////////////
76 // RenderWidgetHostViewAura, public: 79 // RenderWidgetHostViewAura, public:
77 80
78 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) 81 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
79 : host_(host), 82 : host_(host),
80 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 83 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
84 is_fullscreen_(false),
85 popup_parent_host_view_(NULL),
81 is_loading_(false) { 86 is_loading_(false) {
82 host_->SetView(this); 87 host_->SetView(this);
83 } 88 }
84 89
85 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 90 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
86 } 91 }
87 92
88 void RenderWidgetHostViewAura::Init() { 93 void RenderWidgetHostViewAura::Init() {
89 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); 94 window_->Init(ui::Layer::LAYER_HAS_TEXTURE,
95 aura::Window::LAYER_INITIALLY_INVISIBLE);
90 } 96 }
91 97
92 //////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////////
93 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 99 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
94 100
95 void RenderWidgetHostViewAura::InitAsPopup( 101 void RenderWidgetHostViewAura::InitAsPopup(
96 RenderWidgetHostView* parent_host_view, 102 RenderWidgetHostView* parent_host_view,
97 const gfx::Rect& pos) { 103 const gfx::Rect& pos) {
98 NOTIMPLEMENTED(); 104 popup_parent_host_view_ =
99 // TODO(ivankr): there has to be an Init() call, otherwise |window_| 105 static_cast<RenderWidgetHostViewAura*>(parent_host_view);
100 // is left uninitialized and will eventually crash. 106 window_->SetType(aura::WINDOW_TYPE_MENU);
101 Init(); 107 Init();
108
109 window_->SetParent(NULL);
110 Show();
111 SetBounds(pos);
102 } 112 }
103 113
104 void RenderWidgetHostViewAura::InitAsFullscreen( 114 void RenderWidgetHostViewAura::InitAsFullscreen(
105 RenderWidgetHostView* reference_host_view) { 115 RenderWidgetHostView* reference_host_view) {
106 NOTIMPLEMENTED(); 116 window_->SetType(aura::WINDOW_TYPE_POPUP);
107 // TODO(ivankr): there has to be an Init() call, otherwise |window_| 117 is_fullscreen_ = true;
108 // is left uninitialized and will eventually crash.
109 Init(); 118 Init();
119
120 window_->SetParent(NULL);
121 window_->Fullscreen();
122 Show();
123 Focus();
124 // TODO(derat): The window is visible but it's not being updated. Figure out
125 // why.
110 } 126 }
111 127
112 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 128 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
113 return host_; 129 return host_;
114 } 130 }
115 131
116 void RenderWidgetHostViewAura::DidBecomeSelected() { 132 void RenderWidgetHostViewAura::DidBecomeSelected() {
117 host_->WasRestored(); 133 host_->WasRestored();
118 } 134 }
119 135
120 void RenderWidgetHostViewAura::WasHidden() { 136 void RenderWidgetHostViewAura::WasHidden() {
121 host_->WasHidden(); 137 host_->WasHidden();
122 } 138 }
123 139
124 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 140 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
125 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 141 SetBounds(gfx::Rect(window_->bounds().origin(), size));
126 } 142 }
127 143
128 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 144 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
129 window_->SetBounds(rect); 145 gfx::Rect adjusted_rect = rect;
146
147 if (popup_parent_host_view_) {
148 gfx::Point translated_origin = adjusted_rect.origin();
149 // |rect| is relative to |popup_parent_host_view_|; translate it for the
150 // window's container.
151 aura::Window::ConvertPointToWindow(
152 popup_parent_host_view_->window_,
153 window_->parent(),
154 &translated_origin);
155 adjusted_rect.set_origin(translated_origin);
156 }
157
158 window_->SetBounds(adjusted_rect);
130 host_->WasResized(); 159 host_->WasResized();
131 } 160 }
132 161
133 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { 162 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const {
134 return window_; 163 return window_;
135 } 164 }
136 165
137 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { 166 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const {
138 return static_cast<gfx::NativeViewId>(NULL); 167 return static_cast<gfx::NativeViewId>(NULL);
139 } 168 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 RenderWidgetHostView::SetBackground(background); 307 RenderWidgetHostView::SetBackground(background);
279 host_->SetBackground(background); 308 host_->SetBackground(background);
280 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 309 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
281 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 310 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
282 #endif 311 #endif
283 } 312 }
284 313
285 #if defined(OS_POSIX) 314 #if defined(OS_POSIX)
286 void RenderWidgetHostViewAura::GetDefaultScreenInfo( 315 void RenderWidgetHostViewAura::GetDefaultScreenInfo(
287 WebKit::WebScreenInfo* results) { 316 WebKit::WebScreenInfo* results) {
288 NOTIMPLEMENTED(); 317 GetScreenInfo(results);
289 } 318 }
290 319
291 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { 320 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) {
292 NOTIMPLEMENTED(); 321 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize();
322 results->rect = WebKit::WebRect(0, 0, size.width(), size.height());
323 results->availableRect = results->rect;
324 // TODO(derat): Don't hardcode this?
325 results->depth = 24;
326 results->depthPerComponent = 8;
293 } 327 }
294 328
295 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { 329 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() {
296 NOTIMPLEMENTED(); 330 return aura::Desktop::GetInstance()->bounds();
297 return gfx::Rect();
298 } 331 }
299 #endif 332 #endif
300 333
301 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, 334 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color,
302 bool animate) { 335 bool animate) {
303 NOTIMPLEMENTED(); 336 NOTIMPLEMENTED();
304 } 337 }
305 338
306 void RenderWidgetHostViewAura::UnhandledWheelEvent( 339 void RenderWidgetHostViewAura::UnhandledWheelEvent(
307 const WebKit::WebMouseWheelEvent& event) { 340 const WebKit::WebMouseWheelEvent& event) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 400
368 void RenderWidgetHostViewAura::OnFocus() { 401 void RenderWidgetHostViewAura::OnFocus() {
369 host_->GotFocus(); 402 host_->GotFocus();
370 } 403 }
371 404
372 void RenderWidgetHostViewAura::OnBlur() { 405 void RenderWidgetHostViewAura::OnBlur() {
373 host_->Blur(); 406 host_->Blur();
374 } 407 }
375 408
376 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { 409 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) {
377 NativeWebKeyboardEvent webkit_event(event); 410 // We need to handle the Escape key for Pepper Flash.
378 host_->ForwardKeyboardEvent(webkit_event); 411 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
412 host_->Shutdown();
413 } else {
414 NativeWebKeyboardEvent webkit_event(event);
415 host_->ForwardKeyboardEvent(webkit_event);
416 }
379 return true; 417 return true;
380 } 418 }
381 419
382 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { 420 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) {
383 // TODO(beng): talk to beng before implementing this. 421 // TODO(beng): talk to beng before implementing this.
384 //NOTIMPLEMENTED(); 422 //NOTIMPLEMENTED();
385 return gfx::kNullCursor; 423 return gfx::kNullCursor;
386 } 424 }
387 425
388 int RenderWidgetHostViewAura::GetNonClientComponent( 426 int RenderWidgetHostViewAura::GetNonClientComponent(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 506 }
469 #endif 507 #endif
470 508
471 //////////////////////////////////////////////////////////////////////////////// 509 ////////////////////////////////////////////////////////////////////////////////
472 // RenderWidgetHostViewAura, private: 510 // RenderWidgetHostViewAura, private:
473 511
474 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 512 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
475 //NOTIMPLEMENTED(); 513 //NOTIMPLEMENTED();
476 // TODO(beng): See RenderWidgetHostViewWin. 514 // TODO(beng): See RenderWidgetHostViewWin.
477 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698