diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 20:32:06 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 20:32:06 +0000 |
commit | 92edc4764d2f311440929ad4dca91f87be3b2f11 (patch) | |
tree | f4ba410c3fe7612ee830b326739fba05273a59e2 /chrome | |
parent | ea16554e83cab7fe751cac7a0af8eaea3948c512 (diff) | |
download | chromium_src-92edc4764d2f311440929ad4dca91f87be3b2f11.zip chromium_src-92edc4764d2f311440929ad4dca91f87be3b2f11.tar.gz chromium_src-92edc4764d2f311440929ad4dca91f87be3b2f11.tar.bz2 |
Switch from HWNDs to NativeViews, take 2. (First attempt was r9409, in which I missed a file.)
Review URL: http://codereview.chromium.org/20226
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
19 files changed, 64 insertions, 62 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 45ad1b3..b78150a 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1639,7 +1639,7 @@ void AutomationProvider::GetTabHWND(const IPC::Message& message, int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - tab_hwnd = tab->active_contents()->GetContainerHWND(); + tab_hwnd = tab->active_contents()->GetNativeView(); } Send(new AutomationMsg_TabHWNDResponse(message.routing_id(), tab_hwnd)); @@ -2394,7 +2394,7 @@ ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { DCHECK(tab_contents); if (tab_contents) { return ExternalTabContainer::GetContainerForTab( - tab_contents->GetContainerHWND()); + tab_contents->GetNativeView()); } } diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 101179a..d448f0a 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -622,7 +622,7 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) { std::wstring filter = win_util::GetFileFilterFromPath(info->suggested_path.value()); HWND owning_hwnd = - contents ? GetAncestor(contents->GetContainerHWND(), GA_ROOT) : NULL; + contents ? GetAncestor(contents->GetNativeView(), GA_ROOT) : NULL; select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), info->suggested_path.ToWStringHack(), diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 6e1d58e..7b03d4b 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -109,7 +109,7 @@ bool ExternalTabContainer::Init(Profile* profile, HWND parent, // may or may not include the popup bit. ModifyStyle(WS_POPUP, style, 0); - ::ShowWindow(tab_contents_->GetContainerHWND(), SW_SHOW); + ::ShowWindow(tab_contents_->GetNativeView(), SW_SHOW); return true; } @@ -143,7 +143,7 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) { if (tab_contents_) { RECT client_rect = {0}; GetClientRect(&client_rect); - ::SetWindowPos(tab_contents_->GetContainerHWND(), NULL, client_rect.left, + ::SetWindowPos(tab_contents_->GetNativeView(), NULL, client_rect.left, client_rect.top, client_rect.right - client_rect.left, client_rect.bottom - client_rect.top, SWP_NOZORDER); } diff --git a/chrome/browser/jsmessage_box_handler_win.cc b/chrome/browser/jsmessage_box_handler_win.cc index bf586e5..3497838 100644 --- a/chrome/browser/jsmessage_box_handler_win.cc +++ b/chrome/browser/jsmessage_box_handler_win.cc @@ -153,7 +153,7 @@ void JavascriptMessageBoxHandler::ShowModalDialog() { } web_contents_->Activate(); - HWND root_hwnd = GetAncestor(web_contents_->GetContainerHWND(), GA_ROOT); + HWND root_hwnd = GetAncestor(web_contents_->GetNativeView(), GA_ROOT); dialog_ = views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this); dialog_->Show(); } diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index fbc464a..9685a4f 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -216,8 +216,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/native_ui_contents.h b/chrome/browser/tab_contents/native_ui_contents.h index 9f93357..3982f91 100644 --- a/chrome/browser/tab_contents/native_ui_contents.h +++ b/chrome/browser/tab_contents/native_ui_contents.h @@ -39,7 +39,7 @@ class NativeUIContents : public TabContents, explicit NativeUIContents(Profile* profile); virtual void CreateView(); - virtual HWND GetContainerHWND() const { return GetHWND(); } + virtual gfx::NativeView GetNativeView() const { return GetHWND(); } virtual void GetContainerBounds(gfx::Rect* out) const; // Sets the page state. NativeUIContents takes ownership of the supplied 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 0613191..9988091 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_controller.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_controller.cc @@ -353,10 +353,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; } @@ -400,11 +401,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; } @@ -469,8 +471,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..7a9124f 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -104,10 +104,10 @@ void TabContents::Destroy() { Source<TabContents>(this), NotificationService::NoDetails()); - // If we still have a window handle, destroy it. GetContainerHWND can return + // If we still have a window handle, destroy it. GetNativeView 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 ------------------------------------------------------------------ diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index b7cb046..e961a8c 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -450,7 +450,7 @@ void BlockedPopupContainer::Init(const gfx::Point& initial_anchor) { container_view_->SetVisible(true); set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - WidgetWin::Init(owner_->GetContainerHWND(), gfx::Rect(), false); + WidgetWin::Init(owner_->GetNativeView(), gfx::Rect(), false); SetContentsView(container_view_); RepositionConstrainedWindowTo(initial_anchor); diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index fc61153..7d5faa1 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -664,7 +664,7 @@ void ConstrainedWindowImpl::Init(TabContents* owner) { } void ConstrainedWindowImpl::InitAsDialog(const gfx::Rect& initial_bounds) { - CustomFrameWindow::Init(owner_->GetContainerHWND(), initial_bounds); + CustomFrameWindow::Init(owner_->GetNativeView(), initial_bounds); ActivateConstrainedWindow(); } diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc index f6c92a8..226f7b8 100644 --- a/chrome/browser/views/dom_view.cc +++ b/chrome/browser/views/dom_view.cc @@ -32,7 +32,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) { host_ = tab_contents->AsDOMUIHost(); DCHECK(host_); - views::HWNDView::Attach(host_->GetContainerHWND()); + views::HWNDView::Attach(host_->GetNativeView()); host_->SetupController(profile); host_->controller()->LoadURL(contents_, GURL(), PageTransition::START_PAGE); return true; diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation.cc index e09debc..3d91712 100644 --- a/chrome/browser/views/download_started_animation.cc +++ b/chrome/browser/views/download_started_animation.cc @@ -54,7 +54,7 @@ DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents) popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT); popup_->SetLayeredAlpha(0x00); - popup_->Init(tab_contents_->GetContainerHWND(), rc, false); + popup_->Init(tab_contents_->GetNativeView(), rc, false); popup_->SetContentsView(this); Reposition(); popup_->ShowWindow(SW_SHOWNOACTIVATE); diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 594dfbb..76c1267 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -110,7 +110,7 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, kMessageWidth); HWND root_hwnd; if (tab_contents_) { - root_hwnd = GetAncestor(tab_contents_->GetContentHWND(), GA_ROOT); + root_hwnd = GetAncestor(tab_contents_->GetContentNativeView(), GA_ROOT); } else { // Dialog is top level if we don't have a tab_contents associated with us. root_hwnd = NULL; diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index 8c7ca7a..7e0b3df 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -223,7 +223,7 @@ void HungRendererWarningView::ShowForWebContents(WebContents* contents) { // Don't show the warning unless the foreground window is the frame, or this // window (but still invisible). If the user has another window or // application selected, activating ourselves is rude. - HWND frame_hwnd = GetAncestor(contents->GetContainerHWND(), GA_ROOT); + HWND frame_hwnd = GetAncestor(contents->GetNativeView(), GA_ROOT); HWND foreground_window = GetForegroundWindow(); if (foreground_window != frame_hwnd && foreground_window != window()->GetHWND()) { @@ -400,7 +400,7 @@ void HungRendererWarningView::CreateKillButtonView() { gfx::Rect HungRendererWarningView::GetDisplayBounds( WebContents* contents) { - HWND contents_hwnd = contents->GetContainerHWND(); + HWND contents_hwnd = contents->GetNativeView(); CRect contents_bounds; GetWindowRect(contents_hwnd, &contents_bounds); diff --git a/chrome/browser/views/tab_contents_container_view.cc b/chrome/browser/views/tab_contents_container_view.cc index 3228dba..6c8e0c3 100644 --- a/chrome/browser/views/tab_contents_container_view.cc +++ b/chrome/browser/views/tab_contents_container_view.cc @@ -34,7 +34,7 @@ void TabContentsContainerView::SetTabContents(TabContents* tab_contents) { if (tab_contents_) { // TODO(brettw) should this move to HWNDView::Detach which is called below? // It needs cleanup regardless. - HWND container_hwnd = tab_contents_->GetContainerHWND(); + HWND container_hwnd = tab_contents_->GetNativeView(); // Hide the contents before adjusting its parent to avoid a full desktop // flicker. @@ -47,7 +47,7 @@ void TabContentsContainerView::SetTabContents(TabContents* tab_contents) { // Unregister the tab contents window from the FocusManager. views::FocusManager::UninstallFocusSubclass(container_hwnd); - HWND hwnd = tab_contents_->GetContentHWND(); + HWND hwnd = tab_contents_->GetContentNativeView(); if (hwnd) { // We may not have an HWND anymore, if the renderer crashed and we are // displaying the sad tab for example. @@ -80,8 +80,8 @@ void TabContentsContainerView::SetTabContents(TabContents* tab_contents) { // TabContents window (for the WebContents case). SetAssociatedFocusView(this); - Attach(tab_contents->GetContainerHWND()); - HWND contents_hwnd = tab_contents_->GetContentHWND(); + Attach(tab_contents->GetNativeView()); + HWND contents_hwnd = tab_contents_->GetContentNativeView(); if (contents_hwnd) FocusManager::InstallFocusSubclass(contents_hwnd, this); @@ -151,7 +151,7 @@ views::View* TabContentsContainerView::GetFocusTraversableParentView() { void TabContentsContainerView::Focus() { if (tab_contents_ && !tab_contents_->GetContentsRootView()) { // Set the native focus on the actual content of the tab. - ::SetFocus(tab_contents_->GetContentHWND()); + ::SetFocus(tab_contents_->GetContentNativeView()); } } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 7464b92..806faeb 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -832,7 +832,7 @@ void DraggedTabController::Detach() { // Set up the photo booth to start capturing the contents of the dragged // TabContents. if (!photobooth_.get()) - photobooth_.reset(new HWNDPhotobooth(dragged_contents_->GetContainerHWND())); + photobooth_.reset(new HWNDPhotobooth(dragged_contents_->GetNativeView())); // Update the View. This NULL check is necessary apparently in some // conditions during automation where the view_ is destroyed inside a @@ -1111,7 +1111,7 @@ bool DraggedTabController::CompleteDrag() { void DraggedTabController::EnsureDraggedView() { if (!view_.get()) { RECT wr; - GetWindowRect(dragged_contents_->GetContainerHWND(), &wr); + GetWindowRect(dragged_contents_->GetNativeView(), &wr); view_.reset(new DraggedTabView(dragged_contents_, mouse_offset_, gfx::Size(wr.right - wr.left, wr.bottom - wr.top))); |