Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 159419: Correctly update drag status for drags over renderer. This makes things look ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: do what Brett says Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include "app/l10n_util.h"
12 #include "base/mime_util.h" 11 #include "base/mime_util.h"
13 #include "base/gfx/point.h" 12 #include "base/gfx/point.h"
14 #include "base/gfx/rect.h" 13 #include "base/gfx/rect.h"
15 #include "base/gfx/size.h" 14 #include "base/gfx/size.h"
15 #include "base/pickle.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/download/download_shelf.h" 18 #include "chrome/browser/download/download_shelf.h"
19 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h" 19 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h"
20 #include "chrome/browser/gtk/browser_window_gtk.h" 20 #include "chrome/browser/gtk/browser_window_gtk.h"
21 #include "chrome/browser/gtk/constrained_window_gtk.h" 21 #include "chrome/browser/gtk/constrained_window_gtk.h"
22 #include "chrome/browser/gtk/gtk_dnd_util.h" 22 #include "chrome/browser/gtk/gtk_dnd_util.h"
23 #include "chrome/browser/gtk/gtk_floating_container.h" 23 #include "chrome/browser/gtk/gtk_floating_container.h"
24 #include "chrome/browser/gtk/gtk_theme_provider.h" 24 #include "chrome/browser/gtk/gtk_theme_provider.h"
25 #include "chrome/browser/gtk/sad_tab_gtk.h" 25 #include "chrome/browser/gtk/sad_tab_gtk.h"
26 #include "chrome/browser/renderer_host/render_view_host.h" 26 #include "chrome/browser/renderer_host/render_view_host.h"
27 #include "chrome/browser/renderer_host/render_view_host_factory.h" 27 #include "chrome/browser/renderer_host/render_view_host_factory.h"
28 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 28 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
29 #include "chrome/browser/tab_contents/interstitial_page.h" 29 #include "chrome/browser/tab_contents/interstitial_page.h"
30 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" 30 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
31 #include "chrome/browser/tab_contents/tab_contents.h" 31 #include "chrome/browser/tab_contents/tab_contents.h"
32 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 32 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
33 #include "chrome/common/gtk_util.h" 33 #include "chrome/common/gtk_util.h"
34 #include "chrome/common/notification_service.h" 34 #include "chrome/common/notification_service.h"
35 #include "chrome/common/notification_source.h" 35 #include "chrome/common/notification_source.h"
36 #include "chrome/common/notification_type.h" 36 #include "chrome/common/notification_type.h"
37 #include "grit/app_strings.h"
38 #include "net/base/net_util.h"
39 #include "webkit/glue/webdropdata.h" 37 #include "webkit/glue/webdropdata.h"
40 38
41 namespace { 39 namespace {
42 40
43 // TODO(erg): I have no idea how to programatically figure out how wide the 41 // TODO(erg): I have no idea how to programatically figure out how wide the
44 // vertical scrollbar is. Hack it with a hardcoded value for now. 42 // vertical scrollbar is. Hack it with a hardcoded value for now.
45 const int kScrollbarWidthHack = 25; 43 const int kScrollbarWidthHack = 25;
46 44
47 // Called when the content view gtk widget is tabbed to, or after the call to 45 // Called when the content view gtk widget is tabbed to, or after the call to
48 // gtk_widget_child_focus() in TakeFocus(). We return true 46 // gtk_widget_child_focus() in TakeFocus(). We return true
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 222 }
225 } 223 }
226 224
227 // This is called when the renderer responds to a drag motion event. We must 225 // This is called when the renderer responds to a drag motion event. We must
228 // update the system drag cursor. 226 // update the system drag cursor.
229 void UpdateDragStatus(bool is_drop_target) { 227 void UpdateDragStatus(bool is_drop_target) {
230 if (context_) { 228 if (context_) {
231 // TODO(estade): we might want to support other actions besides copy, 229 // TODO(estade): we might want to support other actions besides copy,
232 // but that would increase the cost of getting our drag success guess 230 // but that would increase the cost of getting our drag success guess
233 // wrong. 231 // wrong.
234 gdk_drag_status(context_, GDK_ACTION_COPY, drag_over_time_); 232 gdk_drag_status(context_, is_drop_target ? GDK_ACTION_COPY :
233 static_cast<GdkDragAction>(0),
234 drag_over_time_);
235 is_drop_target_ = false; 235 is_drop_target_ = false;
236 } 236 }
237 } 237 }
238 238
239 // Informs the renderer when a system drag has left the render view. 239 // Informs the renderer when a system drag has left the render view.
240 // See OnDragLeave(). 240 // See OnDragLeave().
241 void DragLeave() { 241 void DragLeave() {
242 tab_contents_->render_view_host()->DragTargetDragLeave(); 242 tab_contents_->render_view_host()->DragTargetDragLeave();
243 } 243 }
244 244
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 std::string utf8_text = UTF16ToUTF8(view->drop_data_->text_html); 813 std::string utf8_text = UTF16ToUTF8(view->drop_data_->text_html);
814 gtk_selection_data_set(selection_data, 814 gtk_selection_data_set(selection_data,
815 GtkDndUtil::GetAtomForTarget(GtkDndUtil::TEXT_HTML), 815 GtkDndUtil::GetAtomForTarget(GtkDndUtil::TEXT_HTML),
816 bits_per_byte, 816 bits_per_byte,
817 reinterpret_cast<const guchar*>(utf8_text.c_str()), 817 reinterpret_cast<const guchar*>(utf8_text.c_str()),
818 utf8_text.length()); 818 utf8_text.length());
819 break; 819 break;
820 } 820 }
821 821
822 case GtkDndUtil::CHROME_NAMED_URL: { 822 case GtkDndUtil::CHROME_NAMED_URL: {
823 std::string name;
824 const GURL& url = view->drop_data_->url;
825 if (!view->drop_data_->url_title.empty()) {
826 name = UTF16ToUTF8(view->drop_data_->url_title);
827 } else if (url.is_valid()) {
828 name = WideToUTF8(net::GetSuggestedFilename(
829 url, std::string(), std::string(), std::wstring()));
830 } else {
831 // Nothing else can be done, just use a default.
832 name = l10n_util::GetStringUTF8(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME);
833 }
834 Pickle pickle; 823 Pickle pickle;
835 pickle.WriteString(name); 824 pickle.WriteString(UTF16ToUTF8(view->drop_data_->url_title));
836 pickle.WriteString(url.spec()); 825 pickle.WriteString(view->drop_data_->url.spec());
837 gtk_selection_data_set(selection_data, 826 gtk_selection_data_set(selection_data,
838 GtkDndUtil::GetAtomForTarget(GtkDndUtil::CHROME_NAMED_URL), 827 GtkDndUtil::GetAtomForTarget(GtkDndUtil::CHROME_NAMED_URL),
839 bits_per_byte, 828 bits_per_byte,
840 reinterpret_cast<const guchar*>(pickle.data()), 829 reinterpret_cast<const guchar*>(pickle.data()),
841 pickle.size()); 830 pickle.size());
842 break; 831 break;
843 } 832 }
844 833
845 case GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS: { 834 case GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS: {
846 gtk_selection_data_set(selection_data, 835 gtk_selection_data_set(selection_data,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 930 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
942 widget, "x", &value); 931 widget, "x", &value);
943 932
944 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 933 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
945 g_value_set_int(&value, child_y); 934 g_value_set_int(&value, child_y);
946 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 935 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
947 widget, "y", &value); 936 widget, "y", &value);
948 g_value_unset(&value); 937 g_value_unset(&value);
949 } 938 }
950 } 939 }
OLDNEW
« chrome/browser/gtk/bookmark_manager_gtk.cc ('K') | « chrome/browser/gtk/tabs/tab_strip_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698