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

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: avoid passing unneeded parameters. um. 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/desktop.h" 14 #include "ui/aura/desktop.h"
14 #include "ui/aura/event.h" 15 #include "ui/aura/event.h"
15 #include "ui/aura/hit_test.h" 16 #include "ui/aura/hit_test.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/compositor/layer.h" 19 #include "ui/gfx/compositor/layer.h"
20 #include "ui/gfx/screen.h"
21 #include "views/widget/native_widget_aura.h"
22 #include "views/widget/widget.h"
19 23
20 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 24 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
21 #include "base/bind.h" 25 #include "base/bind.h"
22 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 26 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
23 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" 27 #include "content/browser/renderer_host/accelerated_surface_container_linux.h"
24 #include "content/common/gpu/gpu_messages.h" 28 #include "content/common/gpu/gpu_messages.h"
25 #include "ui/gfx/gl/gl_bindings.h" 29 #include "ui/gfx/gl/gl_bindings.h"
26 #endif 30 #endif
27 31
28 using WebKit::WebTouchEvent; 32 using WebKit::WebTouchEvent;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 74 }
71 75
72 } // namespace 76 } // namespace
73 77
74 //////////////////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////////////////
75 // RenderWidgetHostViewAura, public: 79 // RenderWidgetHostViewAura, public:
76 80
77 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) 81 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
78 : host_(host), 82 : host_(host),
79 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),
80 is_loading_(false) { 86 is_loading_(false) {
81 host_->SetView(this); 87 host_->SetView(this);
82 } 88 }
83 89
84 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 90 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
85 } 91 }
86 92
87 void RenderWidgetHostViewAura::Init() { 93 void RenderWidgetHostViewAura::Init() {
88 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); 94 window_->Init(ui::Layer::LAYER_HAS_TEXTURE);
89 } 95 }
90 96
91 //////////////////////////////////////////////////////////////////////////////// 97 ////////////////////////////////////////////////////////////////////////////////
92 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 98 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
93 99
94 void RenderWidgetHostViewAura::InitAsPopup( 100 void RenderWidgetHostViewAura::InitAsPopup(
95 RenderWidgetHostView* parent_host_view, 101 RenderWidgetHostView* parent_host_view,
96 const gfx::Rect& pos) { 102 const gfx::Rect& pos) {
97 NOTIMPLEMENTED();
98 // TODO(ivankr): there has to be an Init() call, otherwise |window_|
99 // is left uninitialized and will eventually crash.
100 Init(); 103 Init();
104 popup_parent_host_view_ =
105 static_cast<RenderWidgetHostViewAura*>(parent_host_view);
106 window_->SetProperty(
107 views::NativeWidgetAura::kWindowTypeKey,
108 reinterpret_cast<void*>(views::Widget::InitParams::TYPE_MENU));
109 window_->SetParent(NULL);
110 Show();
111 SetBounds(pos);
101 } 112 }
102 113
103 void RenderWidgetHostViewAura::InitAsFullscreen( 114 void RenderWidgetHostViewAura::InitAsFullscreen(
104 RenderWidgetHostView* reference_host_view) { 115 RenderWidgetHostView* reference_host_view) {
105 NOTIMPLEMENTED();
106 // TODO(ivankr): there has to be an Init() call, otherwise |window_|
107 // is left uninitialized and will eventually crash.
108 Init(); 116 Init();
117 is_fullscreen_ = true;
118 window_->SetProperty(
119 views::NativeWidgetAura::kWindowTypeKey,
120 reinterpret_cast<void*>(views::Widget::InitParams::TYPE_POPUP));
121 window_->SetParent(NULL);
122 window_->Fullscreen();
123 Show();
124 Focus();
125 // TODO(derat): The window is visible but it's not being updated. Figure out
126 // why.
109 } 127 }
110 128
111 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 129 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
112 return host_; 130 return host_;
113 } 131 }
114 132
115 void RenderWidgetHostViewAura::DidBecomeSelected() { 133 void RenderWidgetHostViewAura::DidBecomeSelected() {
116 host_->WasRestored(); 134 host_->WasRestored();
117 } 135 }
118 136
119 void RenderWidgetHostViewAura::WasHidden() { 137 void RenderWidgetHostViewAura::WasHidden() {
120 host_->WasHidden(); 138 host_->WasHidden();
121 } 139 }
122 140
123 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { 141 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) {
124 SetBounds(gfx::Rect(window_->bounds().origin(), size)); 142 SetBounds(gfx::Rect(window_->bounds().origin(), size));
125 } 143 }
126 144
127 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { 145 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
128 window_->SetBounds(rect); 146 gfx::Rect adjusted_rect = rect;
147
148 if (popup_parent_host_view_) {
149 gfx::Point translated_origin = adjusted_rect.origin();
150 // |rect| is relative to |popup_parent_host_view_|; translate it for the
151 // window's container.
152 aura::Window::ConvertPointToWindow(
153 popup_parent_host_view_->window_,
154 window_->parent(),
155 &translated_origin);
156 adjusted_rect.set_origin(translated_origin);
157 }
158
159 window_->SetBounds(adjusted_rect);
129 host_->WasResized(); 160 host_->WasResized();
130 } 161 }
131 162
132 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { 163 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const {
133 return window_; 164 return window_;
134 } 165 }
135 166
136 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { 167 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const {
137 return static_cast<gfx::NativeViewId>(NULL); 168 return static_cast<gfx::NativeViewId>(NULL);
138 } 169 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 RenderWidgetHostView::SetBackground(background); 307 RenderWidgetHostView::SetBackground(background);
277 host_->SetBackground(background); 308 host_->SetBackground(background);
278 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) 309 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
279 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); 310 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
280 #endif 311 #endif
281 } 312 }
282 313
283 #if defined(OS_POSIX) 314 #if defined(OS_POSIX)
284 void RenderWidgetHostViewAura::GetDefaultScreenInfo( 315 void RenderWidgetHostViewAura::GetDefaultScreenInfo(
285 WebKit::WebScreenInfo* results) { 316 WebKit::WebScreenInfo* results) {
286 NOTIMPLEMENTED(); 317 GetScreenInfo(results);
287 } 318 }
288 319
289 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { 320 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) {
290 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;
291 } 327 }
292 328
293 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { 329 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() {
294 NOTIMPLEMENTED(); 330 return aura::Desktop::GetInstance()->bounds();
295 return gfx::Rect();
296 } 331 }
297 #endif 332 #endif
298 333
299 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, 334 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color,
300 bool animate) { 335 bool animate) {
301 NOTIMPLEMENTED(); 336 NOTIMPLEMENTED();
302 } 337 }
303 338
304 void RenderWidgetHostViewAura::UnhandledWheelEvent( 339 void RenderWidgetHostViewAura::UnhandledWheelEvent(
305 const WebKit::WebMouseWheelEvent& event) { 340 const WebKit::WebMouseWheelEvent& event) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 400
366 void RenderWidgetHostViewAura::OnFocus() { 401 void RenderWidgetHostViewAura::OnFocus() {
367 host_->GotFocus(); 402 host_->GotFocus();
368 } 403 }
369 404
370 void RenderWidgetHostViewAura::OnBlur() { 405 void RenderWidgetHostViewAura::OnBlur() {
371 host_->Blur(); 406 host_->Blur();
372 } 407 }
373 408
374 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { 409 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) {
375 NativeWebKeyboardEvent webkit_event(event); 410 // We need to handle the Escape key for Pepper Flash.
376 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 }
377 return true; 417 return true;
378 } 418 }
379 419
380 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { 420 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) {
381 // TODO(beng): talk to beng before implementing this. 421 // TODO(beng): talk to beng before implementing this.
382 //NOTIMPLEMENTED(); 422 //NOTIMPLEMENTED();
383 return gfx::kNullCursor; 423 return gfx::kNullCursor;
384 } 424 }
385 425
386 int RenderWidgetHostViewAura::GetNonClientComponent( 426 int RenderWidgetHostViewAura::GetNonClientComponent(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 506 }
467 #endif 507 #endif
468 508
469 //////////////////////////////////////////////////////////////////////////////// 509 ////////////////////////////////////////////////////////////////////////////////
470 // RenderWidgetHostViewAura, private: 510 // RenderWidgetHostViewAura, private:
471 511
472 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 512 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
473 //NOTIMPLEMENTED(); 513 //NOTIMPLEMENTED();
474 // TODO(beng): See RenderWidgetHostViewWin. 514 // TODO(beng): See RenderWidgetHostViewWin.
475 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698