OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/omnibox/omnibox_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/property_bag.h" | 13 #include "base/property_bag.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversion_utils.h" | 15 #include "base/utf_string_conversion_utils.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
19 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 19 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
20 #include "chrome/browser/command_updater.h" | 20 #include "chrome/browser/command_updater.h" |
21 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
22 #include "chrome/browser/instant/instant_controller.h" | 22 #include "chrome/browser/instant/instant_controller.h" |
23 #include "chrome/browser/platform_util.h" | 23 #include "chrome/browser/platform_util.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 26 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
26 #include "chrome/browser/ui/gtk/gtk_util.h" | 27 #include "chrome/browser/ui/gtk/gtk_util.h" |
27 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 28 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
28 #include "chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h" | 29 #include "chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h" |
29 #include "chrome/browser/ui/gtk/view_id_util.h" | 30 #include "chrome/browser/ui/gtk/view_id_util.h" |
30 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 31 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
31 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 32 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
32 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
33 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 34 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 guint target_type, | 1475 guint target_type, |
1475 guint time) { | 1476 guint time) { |
1476 DCHECK(text_view_); | 1477 DCHECK(text_view_); |
1477 | 1478 |
1478 switch (target_type) { | 1479 switch (target_type) { |
1479 case GTK_TEXT_BUFFER_TARGET_INFO_TEXT: { | 1480 case GTK_TEXT_BUFFER_TARGET_INFO_TEXT: { |
1480 gtk_selection_data_set_text(selection_data, dragged_text_.c_str(), -1); | 1481 gtk_selection_data_set_text(selection_data, dragged_text_.c_str(), -1); |
1481 break; | 1482 break; |
1482 } | 1483 } |
1483 case ui::CHROME_NAMED_URL: { | 1484 case ui::CHROME_NAMED_URL: { |
1484 WebContents* current_tab = browser_->GetActiveWebContents(); | 1485 WebContents* current_tab = chrome::GetActiveWebContents(browser_); |
1485 string16 tab_title = current_tab->GetTitle(); | 1486 string16 tab_title = current_tab->GetTitle(); |
1486 // Pass an empty string if user has edited the URL. | 1487 // Pass an empty string if user has edited the URL. |
1487 if (current_tab->GetURL().spec() != dragged_text_) | 1488 if (current_tab->GetURL().spec() != dragged_text_) |
1488 tab_title = string16(); | 1489 tab_title = string16(); |
1489 ui::WriteURLWithName(selection_data, GURL(dragged_text_), | 1490 ui::WriteURLWithName(selection_data, GURL(dragged_text_), |
1490 tab_title, target_type); | 1491 tab_title, target_type); |
1491 break; | 1492 break; |
1492 } | 1493 } |
1493 } | 1494 } |
1494 } | 1495 } |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { | 2248 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { |
2248 // By default, GtkTextView layouts an anchored child widget just above the | 2249 // By default, GtkTextView layouts an anchored child widget just above the |
2249 // baseline, so we need to move the |instant_view_| down to make sure it | 2250 // baseline, so we need to move the |instant_view_| down to make sure it |
2250 // has the same baseline as the |text_view_|. | 2251 // has the same baseline as the |text_view_|. |
2251 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); | 2252 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); |
2252 int height; | 2253 int height; |
2253 pango_layout_get_size(layout, NULL, &height); | 2254 pango_layout_get_size(layout, NULL, &height); |
2254 int baseline = pango_layout_get_baseline(layout); | 2255 int baseline = pango_layout_get_baseline(layout); |
2255 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); | 2256 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); |
2256 } | 2257 } |
OLD | NEW |