#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_png_rep.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen.h"
#include "ui/wm/public/drag_drop_client.h"
#include "ui/wm/public/drag_drop_delegate.h"
+#if defined(OS_WIN)
+#include "content/browser/accessibility/browser_accessibility_manager.h"
+#include "content/browser/accessibility/browser_accessibility_win.h"
+#include "ui/base/win/hidden_window.h"
+#endif
+
namespace content {
WebContentsView* CreateWebContentsView(
WebContentsImpl* web_contents,
void stop_forwarding_events() { forward_events_ = false; }
private:
- virtual ~OverscrollWindowDelegate() {}
+ ~OverscrollWindowDelegate() override {}
aura::Window* web_contents_window() {
return web_contents_->GetView()->GetContentNativeView();
}
// Overridden from ui::EventHandler.
- virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE {
+ void OnScrollEvent(ui::ScrollEvent* event) override {
if (forward_events_ && web_contents_window())
web_contents_window()->delegate()->OnScrollEvent(event);
}
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ void OnGestureEvent(ui::GestureEvent* event) override {
if (forward_events_ && web_contents_window())
web_contents_window()->delegate()->OnGestureEvent(event);
}
Source<WebContents>(contents));
}
- virtual ~WebDragSourceAura() {
- }
+ ~WebDragSourceAura() override {}
// NotificationObserver:
- virtual void Observe(int type,
- const NotificationSource& source,
- const NotificationDetails& details) OVERRIDE {
+ void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) override {
if (type != NOTIFICATION_WEB_CONTENTS_DISCONNECTED)
return;
void WriteFileSystemFilesToPickle(
const std::vector<DropData::FileSystemFileInfo>& file_system_files,
Pickle* pickle) {
- pickle->WriteUInt64(file_system_files.size());
+ pickle->WriteSizeT(file_system_files.size());
for (size_t i = 0; i < file_system_files.size(); ++i) {
pickle->WriteString(file_system_files[i].url.spec());
pickle->WriteInt64(file_system_files[i].size);
std::vector<DropData::FileSystemFileInfo>* file_system_files) {
PickleIterator iter(pickle);
- uint64 num_files = 0;
- if (!pickle.ReadUInt64(&iter, &num_files))
+ size_t num_files = 0;
+ if (!pickle.ReadSizeT(&iter, &num_files))
return false;
file_system_files->resize(num_files);
- for (uint64 i = 0; i < num_files; ++i) {
+ for (size_t i = 0; i < num_files; ++i) {
std::string url_string;
int64 size = 0;
if (!pickle.ReadString(&iter, &url_string) ||
#endif
}
- virtual ~WindowObserver() {
+ ~WindowObserver() override {
view_->window_->RemoveObserver(this);
if (view_->window_->GetHost())
view_->window_->GetHost()->RemoveObserver(this);
}
// Overridden from aura::WindowObserver:
- virtual void OnWindowHierarchyChanged(
- const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE {
+ void OnWindowHierarchyChanged(
+ const aura::WindowObserver::HierarchyChangeParams& params) override {
if (params.receiver != view_->window_.get() ||
!params.target->Contains(view_->window_.get())) {
return;
// Note: this is hard coding how Chrome layer adds its dialogs. Since NPAPI is
// going to be deprecated in a year, this is ok for now. The test for this is
// PrintPreviewTest.WindowedNPAPIPluginHidden.
- virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE {
+ virtual void OnWindowAdded(aura::Window* new_window) override {
if (!new_window->Contains(view_->window_.get())) {
// Skip the case when the parent moves to the root window.
if (new_window != host_window_) {
}
}
- virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE {
+ virtual void OnWillRemoveWindow(aura::Window* window) override {
if (window == view_->window_)
return;
}
virtual void OnWindowVisibilityChanged(aura::Window* window,
- bool visible) OVERRIDE {
+ bool visible) override {
if (window == view_->window_ ||
window->parent() == host_window_ ||
window->parent() == view_->window_->GetRootWindow()) {
}
#endif
- virtual void OnWindowParentChanged(aura::Window* window,
- aura::Window* parent) OVERRIDE {
+ void OnWindowParentChanged(aura::Window* window,
+ aura::Window* parent) override {
if (window != view_->window_)
return;
}
}
- virtual void OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE {
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
if (window == host_window_ || window == view_->window_) {
SendScreenRects();
if (view_->touch_editable_)
}
}
- virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
+ void OnWindowDestroying(aura::Window* window) override {
if (window == host_window_) {
host_window_->RemoveObserver(this);
host_window_ = NULL;
}
}
- virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE {
+ void OnWindowAddedToRootWindow(aura::Window* window) override {
if (window == view_->window_) {
window->GetHost()->AddObserver(this);
#if defined(OS_WIN)
if (!window->GetRootWindow()->HasObserver(this))
window->GetRootWindow()->AddObserver(this);
+ if (view_->legacy_hwnd_) {
+ view_->legacy_hwnd_->UpdateParent(
+ window->GetHost()->GetAcceleratedWidget());
+ }
#endif
}
}
- virtual void OnWindowRemovingFromRootWindow(aura::Window* window,
- aura::Window* new_root) OVERRIDE {
+ void OnWindowRemovingFromRootWindow(aura::Window* window,
+ aura::Window* new_root) override {
if (window == view_->window_) {
window->GetHost()->RemoveObserver(this);
#if defined(OS_WIN)
root_children[i]->RemoveObserver(this);
}
}
+
+ if (view_->legacy_hwnd_)
+ view_->legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
#endif
}
}
// Overridden WindowTreeHostObserver:
- virtual void OnHostMoved(const aura::WindowTreeHost* host,
- const gfx::Point& new_origin) OVERRIDE {
+ void OnHostMoved(const aura::WindowTreeHost* host,
+ const gfx::Point& new_origin) override {
TRACE_EVENT1("ui",
"WebContentsViewAura::WindowObserver::OnHostMoved",
"new_origin", new_origin.ToString());
gfx::Transform transform;
int content_width =
web_contents_->GetRenderWidgetHostView()->GetViewBounds().width();
- int translate_x = mode == OVERSCROLL_WEST ? -content_width : content_width;
+ float translate_x = static_cast<float>(mode == OVERSCROLL_WEST ?
+ -content_width : content_width);
transform.Translate(translate_x, 0);
target->SetTransform(transform);
UpdateOverscrollWindowBrightness(translate_x);
overscroll_window_.get() : GetContentNativeView();
}
-gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x,
- int delta_y) {
+gfx::Vector2dF WebContentsViewAura::GetTranslationForOverscroll(float delta_x,
+ float delta_y) {
if (current_overscroll_gesture_ == OVERSCROLL_NORTH ||
current_overscroll_gesture_ == OVERSCROLL_SOUTH) {
- return gfx::Vector2d(0, delta_y);
+ return gfx::Vector2dF(0, delta_y);
}
// For horizontal overscroll, scroll freely if a navigation is possible. Do a
// resistive scroll otherwise.
const NavigationControllerImpl& controller = web_contents_->GetController();
const gfx::Rect& bounds = GetViewBounds();
+ const float bounds_width = static_cast<float>(bounds.width());
if (ShouldNavigateForward(controller, current_overscroll_gesture_))
- return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0);
+ return gfx::Vector2dF(std::max(-bounds_width, delta_x), 0);
else if (ShouldNavigateBack(controller, current_overscroll_gesture_))
- return gfx::Vector2d(std::min(bounds.width(), delta_x), 0);
- return gfx::Vector2d();
+ return gfx::Vector2dF(std::min(bounds_width, delta_x), 0);
+ return gfx::Vector2dF();
}
void WebContentsViewAura::PrepareOverscrollNavigationOverlay() {
touch_editable_->AttachToView(rwhva);
}
-void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(int delta_y) {
+void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(
+ float delta_y) {
if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled())
web_contents_->GetDelegate()->OverscrollUpdate(delta_y);
}
if (bounds.size() != size) {
bounds.set_size(size);
window_->SetBounds(bounds);
+#if defined(OS_WIN)
+ if (legacy_hwnd_)
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
+#endif
} else {
// Our size matches what we want but the renderers size may not match.
// Pretend we were resized so that the renderers size is updated too.
if (delegate_.get() && delegate_->Focus())
return;
- RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
+ RenderWidgetHostView* rwhv =
+ web_contents_->GetFullscreenRenderWidgetHostView();
+ if (!rwhv)
+ rwhv = web_contents_->GetRenderWidgetHostView();
if (rwhv)
rwhv->Focus();
}
// platforms as well.
if (delegate_)
drag_dest_delegate_ = delegate_->GetDragDestDelegate();
+
+#if defined(OS_WIN)
+ if (context && context->GetHost()) {
+ HWND parent_hwnd = context->GetHost()->GetAcceleratedWidget();
+ CHECK(parent_hwnd);
+ legacy_hwnd_.reset(LegacyRenderWidgetHostHWND::Create(parent_hwnd, this));
+ }
+#endif
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
- RenderWidgetHost* render_widget_host) {
+ RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
if (render_widget_host->GetView()) {
// During testing, the view will already be set up in most cases to the
// test view, so we don't want to clobber it with a real one. To verify that
}
RenderWidgetHostViewAura* view =
- new RenderWidgetHostViewAura(render_widget_host);
+ new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack);
view->InitAsChild(NULL);
GetNativeView()->AddChild(view->GetNativeView());
}
AttachTouchEditableToRenderView();
+
+#if defined(OS_WIN)
+ if (legacy_hwnd_)
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
+#endif
+
return view;
}
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
- return new RenderWidgetHostViewAura(render_widget_host);
+ RenderWidgetHostViewAura* view =
+ new RenderWidgetHostViewAura(render_widget_host, false);
+#if defined(OS_WIN)
+ if (legacy_hwnd_)
+ view->SetLegacyRenderWidgetHostHWND(legacy_hwnd_.get());
+#endif
+ return view;
}
void WebContentsViewAura::SetPageTitle(const base::string16& title) {
return false;
aura::Window* target = GetWindowToAnimateForOverscroll();
- gfx::Vector2d translate = GetTranslationForOverscroll(delta_x, delta_y);
+ gfx::Vector2dF translate = GetTranslationForOverscroll(delta_x, delta_y);
gfx::Transform transform;
if (current_overscroll_gesture_ == OVERSCROLL_NORTH ||
if (web_contents_->should_normally_be_visible())
web_contents_->WasHidden();
}
+
+#if defined(OS_WIN)
+ if (!legacy_hwnd_)
+ return;
+
+ if (visible && GetNativeView() && GetNativeView()->GetHost()) {
+ legacy_hwnd_->UpdateParent(
+ GetNativeView()->GetHost()->GetAcceleratedWidget());
+ legacy_hwnd_->SetBounds(window_->GetBoundsInRootWindow());
+ legacy_hwnd_->Show();
+ } else {
+ // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global
+ // hidden window on the same lines as Windowed plugin windows.
+ legacy_hwnd_->UpdateParent(ui::GetHiddenWindow());
+ legacy_hwnd_->Hide();
+ }
+#endif
+}
+
+#if defined(OS_WIN)
+gfx::NativeViewAccessible
+WebContentsViewAura::GetNativeViewAccessible() {
+ BrowserAccessibilityManager* manager =
+ web_contents_->GetRootBrowserAccessibilityManager();
+ if (!manager)
+ return nullptr;
+
+ return manager->GetRoot()->ToBrowserAccessibilityWin();
}
+#endif
} // namespace content