summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_contents_view_win.cc
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-18 15:37:29 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-18 15:37:29 +0000
commit425254cdc9b7ff515285250c30976858f0f17abf (patch)
tree2ed818bbc428ac09357f368f0d9084d64ef3717b /chrome/browser/web_contents_view_win.cc
parenta0e30833a5e0b0f32d28a64b36f2dd31cbe681be (diff)
downloadchromium_src-425254cdc9b7ff515285250c30976858f0f17abf.zip
chromium_src-425254cdc9b7ff515285250c30976858f0f17abf.tar.gz
chromium_src-425254cdc9b7ff515285250c30976858f0f17abf.tar.bz2
Move more platform-specific stuff from WebContents to the view.
I refactored the way title setting is done since there were two parts that duplicated the logic and did so slightly differently. I removed some old code in RendererGone whose premise is no longer valid and had the effect of creating a bug with no benefit. I moved the sad tab view from WebContents to the view. Amusingly, the view was the only one using this, but it would go poke inside of the WebContents to get it. Review URL: http://codereview.chromium.org/7650 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_contents_view_win.cc')
-rw-r--r--chrome/browser/web_contents_view_win.cc71
1 files changed, 49 insertions, 22 deletions
diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc
index 60e11ce..a7f4365 100644
--- a/chrome/browser/web_contents_view_win.cc
+++ b/chrome/browser/web_contents_view_win.cc
@@ -164,29 +164,35 @@ InfoBarView* WebContentsViewWin::GetInfoBarView() {
return info_bar_view_.get();
}
+void WebContentsViewWin::SetPageTitle(const std::wstring& title) {
+ if (GetContainerHWND()) {
+ // It's possible to get this after the hwnd has been destroyed.
+ ::SetWindowText(GetContainerHWND(), 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(),
+ title.c_str());
+ }
+}
+
+void WebContentsViewWin::Invalidate() {
+ // Note that it's possible to get this message after the window was destroyed.
+ if (::IsWindow(GetContainerHWND()))
+ InvalidateRect(GetContainerHWND(), NULL, FALSE);
+}
+
void WebContentsViewWin::UpdateDragCursor(bool is_drop_target) {
drop_target_->set_is_drop_target(is_drop_target);
}
-void WebContentsViewWin::ShowContextMenu(
- const ViewHostMsg_ContextMenu_Params& params) {
- RenderViewContextMenuController menu_controller(web_contents_, params);
- RenderViewContextMenu menu(&menu_controller,
- GetHWND(),
- params.type,
- params.misspelled_word,
- params.dictionary_suggestions,
- web_contents_->profile());
-
- POINT screen_pt = { params.x, params.y };
- MapWindowPoints(GetHWND(), HWND_DESKTOP, &screen_pt, 1);
+void WebContentsViewWin::TakeFocus(bool reverse) {
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManager(GetContainerHWND());
- // Enable recursive tasks on the message loop so we can get updates while
- // the context menu is being displayed.
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
- menu.RunMenuAt(screen_pt.x, screen_pt.y);
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
+ // We may not have a focus manager if the tab has been switched before this
+ // message arrived.
+ if (focus_manager)
+ focus_manager->AdvanceFocus(reverse);
}
void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) {
@@ -218,6 +224,27 @@ void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) {
event.actual_message.lParam);
}
+void WebContentsViewWin::ShowContextMenu(
+ const ViewHostMsg_ContextMenu_Params& params) {
+ RenderViewContextMenuController menu_controller(web_contents_, params);
+ RenderViewContextMenu menu(&menu_controller,
+ GetHWND(),
+ params.type,
+ params.misspelled_word,
+ params.dictionary_suggestions,
+ web_contents_->profile());
+
+ POINT screen_pt = { params.x, params.y };
+ MapWindowPoints(GetHWND(), HWND_DESKTOP, &screen_pt, 1);
+
+ // Enable recursive tasks on the message loop so we can get updates while
+ // the context menu is being displayed.
+ bool old_state = MessageLoop::current()->NestableTasksAllowed();
+ MessageLoop::current()->SetNestableTasksAllowed(true);
+ menu.RunMenuAt(screen_pt.x, screen_pt.y);
+ MessageLoop::current()->SetNestableTasksAllowed(old_state);
+}
+
WebContents* WebContentsViewWin::CreateNewWindowInternal(
int route_id,
HANDLE modal_dialog_event) {
@@ -357,13 +384,13 @@ LRESULT WebContentsViewWin::OnMouseRange(UINT msg,
void WebContentsViewWin::OnPaint(HDC junk_dc) {
if (web_contents_->render_view_host() &&
!web_contents_->render_view_host()->IsRenderViewLive()) {
- if (!web_contents_->sad_tab_.get())
- web_contents_->sad_tab_.reset(new SadTabView);
+ if (!sad_tab_.get())
+ sad_tab_.reset(new SadTabView);
CRect cr;
GetClientRect(&cr);
- web_contents_->sad_tab_->SetBounds(gfx::Rect(cr));
+ sad_tab_->SetBounds(gfx::Rect(cr));
ChromeCanvasPaint canvas(GetHWND(), true);
- web_contents_->sad_tab_->ProcessPaint(&canvas);
+ sad_tab_->ProcessPaint(&canvas);
return;
}