diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-09 20:20:47 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-09 20:20:47 +0000 |
commit | d50cca412ec42dd9ccbc33cc38d1f7021a54b4fb (patch) | |
tree | 6cd4024bd99e5508b5e8226758924c1973210664 /chrome/browser/tab_contents | |
parent | c3826037cbcb22fe784a10589061eaf084818727 (diff) | |
download | chromium_src-d50cca412ec42dd9ccbc33cc38d1f7021a54b4fb.zip chromium_src-d50cca412ec42dd9ccbc33cc38d1f7021a54b4fb.tar.gz chromium_src-d50cca412ec42dd9ccbc33cc38d1f7021a54b4fb.tar.bz2 |
Switch from HWNDs to NativeViews.
Review URL: http://codereview.chromium.org/21143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu_controller.cc | 25 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 28 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents.cc | 8 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents.h | 6 |
6 files changed, 42 insertions, 40 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 3351684..9c4ea0e 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -214,8 +214,8 @@ RenderViewHost* InterstitialPage::CreateRenderViewHost() { RenderWidgetHostViewWin* view = new RenderWidgetHostViewWin(render_view_host); render_view_host->set_view(view); - view->Create(tab_->GetContentHWND()); - view->set_parent_hwnd(tab_->GetContentHWND()); + view->Create(tab_->GetContentNativeView()); + view->set_parent_hwnd(tab_->GetContentNativeView()); WebContentsViewWin* web_contents_view = static_cast<WebContentsViewWin*>(tab_->view()); render_view_host->CreateRenderView(); diff --git a/chrome/browser/tab_contents/render_view_context_menu_controller.cc b/chrome/browser/tab_contents/render_view_context_menu_controller.cc index 7a43ff3..d1fdc46 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_controller.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_controller.cc @@ -345,10 +345,11 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: { NavigationEntry* nav_entry = source_web_contents_->controller()->GetActiveEntry(); - PageInfoWindow::CreatePageInfo(source_web_contents_->profile(), - nav_entry, - source_web_contents_->GetContentHWND(), - PageInfoWindow::SECURITY); + PageInfoWindow::CreatePageInfo( + source_web_contents_->profile(), + nav_entry, + source_web_contents_->GetContentNativeView(), + PageInfoWindow::SECURITY); break; } @@ -392,11 +393,12 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { ssl.set_cert_status(cert_status); ssl.set_security_bits(security_bits); } - PageInfoWindow::CreateFrameInfo(source_web_contents_->profile(), - params_.frame_url, - ssl, - source_web_contents_->GetContentHWND(), - PageInfoWindow::SECURITY); + PageInfoWindow::CreateFrameInfo( + source_web_contents_->profile(), + params_.frame_url, + ssl, + source_web_contents_->GetContentNativeView(), + PageInfoWindow::SECURITY); break; } @@ -461,8 +463,9 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { FontsLanguagesWindowView* window_ = new FontsLanguagesWindowView( source_web_contents_->profile()); - views::Window::CreateChromeWindow(source_web_contents_->GetContentHWND(), - gfx::Rect(), window_)->Show(); + views::Window::CreateChromeWindow( + source_web_contents_->GetContentNativeView(), + gfx::Rect(), window_)->Show(); window_->SelectLanguagesTab(); break; } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 6db2c86..a6287bc 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -106,8 +106,8 @@ void TabContents::Destroy() { // If we still have a window handle, destroy it. GetContainerHWND can return // NULL if this contents was part of a window that closed. - if (GetContainerHWND()) - ::DestroyWindow(GetContainerHWND()); + if (GetNativeView()) + ::DestroyWindow(GetNativeView()); // Notify our NavigationController. Make sure we are deleted first, so // that the controller is the last to die. @@ -244,7 +244,7 @@ void TabContents::DidBecomeSelected() { controller_->SetActive(true); // Invalidate all descendants. (take care to exclude invalidating ourselves!) - EnumChildWindows(GetContainerHWND(), InvalidateWindow, 0); + EnumChildWindows(GetNativeView(), InvalidateWindow, 0); } void TabContents::WasHidden() { @@ -311,7 +311,7 @@ void TabContents::AddConstrainedPopup(TabContents* new_contents, const gfx::Rect& initial_pos) { if (!blocked_popups_) { CRect client_rect; - GetClientRect(GetContainerHWND(), &client_rect); + GetClientRect(GetNativeView(), &client_rect); gfx::Point anchor_position( client_rect.Width() - views::NativeScrollBar::GetVerticalScrollBarWidth(), @@ -332,7 +332,7 @@ void TabContents::CloseAllSuppressedPopups() { } void TabContents::Focus() { - HWND container_hwnd = GetContainerHWND(); + HWND container_hwnd = GetNativeView(); if (!container_hwnd) return; @@ -353,7 +353,7 @@ void TabContents::StoreFocus() { view_storage->RemoveView(last_focused_view_storage_id_); views::FocusManager* focus_manager = - views::FocusManager::GetFocusManager(GetContainerHWND()); + views::FocusManager::GetFocusManager(GetNativeView()); if (focus_manager) { // |focus_manager| can be NULL if the tab has been detached but still // exists. @@ -364,7 +364,7 @@ void TabContents::StoreFocus() { // If the focus was on the page, explicitly clear the focus so that we // don't end up with the focused HWND not part of the window hierarchy. // TODO(brettw) this should move to the view somehow. - HWND container_hwnd = GetContainerHWND(); + HWND container_hwnd = GetNativeView(); if (container_hwnd) { views::View* focused_view = focus_manager->GetFocusedView(); if (focused_view) { @@ -386,7 +386,7 @@ void TabContents::RestoreFocus() { SetInitialFocus(); } else { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManager(GetContainerHWND()); + views::FocusManager::GetFocusManager(GetNativeView()); // If you hit this DCHECK, please report it to Jay (jcampan). DCHECK(focus_manager != NULL) << "No focus manager when restoring focus."; @@ -404,7 +404,7 @@ void TabContents::RestoreFocus() { } void TabContents::SetInitialFocus() { - ::SetFocus(GetContainerHWND()); + ::SetFocus(GetNativeView()); } void TabContents::AddInfoBar(InfoBarDelegate* delegate) { @@ -489,8 +489,8 @@ void TabContents::OnStartDownload(DownloadItem* download) { // This animation will delete itself when it finishes, or if we become hidden // or destroyed. - if (IsWindowVisible(GetContainerHWND())) { // For minimized windows, unit - // tests, etc. + if (IsWindowVisible(GetNativeView())) { // For minimized windows, unit + // tests, etc. new DownloadStartedAnimation(tab_contents); } } @@ -519,16 +519,16 @@ void TabContents::WillClose(ConstrainedWindow* window) { if (window == blocked_popups_) blocked_popups_ = NULL; - if (::IsWindow(GetContainerHWND())) { + if (::IsWindow(GetNativeView())) { CRect client_rect; - GetClientRect(GetContainerHWND(), &client_rect); + GetClientRect(GetNativeView(), &client_rect); RepositionSupressedPopupsToFit( gfx::Size(client_rect.Width(), client_rect.Height())); } } void TabContents::DidMoveOrResize(ConstrainedWindow* window) { - UpdateWindow(GetContainerHWND()); + UpdateWindow(GetNativeView()); } void TabContents::Observe(NotificationType type, diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index b23c8d5..59ad1ae 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "chrome/browser/autocomplete/autocomplete_edit.h" #include "chrome/browser/tab_contents/constrained_window.h" @@ -343,17 +344,17 @@ class TabContents : public PageNavigator, // Views and focus ----------------------------------------------------------- // Returns the actual window that is focused when this TabContents is shown. - virtual HWND GetContentHWND() { - return GetContainerHWND(); + virtual gfx::NativeView GetContentNativeView() { + return GetNativeView(); } // Tell the subclass to set up the view (e.g. create the container HWND if // applicable) and any other create-time setup. virtual void CreateView() {} - // Returns the HWND associated with this TabContents. Outside of automation - // in the context of the UI, this is required to be implemented. - virtual HWND GetContainerHWND() const { return NULL; } + // Returns the NativeView associated with this TabContents. Outside of + // automation in the context of the UI, this is required to be implemented. + virtual gfx::NativeView GetNativeView() const { return NULL; } // Returns the bounds of this TabContents in the screen coordinate system. virtual void GetContainerBounds(gfx::Rect *out) const { diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index 44ab59b..6df85ac 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -499,17 +499,17 @@ void WebContents::CreateView() { view_->CreateView(); } -#if defined(OS_WIN) -HWND WebContents::GetContainerHWND() const { +gfx::NativeView WebContents::GetNativeView() const { return view_->GetNativeView(); } -HWND WebContents::GetContentHWND() { + +gfx::NativeView WebContents::GetContentNativeView() { return view_->GetContentNativeView(); } + void WebContents::GetContainerBounds(gfx::Rect *out) const { view_->GetContainerBounds(out); } -#endif void WebContents::CreateShortcut() { NavigationEntry* entry = controller()->GetLastCommittedEntry(); diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h index 2f3044b..bd1c2ce 100644 --- a/chrome/browser/tab_contents/web_contents.h +++ b/chrome/browser/tab_contents/web_contents.h @@ -132,11 +132,9 @@ class WebContents : public TabContents, // TODO(brettw) fix this, tab contents shouldn't have these methods, probably // it should be killed altogether. virtual void CreateView(); -#if defined(OS_WIN) - virtual HWND GetContainerHWND() const; - virtual HWND GetContentHWND(); + virtual gfx::NativeView GetNativeView() const; + virtual gfx::NativeView GetContentNativeView(); virtual void GetContainerBounds(gfx::Rect *out) const; -#endif // Web apps ------------------------------------------------------------------ |