OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "app/gtk_dnd_util.h" | |
12 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
13 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
14 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
16 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
17 #include "base/logging.h" | 16 #include "base/logging.h" |
18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
19 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
20 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
21 #include "chrome/browser/accessibility_events.h" | 20 #include "chrome/browser/accessibility_events.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "chrome/common/extensions/extension_resource.h" | 53 #include "chrome/common/extensions/extension_resource.h" |
55 #include "chrome/common/notification_service.h" | 54 #include "chrome/common/notification_service.h" |
56 #include "chrome/common/page_transition_types.h" | 55 #include "chrome/common/page_transition_types.h" |
57 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
58 #include "gfx/canvas_skia_paint.h" | 57 #include "gfx/canvas_skia_paint.h" |
59 #include "gfx/font.h" | 58 #include "gfx/font.h" |
60 #include "gfx/gtk_util.h" | 59 #include "gfx/gtk_util.h" |
61 #include "grit/generated_resources.h" | 60 #include "grit/generated_resources.h" |
62 #include "grit/theme_resources.h" | 61 #include "grit/theme_resources.h" |
63 #include "net/base/net_util.h" | 62 #include "net/base/net_util.h" |
| 63 #include "ui/base/dragdrop/gtk_dnd_util.h" |
64 #include "webkit/glue/window_open_disposition.h" | 64 #include "webkit/glue/window_open_disposition.h" |
65 | 65 |
66 namespace { | 66 namespace { |
67 | 67 |
68 // We are positioned with a little bit of extra space that we don't use now. | 68 // We are positioned with a little bit of extra space that we don't use now. |
69 const int kTopMargin = 1; | 69 const int kTopMargin = 1; |
70 const int kBottomMargin = 1; | 70 const int kBottomMargin = 1; |
71 const int kLeftMargin = 1; | 71 const int kLeftMargin = 1; |
72 const int kRightMargin = 1; | 72 const int kRightMargin = 1; |
73 // We draw a border on the top and bottom (but not on left or right). | 73 // We draw a border on the top and bottom (but not on left or right). |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 return; | 363 return; |
364 enable_location_drag_ = enable; | 364 enable_location_drag_ = enable; |
365 | 365 |
366 if (!enable) { | 366 if (!enable) { |
367 gtk_drag_source_unset(site_type_event_box_); | 367 gtk_drag_source_unset(site_type_event_box_); |
368 return; | 368 return; |
369 } | 369 } |
370 | 370 |
371 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, | 371 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, |
372 NULL, 0, GDK_ACTION_COPY); | 372 NULL, 0, GDK_ACTION_COPY); |
373 gtk_dnd_util::SetSourceTargetListFromCodeMask(site_type_event_box_, | 373 ui::SetSourceTargetListFromCodeMask(site_type_event_box_, |
374 gtk_dnd_util::TEXT_PLAIN | | 374 ui::TEXT_PLAIN | |
375 gtk_dnd_util::TEXT_URI_LIST | | 375 ui::TEXT_URI_LIST | |
376 gtk_dnd_util::CHROME_NAMED_URL); | 376 ui::CHROME_NAMED_URL); |
377 } | 377 } |
378 | 378 |
379 void LocationBarViewGtk::SetProfile(Profile* profile) { | 379 void LocationBarViewGtk::SetProfile(Profile* profile) { |
380 profile_ = profile; | 380 profile_ = profile; |
381 } | 381 } |
382 | 382 |
383 TabContents* LocationBarViewGtk::GetTabContents() const { | 383 TabContents* LocationBarViewGtk::GetTabContents() const { |
384 return browser_->GetSelectedTabContents(); | 384 return browser_->GetSelectedTabContents(); |
385 } | 385 } |
386 | 386 |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 return FALSE; | 1115 return FALSE; |
1116 } | 1116 } |
1117 | 1117 |
1118 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, | 1118 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, |
1119 GdkDragContext* context, | 1119 GdkDragContext* context, |
1120 GtkSelectionData* data, | 1120 GtkSelectionData* data, |
1121 guint info, guint time) { | 1121 guint info, guint time) { |
1122 TabContents* tab = GetTabContents(); | 1122 TabContents* tab = GetTabContents(); |
1123 if (!tab) | 1123 if (!tab) |
1124 return; | 1124 return; |
1125 gtk_dnd_util::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); | 1125 ui::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); |
1126 } | 1126 } |
1127 | 1127 |
1128 void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, | 1128 void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, |
1129 GdkDragContext* context) { | 1129 GdkDragContext* context) { |
1130 SkBitmap favicon = GetFavIcon(); | 1130 SkBitmap favicon = GetFavIcon(); |
1131 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&favicon); | 1131 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&favicon); |
1132 if (!pixbuf) | 1132 if (!pixbuf) |
1133 return; | 1133 return; |
1134 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, | 1134 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, |
1135 WideToUTF16(GetTitle()), theme_provider_); | 1135 WideToUTF16(GetTitle()), theme_provider_); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1551 |
1552 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1552 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1553 if (badge_text.empty()) | 1553 if (badge_text.empty()) |
1554 return FALSE; | 1554 return FALSE; |
1555 | 1555 |
1556 gfx::CanvasSkiaPaint canvas(event, false); | 1556 gfx::CanvasSkiaPaint canvas(event, false); |
1557 gfx::Rect bounding_rect(widget->allocation); | 1557 gfx::Rect bounding_rect(widget->allocation); |
1558 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1558 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1559 return FALSE; | 1559 return FALSE; |
1560 } | 1560 } |
OLD | NEW |