| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/tab_contents/web_drop_target.h" | 25 #include "chrome/browser/tab_contents/web_drop_target.h" |
| 26 #include "chrome/browser/views/sad_tab_view.h" | 26 #include "chrome/browser/views/sad_tab_view.h" |
| 27 #include "chrome/browser/views/tab_contents/render_view_context_menu_win.h" | 27 #include "chrome/browser/views/tab_contents/render_view_context_menu_win.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 30 #include "views/focus/view_storage.h" | 30 #include "views/focus/view_storage.h" |
| 31 #include "views/widget/root_view.h" | 31 #include "views/widget/root_view.h" |
| 32 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 32 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 33 #include "webkit/glue/webdropdata.h" | 33 #include "webkit/glue/webdropdata.h" |
| 34 | 34 |
| 35 using WebKit::WebDragOperation; |
| 36 using WebKit::WebDragOperationNone; |
| 37 using WebKit::WebDragOperationsMask; |
| 35 using WebKit::WebInputEvent; | 38 using WebKit::WebInputEvent; |
| 36 | 39 |
| 37 namespace { | 40 namespace { |
| 38 | 41 |
| 39 // Windows callback for OnDestroy to detach the plugin windows. | 42 // Windows callback for OnDestroy to detach the plugin windows. |
| 40 BOOL CALLBACK DetachPluginWindowsCallback(HWND window, LPARAM param) { | 43 BOOL CALLBACK DetachPluginWindowsCallback(HWND window, LPARAM param) { |
| 41 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window) && | 44 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window) && |
| 42 !IsHungAppWindow(window)) { | 45 !IsHungAppWindow(window)) { |
| 43 ::ShowWindow(window, SW_HIDE); | 46 ::ShowWindow(window, SW_HIDE); |
| 44 SetParent(window, NULL); | 47 SetParent(window, NULL); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 128 } |
| 126 | 129 |
| 127 gfx::NativeWindow TabContentsViewWin::GetTopLevelNativeWindow() const { | 130 gfx::NativeWindow TabContentsViewWin::GetTopLevelNativeWindow() const { |
| 128 return ::GetAncestor(GetNativeView(), GA_ROOT); | 131 return ::GetAncestor(GetNativeView(), GA_ROOT); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void TabContentsViewWin::GetContainerBounds(gfx::Rect* out) const { | 134 void TabContentsViewWin::GetContainerBounds(gfx::Rect* out) const { |
| 132 GetBounds(out, false); | 135 GetBounds(out, false); |
| 133 } | 136 } |
| 134 | 137 |
| 135 void TabContentsViewWin::StartDragging(const WebDropData& drop_data) { | 138 void TabContentsViewWin::StartDragging(const WebDropData& drop_data, |
| 139 WebDragOperationsMask ops) { |
| 136 OSExchangeData data; | 140 OSExchangeData data; |
| 137 | 141 |
| 138 // TODO(tc): Generate an appropriate drag image. | 142 // TODO(tc): Generate an appropriate drag image. |
| 139 | 143 |
| 140 // We set the file contents before the URL because the URL also sets file | 144 // We set the file contents before the URL because the URL also sets file |
| 141 // contents (to a .URL shortcut). We want to prefer file content data over a | 145 // contents (to a .URL shortcut). We want to prefer file content data over a |
| 142 // shortcut so we add it first. | 146 // shortcut so we add it first. |
| 143 if (!drop_data.file_contents.empty()) { | 147 if (!drop_data.file_contents.empty()) { |
| 144 // Images without ALT text will only have a file extension so we need to | 148 // Images without ALT text will only have a file extension so we need to |
| 145 // synthesize one from the provided extension and URL. | 149 // synthesize one from the provided extension and URL. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 drag_source_ = new WebDragSource(GetNativeView(), tab_contents()); | 186 drag_source_ = new WebDragSource(GetNativeView(), tab_contents()); |
| 183 | 187 |
| 184 DWORD effects; | 188 DWORD effects; |
| 185 | 189 |
| 186 // We need to enable recursive tasks on the message loop so we can get | 190 // We need to enable recursive tasks on the message loop so we can get |
| 187 // updates while in the system DoDragDrop loop. | 191 // updates while in the system DoDragDrop loop. |
| 188 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 192 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
| 189 MessageLoop::current()->SetNestableTasksAllowed(true); | 193 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 190 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, | 194 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, |
| 191 DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); | 195 DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); |
| 196 // TODO(snej): Use 'ops' param instead of hardcoding dropeffects |
| 192 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 197 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
| 193 | 198 |
| 194 drag_source_ = NULL; | 199 drag_source_ = NULL; |
| 195 if (close_tab_after_drag_ends_) { | 200 if (close_tab_after_drag_ends_) { |
| 196 close_tab_timer_.Start(base::TimeDelta::FromMilliseconds(0), this, | 201 close_tab_timer_.Start(base::TimeDelta::FromMilliseconds(0), this, |
| 197 &TabContentsViewWin::CloseTab); | 202 &TabContentsViewWin::CloseTab); |
| 198 } | 203 } |
| 199 | 204 |
| 200 if (tab_contents()->render_view_host()) | 205 if (tab_contents()->render_view_host()) |
| 201 tab_contents()->render_view_host()->DragSourceSystemDragEnded(); | 206 tab_contents()->render_view_host()->DragSourceSystemDragEnded(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 356 |
| 352 void TabContentsViewWin::CancelDragAndCloseTab() { | 357 void TabContentsViewWin::CancelDragAndCloseTab() { |
| 353 DCHECK(IsDoingDrag()); | 358 DCHECK(IsDoingDrag()); |
| 354 // We can't close the tab while we're in the drag and | 359 // We can't close the tab while we're in the drag and |
| 355 // |drag_source_->CancelDrag()| is async. Instead, set a flag to cancel | 360 // |drag_source_->CancelDrag()| is async. Instead, set a flag to cancel |
| 356 // the drag and when the drag nested message loop ends, close the tab. | 361 // the drag and when the drag nested message loop ends, close the tab. |
| 357 drag_source_->CancelDrag(); | 362 drag_source_->CancelDrag(); |
| 358 close_tab_after_drag_ends_ = true; | 363 close_tab_after_drag_ends_ = true; |
| 359 } | 364 } |
| 360 | 365 |
| 361 void TabContentsViewWin::UpdateDragCursor(bool is_drop_target) { | 366 void TabContentsViewWin::UpdateDragCursor(WebDragOperation operation) { |
| 362 drop_target_->set_is_drop_target(is_drop_target); | 367 drop_target_->set_is_drop_target(operation != WebDragOperationNone); |
| 363 } | 368 } |
| 364 | 369 |
| 365 void TabContentsViewWin::GotFocus() { | 370 void TabContentsViewWin::GotFocus() { |
| 366 if (tab_contents()->delegate()) | 371 if (tab_contents()->delegate()) |
| 367 tab_contents()->delegate()->TabContentsFocused(tab_contents()); | 372 tab_contents()->delegate()->TabContentsFocused(tab_contents()); |
| 368 } | 373 } |
| 369 | 374 |
| 370 void TabContentsViewWin::TakeFocus(bool reverse) { | 375 void TabContentsViewWin::TakeFocus(bool reverse) { |
| 371 if (!tab_contents()->delegate()->TakeFocus(reverse)) { | 376 if (!tab_contents()->delegate()->TakeFocus(reverse)) { |
| 372 views::FocusManager* focus_manager = | 377 views::FocusManager* focus_manager = |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } | 678 } |
| 674 return false; | 679 return false; |
| 675 } | 680 } |
| 676 | 681 |
| 677 void TabContentsViewWin::WheelZoom(int distance) { | 682 void TabContentsViewWin::WheelZoom(int distance) { |
| 678 if (tab_contents()->delegate()) { | 683 if (tab_contents()->delegate()) { |
| 679 bool zoom_in = distance > 0; | 684 bool zoom_in = distance > 0; |
| 680 tab_contents()->delegate()->ContentsZoomChange(zoom_in); | 685 tab_contents()->delegate()->ContentsZoomChange(zoom_in); |
| 681 } | 686 } |
| 682 } | 687 } |
| OLD | NEW |