summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 20:14:45 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 20:14:45 +0000
commitef85d47f1a76de6a2832607b7d80c45b5c662e65 (patch)
treeb8a40f567be4abbe9f611ac4b9d9a509573c70de
parent90b59b78afc61c68536a30afb526628c2891731b (diff)
downloadchromium_src-ef85d47f1a76de6a2832607b7d80c45b5c662e65.zip
chromium_src-ef85d47f1a76de6a2832607b7d80c45b5c662e65.tar.gz
chromium_src-ef85d47f1a76de6a2832607b7d80c45b5c662e65.tar.bz2
Make WebContentsView portable by using the native view types.
Review URL: http://codereview.chromium.org/19632 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8819 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/build/base_gfx.vcproj12
-rw-r--r--chrome/browser/tab_contents/web_contents.cc11
-rw-r--r--chrome/browser/tab_contents/web_contents_view.h22
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.cc21
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.h4
-rw-r--r--chrome/browser/views/find_bar_win.cc5
6 files changed, 40 insertions, 35 deletions
diff --git a/base/build/base_gfx.vcproj b/base/build/base_gfx.vcproj
index b19945a..998fcb0 100644
--- a/base/build/base_gfx.vcproj
+++ b/base/build/base_gfx.vcproj
@@ -122,19 +122,19 @@
</References>
<Files>
<File
- RelativePath="..\gfx\jpeg_codec.cc"
+ RelativePath="..\gfx\gdi_util.cc"
>
</File>
<File
- RelativePath="..\gfx\jpeg_codec.h"
+ RelativePath="..\gfx\gdi_util.h"
>
</File>
<File
- RelativePath="..\gfx\gdi_util.cc"
+ RelativePath="..\gfx\jpeg_codec.cc"
>
</File>
<File
- RelativePath="..\gfx\gdi_util.h"
+ RelativePath="..\gfx\jpeg_codec.h"
>
</File>
<File
@@ -146,6 +146,10 @@
>
</File>
<File
+ RelativePath="..\gfx\native_widget_types.h"
+ >
+ </File>
+ <File
RelativePath="..\gfx\png_decoder.cc"
>
</File>
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index cf36173..5c2fdb2 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -494,10 +494,10 @@ void WebContents::CreateView() {
view_->CreateView();
}
HWND WebContents::GetContainerHWND() const {
- return view_->GetContainerHWND();
+ return view_->GetNativeView();
}
HWND WebContents::GetContentHWND() {
- return view_->GetContentHWND();
+ return view_->GetContentNativeView();
}
void WebContents::GetContainerBounds(gfx::Rect *out) const {
view_->GetContainerBounds(out);
@@ -573,8 +573,8 @@ void WebContents::OnSavePage() {
// TODO(rocking): Use new asynchronous dialog boxes to prevent the SaveAs
// dialog blocking the UI thread. See bug: http://b/issue?id=1129694.
- if (SavePackage::GetSaveInfo(suggest_name, GetContainerHWND(), &param,
- profile()->GetDownloadManager()))
+ if (SavePackage::GetSaveInfo(suggest_name, view_->GetNativeView(),
+ &param, profile()->GetDownloadManager()))
SavePage(param.saved_main_file_path, param.dir, param.save_type);
}
@@ -997,6 +997,7 @@ void WebContents::RunFileChooser(bool multiple_files,
const std::wstring& title,
const std::wstring& default_file,
const std::wstring& filter) {
+ // TODO(brettw) move this to the view.
HWND toplevel_hwnd = GetAncestor(GetContainerHWND(), GA_ROOT);
if (!select_file_dialog_.get())
select_file_dialog_ = SelectFileDialog::Create(this);
@@ -1144,7 +1145,7 @@ void WebContents::PageHasOSDD(RenderViewHost* render_view_host,
keyword,
url,
base_entry->favicon().url(),
- GetAncestor(view_->GetContainerHWND(), GA_ROOT),
+ GetAncestor(view_->GetNativeView(), GA_ROOT),
autodetected);
}
diff --git a/chrome/browser/tab_contents/web_contents_view.h b/chrome/browser/tab_contents/web_contents_view.h
index 12f4ab8..ab7ae97 100644
--- a/chrome/browser/tab_contents/web_contents_view.h
+++ b/chrome/browser/tab_contents/web_contents_view.h
@@ -5,12 +5,11 @@
#ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_VIEW_H_
#define CHROME_BROWSER_TAB_CONTENTS_WEB_CONTENTS_VIEW_H_
-#include <windows.h>
-
#include <map>
#include <string>
#include "base/basictypes.h"
+#include "base/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
#include "base/gfx/size.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -50,15 +49,13 @@ class WebContentsView : public RenderViewHostDelegate::View {
virtual RenderWidgetHostViewWin* CreateViewForWidget(
RenderWidgetHost* render_widget_host) = 0;
- // Returns the HWND that contains the contents of the tab.
- // TODO(brettw) this should not be necessary in this cross-platform interface.
- virtual HWND GetContainerHWND() const = 0;
+ // Returns the native widget that contains the contents of the tab.
+ virtual gfx::NativeView GetNativeView() const = 0;
- // Returns the HWND with the main content of the tab (i.e. the main render
- // view host, though there may be many popups in the tab as children of the
- // container HWND).
- // TODO(brettw) this should not be necessary in this cross-platform interface.
- virtual HWND GetContentHWND() const = 0;
+ // Returns the native widget with the main content of the tab (i.e. the main
+ // render view host, though there may be many popups in the tab as children of
+ // the container).
+ virtual gfx::NativeView GetContentNativeView() const = 0;
// Computes the rectangle for the native widget that contains the contents of
// the tab relative to its parent.
@@ -156,8 +153,9 @@ class WebContentsView : public RenderViewHostDelegate::View {
// created objects so that they can be associated with the given routes. When
// they are shown later, we'll look them up again and pass the objects to
// the Show functions rather than the route ID.
- virtual WebContents* CreateNewWindowInternal
- (int route_id, base::WaitableEvent* modal_dialog_event) = 0;
+ virtual WebContents* CreateNewWindowInternal(
+ int route_id,
+ base::WaitableEvent* modal_dialog_event) = 0;
virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id,
bool activatable) = 0;
virtual void ShowCreatedWindowInternal(WebContents* new_web_contents,
diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc
index ee69af7..2c0ea3e 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.cc
+++ b/chrome/browser/tab_contents/web_contents_view_win.cc
@@ -73,11 +73,11 @@ RenderWidgetHostViewWin* WebContentsViewWin::CreateViewForWidget(
return view;
}
-HWND WebContentsViewWin::GetContainerHWND() const {
+gfx::NativeView WebContentsViewWin::GetNativeView() const {
return GetHWND();
}
-HWND WebContentsViewWin::GetContentHWND() const {
+gfx::NativeView WebContentsViewWin::GetContentNativeView() const {
if (!web_contents_->render_widget_host_view())
return NULL;
return web_contents_->render_widget_host_view()->GetPluginHWND();
@@ -172,9 +172,9 @@ void WebContentsViewWin::OnDestroy() {
}
void WebContentsViewWin::SetPageTitle(const std::wstring& title) {
- if (GetContainerHWND()) {
+ if (GetNativeView()) {
// It's possible to get this after the hwnd has been destroyed.
- ::SetWindowText(GetContainerHWND(), title.c_str());
+ ::SetWindowText(GetNativeView(), title.c_str());
// TODO(brettw) this call seems messy the way it reaches into the widget
// view, and I'm not sure it's necessary. Maybe we should just remove it.
::SetWindowText(web_contents_->render_widget_host_view()->GetPluginHWND(),
@@ -184,8 +184,8 @@ void WebContentsViewWin::SetPageTitle(const std::wstring& title) {
void WebContentsViewWin::Invalidate() {
// Note that it's possible to get this message after the window was destroyed.
- if (::IsWindow(GetContainerHWND()))
- InvalidateRect(GetContainerHWND(), NULL, FALSE);
+ if (::IsWindow(GetNativeView()))
+ InvalidateRect(GetNativeView(), NULL, FALSE);
}
void WebContentsViewWin::SizeContents(const gfx::Size& size) {
@@ -245,7 +245,7 @@ void WebContentsViewWin::UpdateDragCursor(bool is_drop_target) {
void WebContentsViewWin::TakeFocus(bool reverse) {
views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(GetContainerHWND());
+ views::FocusManager::GetFocusManager(GetNativeView());
// We may not have a focus manager if the tab has been switched before this
// message arrived.
@@ -415,7 +415,7 @@ void WebContentsViewWin::ShowCreatedWidgetInternal(
// This logic should be implemented by RenderWidgetHostHWND (as mentioned
// above) in the ::Init function, which should take a parent and some initial
// bounds.
- widget_host_view_win->Create(GetContainerHWND(), NULL, NULL,
+ widget_host_view_win->Create(GetNativeView(), NULL, NULL,
WS_POPUP, WS_EX_TOOLWINDOW);
widget_host_view_win->MoveWindow(initial_pos.x(), initial_pos.y(),
initial_pos.width(), initial_pos.height(),
@@ -589,8 +589,9 @@ void WebContentsViewWin::ScrollCommon(UINT message, int scroll_type,
if (!ScrollZoom(scroll_type)) {
// Reflect scroll message to the view() to give it a chance
// to process scrolling.
- SendMessage(GetContentHWND(), message, MAKELONG(scroll_type, position),
- (LPARAM) scrollbar);
+ SendMessage(GetContentNativeView(), message,
+ MAKELONG(scroll_type, position),
+ reinterpret_cast<LPARAM>(scrollbar));
}
}
diff --git a/chrome/browser/tab_contents/web_contents_view_win.h b/chrome/browser/tab_contents/web_contents_view_win.h
index b44809b..2658fb6 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.h
+++ b/chrome/browser/tab_contents/web_contents_view_win.h
@@ -32,8 +32,8 @@ class WebContentsViewWin : public WebContentsView,
virtual void CreateView();
virtual RenderWidgetHostViewWin* CreateViewForWidget(
RenderWidgetHost* render_widget_host);
- virtual HWND GetContainerHWND() const;
- virtual HWND GetContentHWND() const;
+ virtual gfx::NativeView GetNativeView() const;
+ virtual gfx::NativeView GetContentNativeView() const;
virtual void GetContainerBounds(gfx::Rect* out) const;
virtual void OnContentsDestroy();
virtual void SetPageTitle(const std::wstring& title);
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index d58cf6c..e85bd3e 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -468,7 +468,8 @@ void FindBarWin::GetDialogBounds(gfx::Rect* bounds) {
// fails, we return an empty rect.
CRect browser_client_rect, browser_window_rect, content_window_rect;
if (!::IsWindow(parent_hwnd_) ||
- !::GetWindowRect(parent_tab_->GetContentHWND(), &content_window_rect) ||
+ !::GetWindowRect(parent_tab_->GetContentNativeView(),
+ &content_window_rect) ||
!::GetWindowRect(parent_hwnd_, &browser_window_rect) ||
!::GetClientRect(parent_hwnd_, &browser_client_rect) ||
!toolbar) {
@@ -589,7 +590,7 @@ gfx::Rect FindBarWin::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
// whereas the selection rect is relative to the page.
RECT frame_rect = {0}, webcontents_rect = {0};
::GetWindowRect(parent_hwnd_, &frame_rect);
- ::GetWindowRect(parent_tab_->GetContainerHWND(), &webcontents_rect);
+ ::GetWindowRect(parent_tab_->GetNativeView(), &webcontents_rect);
avoid_overlapping_rect.Offset(0, webcontents_rect.top - frame_rect.top);
}