summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-04 19:26:13 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-04 19:26:13 +0000
commit68b522563b8dc3c28d66455959915cf23ac6331e (patch)
tree8c4c3217574743efd8f84ac94c1392770bafd06f /chrome/browser/tab_contents
parent872b5045d897456ebcea2fe8a527740d5eab2fd2 (diff)
downloadchromium_src-68b522563b8dc3c28d66455959915cf23ac6331e.zip
chromium_src-68b522563b8dc3c28d66455959915cf23ac6331e.tar.gz
chromium_src-68b522563b8dc3c28d66455959915cf23ac6331e.tar.bz2
Adds a TabContentsViewAura.
It is derived from TCVV/NTCVA. Right now, it's behind the flag --enable-tcva. http://crbug.com/118410 TEST=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=130442 Review URL: https://chromiumcodereview.appspot.com/9963079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.cc16
-rw-r--r--chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.h5
-rw-r--r--chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.cc (renamed from chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.cc)47
-rw-r--r--chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h (renamed from chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.h)19
4 files changed, 63 insertions, 24 deletions
diff --git a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.cc b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.cc
index ac69b79..f528182 100644
--- a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.cc
+++ b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.cc
@@ -24,6 +24,22 @@ content::WebDragDestDelegate*
return bookmark_handler_.get();
}
+void ChromeWebContentsViewDelegateAura::StoreFocus() {
+}
+
+void ChromeWebContentsViewDelegateAura::RestoreFocus() {
+}
+
+bool ChromeWebContentsViewDelegateAura::Focus() {
+ return false;
+}
+
+void ChromeWebContentsViewDelegateAura::TakeFocus(bool reverse) {
+}
+
void ChromeWebContentsViewDelegateAura::ShowContextMenu(
const content::ContextMenuParams& params) {
}
+
+void ChromeWebContentsViewDelegateAura::SizeChanged(const gfx::Size& size) {
+}
diff --git a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.h b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.h
index 0a152da..99e7b05 100644
--- a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.h
+++ b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_aura.h
@@ -28,8 +28,13 @@ class ChromeWebContentsViewDelegateAura
// Overridden from WebContentsViewDelegate:
virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
+ virtual void StoreFocus() OVERRIDE;
+ virtual void RestoreFocus() OVERRIDE;
+ virtual bool Focus() OVERRIDE;
+ virtual void TakeFocus(bool reverse) OVERRIDE;
virtual void ShowContextMenu(
const content::ContextMenuParams& params) OVERRIDE;
+ virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
private:
content::WebContents* web_contents_;
diff --git a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.cc b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.cc
index 802de7c..bfef3c8 100644
--- a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.cc
+++ b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.h"
+#include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h"
#include "chrome/browser/browser_shutdown.h"
-#include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/sad_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -20,14 +19,21 @@
#include "ui/views/focus/view_storage.h"
#include "ui/views/widget/widget.h"
-ChromeWebContentsViewDelegateWin::ChromeWebContentsViewDelegateWin(
+#if defined(USE_AURA)
+#include "chrome/browser/tab_contents/web_drag_bookmark_handler_aura.h"
+#include "ui/aura/window.h"
+#else
+#include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
+#endif
+
+ChromeWebContentsViewDelegateViews::ChromeWebContentsViewDelegateViews(
content::WebContents* web_contents)
: web_contents_(web_contents) {
last_focused_view_storage_id_ =
views::ViewStorage::GetInstance()->CreateStorageID();
}
-ChromeWebContentsViewDelegateWin::~ChromeWebContentsViewDelegateWin() {
+ChromeWebContentsViewDelegateViews::~ChromeWebContentsViewDelegateViews() {
// Makes sure to remove any stored view we may still have in the ViewStorage.
//
// It is possible the view went away before us, so we only do this if the
@@ -39,14 +45,18 @@ ChromeWebContentsViewDelegateWin::~ChromeWebContentsViewDelegateWin() {
}
content::WebDragDestDelegate*
- ChromeWebContentsViewDelegateWin::GetDragDestDelegate() {
+ ChromeWebContentsViewDelegateViews::GetDragDestDelegate() {
// We install a chrome specific handler to intercept bookmark drags for the
// bookmark manager/extension API.
+#if defined(USE_AURA)
+ bookmark_handler_.reset(new WebDragBookmarkHandlerAura);
+#else
bookmark_handler_.reset(new WebDragBookmarkHandlerWin);
+#endif
return bookmark_handler_.get();
}
-bool ChromeWebContentsViewDelegateWin::Focus() {
+bool ChromeWebContentsViewDelegateViews::Focus() {
TabContentsWrapper* wrapper =
TabContentsWrapper::GetCurrentWrapperForContents(web_contents_);
if (wrapper) {
@@ -71,11 +81,11 @@ bool ChromeWebContentsViewDelegateWin::Focus() {
return false;
}
-void ChromeWebContentsViewDelegateWin::TakeFocus(bool reverse) {
+void ChromeWebContentsViewDelegateViews::TakeFocus(bool reverse) {
GetFocusManager()->AdvanceFocus(reverse);
}
-void ChromeWebContentsViewDelegateWin::StoreFocus() {
+void ChromeWebContentsViewDelegateViews::StoreFocus() {
views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
@@ -88,7 +98,7 @@ void ChromeWebContentsViewDelegateWin::StoreFocus() {
view_storage->StoreView(last_focused_view_storage_id_, focused_view);
}
-void ChromeWebContentsViewDelegateWin::RestoreFocus() {
+void ChromeWebContentsViewDelegateViews::RestoreFocus() {
views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
views::View* last_focused_view =
view_storage->RetrieveView(last_focused_view_storage_id_);
@@ -111,7 +121,7 @@ void ChromeWebContentsViewDelegateWin::RestoreFocus() {
}
}
-void ChromeWebContentsViewDelegateWin::ShowContextMenu(
+void ChromeWebContentsViewDelegateViews::ShowContextMenu(
const content::ContextMenuParams& params) {
context_menu_.reset(new RenderViewContextMenuViews(web_contents_, params));
context_menu_->Init();
@@ -122,9 +132,15 @@ void ChromeWebContentsViewDelegateWin::ShowContextMenu(
gfx::Point screen_point(params.x, params.y);
+#if defined(USE_AURA)
+ gfx::Point view_origin =
+ web_contents_->GetView()->GetNativeView()->GetScreenBounds().origin();
+ screen_point.Offset(view_origin.x(), view_origin.y());
+#else
POINT temp = screen_point.ToPOINT();
ClientToScreen(web_contents_->GetView()->GetNativeView(), &temp);
screen_point = temp;
+#endif
// Enable recursive tasks on the message loop so we can get updates while
// the context menu is being displayed.
@@ -132,7 +148,7 @@ void ChromeWebContentsViewDelegateWin::ShowContextMenu(
context_menu_->RunMenuAt(GetTopLevelWidget(), screen_point);
}
-void ChromeWebContentsViewDelegateWin::SizeChanged(const gfx::Size& size) {
+void ChromeWebContentsViewDelegateViews::SizeChanged(const gfx::Size& size) {
TabContentsWrapper* wrapper =
TabContentsWrapper::GetCurrentWrapperForContents(web_contents_);
if (!wrapper)
@@ -142,20 +158,21 @@ void ChromeWebContentsViewDelegateWin::SizeChanged(const gfx::Size& size) {
sad_tab->SetBounds(gfx::Rect(size));
}
-views::Widget* ChromeWebContentsViewDelegateWin::GetTopLevelWidget() {
- HWND top_level_window = web_contents_->GetView()->GetTopLevelNativeWindow();
+views::Widget* ChromeWebContentsViewDelegateViews::GetTopLevelWidget() {
+ gfx::NativeWindow top_level_window =
+ web_contents_->GetView()->GetTopLevelNativeWindow();
if (!top_level_window)
return NULL;
return views::Widget::GetWidgetForNativeWindow(top_level_window);
}
views::FocusManager*
- ChromeWebContentsViewDelegateWin::GetFocusManager() {
+ ChromeWebContentsViewDelegateViews::GetFocusManager() {
views::Widget* toplevel_widget = GetTopLevelWidget();
return toplevel_widget ? toplevel_widget->GetFocusManager() : NULL;
}
-void ChromeWebContentsViewDelegateWin::SetInitialFocus() {
+void ChromeWebContentsViewDelegateViews::SetInitialFocus() {
if (web_contents_->FocusLocationBarByDefault()) {
web_contents_->SetFocusToLocationBar(false);
} else {
diff --git a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.h b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h
index a573372..cbf6486 100644
--- a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.h
+++ b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_WIN_H_
-#define CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_WIN_H_
+#ifndef CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
+#define CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
#pragma once
#include "base/basictypes.h"
@@ -13,10 +13,10 @@
class ConstrainedWindowViews;
class RenderViewContextMenuViews;
-class WebDragBookmarkHandlerWin;
namespace content {
class WebContents;
+class WebDragDestDelegate;
}
namespace views {
@@ -26,11 +26,12 @@ class Widget;
// A chrome specific class that extends TabContentsViewWin with features like
// constrained windows, which live in chrome.
-class ChromeWebContentsViewDelegateWin
+class ChromeWebContentsViewDelegateViews
: public content::WebContentsViewDelegate {
public:
- explicit ChromeWebContentsViewDelegateWin(content::WebContents* web_contents);
- virtual ~ChromeWebContentsViewDelegateWin();
+ explicit ChromeWebContentsViewDelegateViews(
+ content::WebContents* web_contents);
+ virtual ~ChromeWebContentsViewDelegateViews();
// Overridden from WebContentsViewDelegate:
virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
@@ -55,11 +56,11 @@ class ChromeWebContentsViewDelegateWin
scoped_ptr<RenderViewContextMenuViews> context_menu_;
// The chrome specific delegate that receives events from WebDragDest.
- scoped_ptr<WebDragBookmarkHandlerWin> bookmark_handler_;
+ scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
content::WebContents* web_contents_;
- DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateWin);
+ DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
};
-#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_WIN_H_
+#endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_