Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| index 0fc2348492cfdb8c0628f910470c983a63ce1d74..1c8b256caf7814a80a81e825518b31e0826df826 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| @@ -10,6 +10,7 @@ |
| #include "content/browser/renderer_host/render_widget_host.h" |
| #include "content/public/browser/native_web_keyboard_event.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| #include "ui/aura/aura_constants.h" |
| #include "ui/aura/desktop.h" |
| #include "ui/aura/event.h" |
| @@ -17,6 +18,9 @@ |
| #include "ui/aura/window.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/compositor/layer.h" |
| +#include "ui/gfx/screen.h" |
| +#include "views/widget/native_widget_aura.h" |
| +#include "views/widget/widget.h" |
| #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| #include "base/bind.h" |
| @@ -78,6 +82,8 @@ void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, |
| RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| : host_(host), |
| ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| + is_fullscreen_(false), |
| + popup_parent_host_view_(NULL), |
| is_loading_(false) { |
| host_->SetView(this); |
| } |
| @@ -95,18 +101,30 @@ void RenderWidgetHostViewAura::Init() { |
| void RenderWidgetHostViewAura::InitAsPopup( |
| RenderWidgetHostView* parent_host_view, |
| const gfx::Rect& pos) { |
| - NOTIMPLEMENTED(); |
| - // TODO(ivankr): there has to be an Init() call, otherwise |window_| |
| - // is left uninitialized and will eventually crash. |
| Init(); |
| + popup_parent_host_view_ = |
| + static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
| + window_->SetProperty( |
|
Daniel Erat
2011/10/28 14:56:16
Thoughts about whether this should be exposed by a
Ben Goodger (Google)
2011/10/28 16:27:53
I would like to get rid of Window::type_, mostly b
Daniel Erat
2011/10/28 17:04:25
I agree with the sentiment, but it seems like we s
|
| + views::NativeWidgetAura::kWindowTypeKey, |
| + reinterpret_cast<void*>(views::Widget::InitParams::TYPE_MENU)); |
|
Ben Goodger (Google)
2011/10/28 16:27:53
However, you can't use views types here, because s
Daniel Erat
2011/10/28 17:04:25
Of the values currently in ui/aura/window_types.h,
|
| + window_->SetParent(NULL); |
| + Show(); |
| + SetBounds(pos); |
| } |
| void RenderWidgetHostViewAura::InitAsFullscreen( |
| RenderWidgetHostView* reference_host_view) { |
| - NOTIMPLEMENTED(); |
| - // TODO(ivankr): there has to be an Init() call, otherwise |window_| |
| - // is left uninitialized and will eventually crash. |
| Init(); |
| + is_fullscreen_ = true; |
| + window_->SetProperty( |
| + views::NativeWidgetAura::kWindowTypeKey, |
| + reinterpret_cast<void*>(views::Widget::InitParams::TYPE_POPUP)); |
| + window_->SetParent(NULL); |
| + window_->Fullscreen(); |
| + Show(); |
| + Focus(); |
| + // TODO(derat): The window is visible but it's not being updated. Figure out |
| + // why. |
| } |
| RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
| @@ -126,7 +144,20 @@ void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
| } |
| void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { |
| - window_->SetBounds(rect); |
| + gfx::Rect adjusted_rect = rect; |
| + |
| + if (popup_parent_host_view_) { |
| + gfx::Point translated_origin = adjusted_rect.origin(); |
| + // |rect| is relative to |popup_parent_host_view_|; translate it for the |
| + // window's container. |
| + aura::Window::ConvertPointToWindow( |
| + popup_parent_host_view_->window_, |
| + window_->parent(), |
| + &translated_origin); |
| + adjusted_rect.set_origin(translated_origin); |
| + } |
| + |
| + window_->SetBounds(adjusted_rect); |
| host_->WasResized(); |
| } |
| @@ -285,16 +316,20 @@ void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
| #if defined(OS_POSIX) |
| void RenderWidgetHostViewAura::GetDefaultScreenInfo( |
| WebKit::WebScreenInfo* results) { |
| - NOTIMPLEMENTED(); |
| + GetScreenInfo(results); |
| } |
| void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { |
| - NOTIMPLEMENTED(); |
| + const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
| + results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
| + results->availableRect = results->rect; |
| + // TODO(derat): Don't hardcode this? |
| + results->depth = 24; |
| + results->depthPerComponent = 8; |
| } |
| gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { |
| - NOTIMPLEMENTED(); |
| - return gfx::Rect(); |
| + return aura::Desktop::GetInstance()->bounds(); |
| } |
| #endif |
| @@ -374,8 +409,13 @@ void RenderWidgetHostViewAura::OnBlur() { |
| } |
| bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { |
| - NativeWebKeyboardEvent webkit_event(event); |
| - host_->ForwardKeyboardEvent(webkit_event); |
| + // We need to handle the Escape key for Pepper Flash. |
| + if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
| + host_->Shutdown(); |
| + } else { |
| + NativeWebKeyboardEvent webkit_event(event); |
| + host_->ForwardKeyboardEvent(webkit_event); |
| + } |
| return true; |
| } |