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

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: Implementation does not depend on having a host and fixed 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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 } 1644 }
1645 // See whether the contents are a URL with a non-empty host portion, which we 1645 // See whether the contents are a URL with a non-empty host portion, which we
1646 // should emphasize. To check for a URL, rather than using the type returned 1646 // should emphasize. To check for a URL, rather than using the type returned
1647 // by Parse(), ask the model, which will check the desired page transition for 1647 // by Parse(), ask the model, which will check the desired page transition for
1648 // this input. This can tell us whether an UNKNOWN input string is going to 1648 // this input. This can tell us whether an UNKNOWN input string is going to
1649 // be treated as a search or a navigation, and is the same method the Paste 1649 // be treated as a search or a navigation, and is the same method the Paste
1650 // And Go system uses. 1650 // And Go system uses.
1651 url_parse::Component scheme, host; 1651 url_parse::Component scheme, host;
1652 string16 text(GetText()); 1652 string16 text(GetText());
1653 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host); 1653 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host);
1654 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
1655 1654
1656 // Set the baseline emphasis. 1655 // Set the baseline emphasis.
1657 GtkTextIter start, end; 1656 GtkTextIter start, end;
1658 GetTextBufferBounds(&start, &end); 1657 GetTextBufferBounds(&start, &end);
1659 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end); 1658 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end);
1660 if (emphasize) { 1659 if (model()->CurrentTextIsURL() &&
Peter Kasting 2013/04/04 21:07:05 Nit: Slightly simpler: bool grey_base = model()
Patrick Riordan 2013/04/10 02:00:24 Done.
1660 (host.is_nonempty() || toolbar_model()->ShouldGreyOutURL())) {
1661 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end); 1661 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end);
1662 1662
1663 // We've found a host name, give it more emphasis. 1663 if (host.is_nonempty() && !toolbar_model()->ShouldGreyOutURL()) {
1664 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0, 1664 // We've found a host name, give it more emphasis.
1665 GetUTF8Offset(text, 1665 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0,
1666 host.begin)); 1666 GetUTF8Offset(text,
1667 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0, 1667 host.begin));
1668 GetUTF8Offset(text, 1668 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0,
1669 host.end())); 1669 GetUTF8Offset(text,
1670 host.end()));
1670 1671
1671 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1672 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1673 }
1672 } else { 1674 } else {
1673 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1675 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1674 } 1676 }
1675 1677
1676 strikethrough_ = CharRange(); 1678 strikethrough_ = CharRange();
1677 // Emphasize the scheme for security UI display purposes (if necessary). 1679 // Emphasize the scheme for security UI display purposes (if necessary).
1678 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 1680 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
1679 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 1681 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
1680 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin), 1682 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin),
1681 GetUTF8Offset(text, scheme.end())); 1683 GetUTF8Offset(text, scheme.end()));
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { 2157 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() {
2156 // By default, GtkTextView layouts an anchored child widget just above the 2158 // By default, GtkTextView layouts an anchored child widget just above the
2157 // baseline, so we need to move the |instant_view_| down to make sure it 2159 // baseline, so we need to move the |instant_view_| down to make sure it
2158 // has the same baseline as the |text_view_|. 2160 // has the same baseline as the |text_view_|.
2159 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2161 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2160 int height; 2162 int height;
2161 pango_layout_get_size(layout, NULL, &height); 2163 pango_layout_get_size(layout, NULL, &height);
2162 int baseline = pango_layout_get_baseline(layout); 2164 int baseline = pango_layout_get_baseline(layout);
2163 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2165 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2164 } 2166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698