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

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: Not hacky anymore 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, host;
Devlin 2013/03/27 15:59:52 Chrome style says to put each variable declaration
Patrick Riordan 2013/03/27 19:43:28 Done.
1641 string16 text(GetText()); 1641 string16 text(GetText());
1642 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host); 1642 AutocompleteInput::ParseForEmphasizeComponents(text, &scheme, &host);
1643 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 1643 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
1644 1644
1645 // Set the baseline emphasis. 1645 // Set the baseline emphasis.
1646 GtkTextIter start, end; 1646 GtkTextIter start, end;
Devlin 2013/03/27 15:59:52 Same as 1640.
Patrick Riordan 2013/03/27 19:43:28 Done.
1647 GetTextBufferBounds(&start, &end); 1647 GetTextBufferBounds(&start, &end);
1648 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end); 1648 gtk_text_buffer_remove_all_tags(text_buffer_, &start, &end);
1649 if (emphasize) { 1649 if (emphasize) {
1650 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end); 1650 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end);
1651 1651
1652 // We've found a host name, give it more emphasis. 1652 if (!toolbar_model()->ShouldNotEmphasizeHost()) {
1653 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0, 1653
Devlin 2013/03/27 15:59:52 remove extra newline.
Patrick Riordan 2013/03/27 19:43:28 Done.
1654 // We've found a host name, give it more emphasis.
1655 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &start, 0,
1654 GetUTF8Offset(text, 1656 GetUTF8Offset(text,
Devlin 2013/03/27 15:59:52 Need to fix line wrapping.
Patrick Riordan 2013/03/27 19:43:28 Done.
1655 host.begin)); 1657 host.begin));
1656 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0, 1658 gtk_text_buffer_get_iter_at_line_index(text_buffer_, &end, 0,
1657 GetUTF8Offset(text, 1659 GetUTF8Offset(text,
1658 host.end())); 1660 host.end()));
1659 1661
1660 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1662 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1663 }
1661 } else { 1664 } else {
1662 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end); 1665 gtk_text_buffer_apply_tag(text_buffer_, normal_text_tag_, &start, &end);
1663 } 1666 }
1664 1667
1665 strikethrough_ = CharRange(); 1668 strikethrough_ = CharRange();
1666 // Emphasize the scheme for security UI display purposes (if necessary). 1669 // Emphasize the scheme for security UI display purposes (if necessary).
1667 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 1670 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
1668 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 1671 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
1669 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin), 1672 CharRange scheme_range = CharRange(GetUTF8Offset(text, scheme.begin),
1670 GetUTF8Offset(text, scheme.end())); 1673 GetUTF8Offset(text, scheme.end()));
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { 2147 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() {
2145 // By default, GtkTextView layouts an anchored child widget just above the 2148 // 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 2149 // baseline, so we need to move the |instant_view_| down to make sure it
2147 // has the same baseline as the |text_view_|. 2150 // has the same baseline as the |text_view_|.
2148 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2151 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2149 int height; 2152 int height;
2150 pango_layout_get_size(layout, NULL, &height); 2153 pango_layout_get_size(layout, NULL, &height);
2151 int baseline = pango_layout_get_baseline(layout); 2154 int baseline = pango_layout_get_baseline(layout);
2152 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2155 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2153 } 2156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698