summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 19:06:50 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 19:06:50 +0000
commit6eb7e132a6222068366e50a95a62281ebcbcfeb2 (patch)
treec1150002f4932f279d8d934de598b7f546ec52cc
parent4978bacf0e1b64f470eaaf828702bdbd84859d9f (diff)
downloadchromium_src-6eb7e132a6222068366e50a95a62281ebcbcfeb2.zip
chromium_src-6eb7e132a6222068366e50a95a62281ebcbcfeb2.tar.gz
chromium_src-6eb7e132a6222068366e50a95a62281ebcbcfeb2.tar.bz2
Renames BrowserView::GetBrowserViewForHWND to
GetBrowserViewForNativeView and implements the GTK side. I could have went with NativeWindow here, but we end up with more flexibility if we keep this as NativeView. BUG=none TEST=none Review URL: http://codereview.chromium.org/113842 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16882 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_focus_uitest.cc22
-rw-r--r--chrome/browser/dock_info_win.cc2
-rw-r--r--chrome/browser/views/browser_bubble_win.cc6
-rw-r--r--chrome/browser/views/frame/browser_view.cc21
-rw-r--r--chrome/browser/views/frame/browser_view.h9
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc2
6 files changed, 38 insertions, 24 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 17946e0..a452e5f 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -105,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
// The focus should be on the Tab contents.
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
ASSERT_TRUE(browser_view);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
@@ -145,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
ui_test_utils::NavigateToURL(browser2, url);
HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle());
- BrowserView* browser_view2 = BrowserView::GetBrowserViewForHWND(hwnd2);
+ BrowserView* browser_view2 = BrowserView::GetBrowserViewForNativeView(hwnd2);
ASSERT_TRUE(browser_view2);
views::FocusManager* focus_manager2 =
views::FocusManager::GetFocusManager(hwnd2);
@@ -178,7 +178,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
ASSERT_TRUE(browser_view);
views::FocusManager* focus_manager =
@@ -254,13 +254,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
// Make sure the first browser is still active.
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
ASSERT_TRUE(browser_view);
EXPECT_TRUE(browser_view->frame()->GetWindow()->IsActive());
// Close the 2nd browser to avoid a DCHECK().
HWND hwnd2 = reinterpret_cast<HWND>(browser2->window()->GetNativeHandle());
- BrowserView* browser_view2 = BrowserView::GetBrowserViewForHWND(hwnd2);
+ BrowserView* browser_view2 = BrowserView::GetBrowserViewForNativeView(hwnd2);
browser_view2->Close();
}
@@ -273,7 +273,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
@@ -301,7 +301,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
@@ -391,7 +391,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversalOnInterstitial) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
@@ -486,7 +486,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
@@ -531,7 +531,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
ui_test_utils::NavigateToURL(browser(), url);
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
LocationBarView* location_bar = browser_view->GetLocationBarView();
@@ -602,7 +602,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
// types of tabs.
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeView(hwnd);
ASSERT_TRUE(browser_view);
views::FocusManager* focus_manager =
views::FocusManager::GetFocusManager(hwnd);
diff --git a/chrome/browser/dock_info_win.cc b/chrome/browser/dock_info_win.cc
index 1eb7633..72241a4 100644
--- a/chrome/browser/dock_info_win.cc
+++ b/chrome/browser/dock_info_win.cc
@@ -195,7 +195,7 @@ class DockToWindowFinder : public BaseWindowFinder {
protected:
virtual bool ShouldStopIterating(HWND hwnd) {
- BrowserView* window = BrowserView::GetBrowserViewForHWND(hwnd);
+ BrowserView* window = BrowserView::GetBrowserViewForNativeView(hwnd);
CRect bounds;
if (!window || !::IsWindowVisible(hwnd) ||
!::GetWindowRect(hwnd, &bounds)) {
diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc
index 7471baa..1adb229 100644
--- a/chrome/browser/views/browser_bubble_win.cc
+++ b/chrome/browser/views/browser_bubble_win.cc
@@ -22,7 +22,8 @@ void BrowserBubble::InitPopup() {
popup_.reset(pop);
Reposition();
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(native_view);
+ BrowserView* browser_view =
+ BrowserView::GetBrowserViewForNativeView(native_view);
DCHECK(browser_view);
if (browser_view)
browser_view->AttachBrowserBubble(this);
@@ -30,7 +31,8 @@ void BrowserBubble::InitPopup() {
void BrowserBubble::DestroyPopup() {
gfx::NativeView native_view = frame_->GetNativeView();
- BrowserView* browser_view = BrowserView::GetBrowserViewForHWND(native_view);
+ BrowserView* browser_view =
+ BrowserView::GetBrowserViewForNativeView(native_view);
if (browser_view)
browser_view->DetachBrowserBubble(this);
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index b2bfaf2..af38dd7 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/views/frame/browser_view.h"
+#if defined(OS_LINUX)
+#include <gtk/gtk.h>
+#endif
+
#include "app/drag_drop_types.h"
#include "app/gfx/canvas.h"
#include "app/l10n_util.h"
@@ -291,17 +295,22 @@ BrowserView::~BrowserView() {
ticker_.UnregisterTickHandler(&hung_window_detector_);
}
-#if defined(OS_WIN)
// static
-BrowserView* BrowserView::GetBrowserViewForHWND(HWND window) {
+BrowserView* BrowserView::GetBrowserViewForNativeView(gfx::NativeView window) {
+#if defined(OS_WIN)
if (IsWindow(window)) {
HANDLE data = GetProp(window, kBrowserViewKey);
if (data)
return reinterpret_cast<BrowserView*>(data);
}
+#else
+ if (window) {
+ return reinterpret_cast<BrowserView*>(
+ g_object_set_data(G_OBJECT(window), kBrowserViewKey, this));
+ }
+#endif
return NULL;
}
-#endif
int BrowserView::GetShowState() const {
if (explicit_show_state != -1)
@@ -1251,8 +1260,12 @@ void BrowserView::ChildPreferredSizeChanged(View* child) {
void BrowserView::Init() {
// Stow a pointer to this object onto the window handle so that we can get
- // at it later when all we have is a HWND.
+ // at it later when all we have is a native view.
+#if defined(OS_WIN)
SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this);
+#else
+ g_object_set_data(G_OBJECT(GetWidget()->GetNativeView()), kBrowserViewKey, this);
+#endif
// Start a hung plugin window detector for this browser object (as long as
// hang detection is not disabled).
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index f230ecf..13f8591 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -7,6 +7,7 @@
#include <set>
+#include "base/gfx/native_widget_types.h"
#include "build/build_config.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
@@ -64,12 +65,10 @@ class BrowserView : public BrowserWindow,
void set_frame(BrowserFrame* frame) { frame_ = frame; }
BrowserFrame* frame() const { return frame_; }
-#if defined(OS_WIN)
// Returns a pointer to the BrowserView* interface implementation (an
- // instance of this object, typically) for a given HWND, or NULL if there is
- // no such association.
- static BrowserView* GetBrowserViewForHWND(HWND window);
-#endif
+ // instance of this object, typically) for a given native window, or NULL if
+ // there is no such association.
+ static BrowserView* GetBrowserViewForNativeView(gfx::NativeView window);
// Returns the show flag that should be used to show the frame containing
// this view.
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 8ba91cf..b3ac3bf 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -653,7 +653,7 @@ TabStrip* DraggedTabController::GetTabStripForPoint(
dock_windows_.erase(dragged_view);
if (!local_window)
return NULL;
- BrowserView* browser = BrowserView::GetBrowserViewForHWND(local_window);
+ BrowserView* browser = BrowserView::GetBrowserViewForNativeView(local_window);
if (!browser)
return NULL;