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

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 12463042: Shows chrome-extension urls and greys out the whole url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment nits Created 7 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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>
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 strikethrough_ = CharRange(); 1630 strikethrough_ = CharRange();
1631 return; 1631 return;
1632 } 1632 }
1633 } 1633 }
1634 // See whether the contents are a URL with a non-empty host portion, which we 1634 // See whether the contents are a URL with a non-empty host portion, which we
1635 // should emphasize. To check for a URL, rather than using the type returned 1635 // should emphasize. To check for a URL, rather than using the type returned
1636 // by Parse(), ask the model, which will check the desired page transition for 1636 // by Parse(), ask the model, which will check the desired page transition for
1637 // this input. This can tell us whether an UNKNOWN input string is going to 1637 // this input. This can tell us whether an UNKNOWN input string is going to
1638 // be treated as a search or a navigation, and is the same method the Paste 1638 // be treated as a search or a navigation, and is the same method the Paste
1639 // And Go system uses. 1639 // And Go system uses.
1640 url_parse::Component scheme, host; 1640 url_parse::Component scheme;
1641 url_parse::Component host;
Peter Kasting 2013/04/03 22:32:13 Nit: Splitting these declarations onto multiple li
Patrick Riordan 2013/04/04 01:01:37 Done.
1641 string16 text(GetText()); 1642 string16 text(GetText());
1642 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host); 1643 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host);
1643 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 1644 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
1644 1645
1645 // Set the baseline emphasis. 1646 // Set the baseline emphasis.
1646 GtkTextIter start, end; 1647 GtkTextIter start;
1648 GtkTextIter end;
1647 GetTextBufferBounds(&start, &end); 1649 GetTextBufferBounds(&start, &end);
1648 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end); 1650 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end);
1649 if (emphasize) { 1651 if (emphasize) {
1650 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end); 1652 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end);
1651 1653
1652 // We've found a host name, give it more emphasis. 1654 if (!toolbar_model()->ShouldGreyOutURL()) {
1653 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0, 1655 // We've found a host name, give it more emphasis.
1654 GetUTF8Offset(text, 1656 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0,
1655 host.begin)); 1657 GetUTF8Offset(text,
1656 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0, 1658 host.begin));
1657 GetUTF8Offset(text, 1659 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0,
1658 host.end())); 1660 GetUTF8Offset(text,
1661 host.end()));
1659 1662
1660 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1663 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1664 }
1661 } else { 1665 } else {
1662 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1666 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1663 } 1667 }
1664 1668
1665 strikethrough_ = CharRange(); 1669 strikethrough_ = CharRange();
1666 // Emphasize the scheme for security UI display purposes (if necessary). 1670 // Emphasize the scheme for security UI display purposes (if necessary).
1667 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 1671 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
1668 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 1672 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
1669 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin), 1673 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin),
1670 GetUTF8Offset(text, scheme.end())); 1674 GetUTF8Offset(text, scheme.end()));
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { 2148 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() {
2145 // By default, GtkTextView layouts an anchored child widget just above the 2149 // By default, GtkTextView layouts an anchored child widget just above the
2146 // baseline, so we need to move the |instant_view_| down to make sure it 2150 // baseline, so we need to move the |instant_view_| down to make sure it
2147 // has the same baseline as the |text_view_|. 2151 // has the same baseline as the |text_view_|.
2148 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2152 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2149 int height; 2153 int height;
2150 pango_layout_get_size(layout, NULL, &height); 2154 pango_layout_get_size(layout, NULL, &height);
2151 int baseline = pango_layout_get_baseline(layout); 2155 int baseline = pango_layout_get_baseline(layout);
2152 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2156 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2153 } 2157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698