summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 00:58:06 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-05 00:58:06 +0000
commita55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4 (patch)
treef90c20acb5701e17d66fabfce5ca90c827ca9c2e /chrome/browser
parentbd205617c4f7eca4bb28c0343ed2f071189393c3 (diff)
downloadchromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.zip
chromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.tar.gz
chromium_src-a55bfd3d8f23c22003cf6a0754aa320fe7b7d3e4.tar.bz2
Add cross platform Widget::InitWithWidget(parent, const gfx::Rect& bounds);
On linux, native parent has to be either window_contents or widget depending of the type of wiget. InitWithWidget takes a parent Widget instead of native and hides these details. I also cleaned up a few dead/duplicated code. BUG=none TEST=none Review URL: http://codereview.chromium.org/2355003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc10
-rw-r--r--chrome/browser/find_bar_host_browsertest.cc18
-rw-r--r--chrome/browser/views/dropdown_bar_host.cc2
-rw-r--r--chrome/browser/views/dropdown_bar_host.h3
-rw-r--r--chrome/browser/views/dropdown_bar_host_gtk.cc5
-rw-r--r--chrome/browser/views/dropdown_bar_host_win.cc4
-rw-r--r--chrome/browser/views/info_bubble.cc4
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc5
8 files changed, 10 insertions, 41 deletions
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 507f0fe..60540c7 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -181,11 +181,11 @@ void ScreenLocker::Init(const gfx::Rect& bounds) {
lock_widget_ = new GrabWidget();
lock_widget_->MakeTransparent();
- lock_widget_->Init(lock_window_->window_contents(),
- gfx::Rect((bounds.width() - size.width()) /2,
- (bounds.height() - size.width()) /2,
- size.width(),
- size.height()));
+ lock_widget_->InitWithWidget(lock_window_,
+ gfx::Rect((bounds.width() - size.width()) / 2,
+ (bounds.height() - size.width()) / 2,
+ size.width(),
+ size.height()));
lock_widget_->SetContentsView(screen_lock_view_);
lock_widget_->Show();
screen_lock_view_->ClearAndSetFocusToPassword();
diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc
index 2473128..9ffaf72 100644
--- a/chrome/browser/find_bar_host_browsertest.cc
+++ b/chrome/browser/find_bar_host_browsertest.cc
@@ -732,23 +732,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
GURL url = server->TestServerPage(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
-#if defined(OS_WIN)
- // TODO(oshima): Windows code assumes that NativeView is
- // assignable from NativeWindow, which is not true on other platforms.
- // This has to be fixed, probably by having explicit
- // GetNativeView / GetNativewWindow methods on BrowserWindow.
- // See http://crbug.com/26873.
- gfx::NativeView browser_view = browser()->window()->GetNativeHandle();
-#elif defined(OS_LINUX)
- gfx::NativeView browser_view =
- GTK_WIDGET(browser()->window()->GetNativeHandle());
-#else
- // Mac does not use views.
- NOTREACHED();
-#endif
-
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManagerForNativeView(browser_view);
+ views::FocusManager::GetFocusManagerForNativeWindow(
+ browser()->window()->GetNativeHandle());
// See where Escape is registered.
views::Accelerator escape(base::VKEY_ESCAPE, false, false, false);
diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc
index b722979..4878e15 100644
--- a/chrome/browser/views/dropdown_bar_host.cc
+++ b/chrome/browser/views/dropdown_bar_host.cc
@@ -44,7 +44,7 @@ void DropdownBarHost::Init(DropdownBarView* view) {
// Initialize the host.
host_.reset(CreateHost());
- host_->Init(GetNativeView(browser_view_), gfx::Rect());
+ host_->InitWithWidget(browser_view_->GetWidget(), gfx::Rect());
host_->SetContentsView(view_);
// Start listening to focus changes, so we can register and unregister our
diff --git a/chrome/browser/views/dropdown_bar_host.h b/chrome/browser/views/dropdown_bar_host.h
index e77ffa5..8b45f06 100644
--- a/chrome/browser/views/dropdown_bar_host.h
+++ b/chrome/browser/views/dropdown_bar_host.h
@@ -141,9 +141,6 @@ class DropdownBarHost : public views::AcceleratorTarget,
// Allows implementation to tweak widget position.
void SetWidgetPositionNative(const gfx::Rect& new_pos, bool no_redraw);
- // Returns the native view (is a child of the window widget in gtk).
- gfx::NativeView GetNativeView(BrowserView* browser_view);
-
// Returns a keyboard event suitable for fowarding.
NativeWebKeyboardEvent GetKeyboardEvent(
const TabContents* contents,
diff --git a/chrome/browser/views/dropdown_bar_host_gtk.cc b/chrome/browser/views/dropdown_bar_host_gtk.cc
index 751d0d8..2a4e4be 100644
--- a/chrome/browser/views/dropdown_bar_host_gtk.cc
+++ b/chrome/browser/views/dropdown_bar_host_gtk.cc
@@ -24,11 +24,6 @@ void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
host_->Show();
}
-gfx::NativeView DropdownBarHost::GetNativeView(BrowserView* browser_view) {
- return static_cast<views::WidgetGtk*>(
- browser_view->GetWidget())->window_contents();
-}
-
NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
const TabContents* contents,
const views::Textfield::Keystroke& key_stroke) {
diff --git a/chrome/browser/views/dropdown_bar_host_win.cc b/chrome/browser/views/dropdown_bar_host_win.cc
index e5335dd..c14fb21 100644
--- a/chrome/browser/views/dropdown_bar_host_win.cc
+++ b/chrome/browser/views/dropdown_bar_host_win.cc
@@ -46,7 +46,3 @@ void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
::SetWindowPos(host_->GetNativeView(), HWND_TOP, new_pos.x(), new_pos.y(),
new_pos.width(), new_pos.height(), swp_flags);
}
-
-gfx::NativeView DropdownBarHost::GetNativeView(BrowserView* browser_view) {
- return browser_view->GetWidget()->GetNativeView();
-}
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 230fcb6..41907af 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -338,9 +338,7 @@ void InfoBubble::Init(views::Widget* parent,
#elif defined(OS_LINUX)
MakeTransparent();
make_transient_to_parent();
- WidgetGtk::Init(
- GTK_WIDGET(static_cast<WidgetGtk*>(parent)->GetNativeView()),
- gfx::Rect());
+ WidgetGtk::InitWithWidget(parent, gfx::Rect());
#if defined(OS_CHROMEOS)
chromeos::WmIpc::instance()->SetWindowType(
GetNativeView(),
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 857122a..77fb8eb 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -1010,16 +1010,13 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down)
arrow_window->set_window_style(WS_POPUP);
arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE |
WS_EX_LAYERED | WS_EX_TRANSPARENT);
- arrow_window->Init(
- NULL,
- gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height));
#else
arrow_window = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP);
arrow_window->MakeTransparent();
+#endif
arrow_window->Init(
NULL,
gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height));
-#endif
arrow_window->SetContentsView(arrow_view);
}