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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 11360144: Converts some of the omnibox related classes to support multiple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // OmniboxViewViews public: 234 // OmniboxViewViews public:
235 235
236 void OmniboxViewViews::Init() { 236 void OmniboxViewViews::Init() {
237 // The height of the text view is going to change based on the font used. We 237 // The height of the text view is going to change based on the font used. We
238 // don't want to stretch the height, and we want it vertically centered. 238 // don't want to stretch the height, and we want it vertically centered.
239 // TODO(oshima): make sure the above happens with views. 239 // TODO(oshima): make sure the above happens with views.
240 textfield_ = new AutocompleteTextfield(this, location_bar_view_); 240 textfield_ = new AutocompleteTextfield(this, location_bar_view_);
241 textfield_->SetController(this); 241 textfield_->SetController(this);
242 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 242 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
243 textfield_->SetBackgroundColor(LocationBarView::GetColor( 243 textfield_->SetBackgroundColor(LocationBarView::GetColor(
244 ToolbarModel::NONE, LocationBarView::BACKGROUND)); 244 GetNativeTheme(), ToolbarModel::NONE, LocationBarView::BACKGROUND));
245 245
246 if (popup_window_mode_) 246 if (popup_window_mode_)
247 textfield_->SetReadOnly(true); 247 textfield_->SetReadOnly(true);
248 248
249 const int font_size = GetEditFontPixelSize(popup_window_mode_); 249 const int font_size = GetEditFontPixelSize(popup_window_mode_);
250 const int old_size = textfield_->font().GetFontSize(); 250 const int old_size = textfield_->font().GetFontSize();
251 if (font_size != old_size) 251 if (font_size != old_size)
252 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size)); 252 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size));
253 253
254 // Create popup view using the same font as |textfield_|'s. 254 // Create popup view using the same font as |textfield_|'s.
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 // by Parse(), ask the model, which will check the desired page transition for 852 // by Parse(), ask the model, which will check the desired page transition for
853 // this input. This can tell us whether an UNKNOWN input string is going to 853 // this input. This can tell us whether an UNKNOWN input string is going to
854 // be treated as a search or a navigation, and is the same method the Paste 854 // be treated as a search or a navigation, and is the same method the Paste
855 // And Go system uses. 855 // And Go system uses.
856 string16 text = GetText(); 856 string16 text = GetText();
857 url_parse::Component scheme, host; 857 url_parse::Component scheme, host;
858 AutocompleteInput::ParseForEmphasizeComponents(text, model()->GetDesiredTLD(), 858 AutocompleteInput::ParseForEmphasizeComponents(text, model()->GetDesiredTLD(),
859 &scheme, &host); 859 &scheme, &host);
860 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 860 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
861 861
862 const ui::NativeTheme* theme = GetNativeTheme();
Peter Kasting 2012/11/08 18:55:47 I'd remove either the blank above or the blank bel
863
862 SkColor base_color = LocationBarView::GetColor( 864 SkColor base_color = LocationBarView::GetColor(
863 security_level_, 865 theme, security_level_,
864 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT); 866 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT);
865 ApplyURLStyle(textfield_, 0, text.length(), base_color, false); 867 ApplyURLStyle(textfield_, 0, text.length(), base_color, false);
866 868
867 if (emphasize) { 869 if (emphasize) {
868 SkColor normal_color = 870 SkColor normal_color = LocationBarView::GetColor(
869 LocationBarView::GetColor(security_level_, LocationBarView::TEXT); 871 theme, security_level_, LocationBarView::TEXT);
870 ApplyURLStyle(textfield_, host.begin, host.end(), normal_color, false); 872 ApplyURLStyle(textfield_, host.begin, host.end(), normal_color, false);
871 } 873 }
872 874
873 // Emphasize the scheme for security UI display purposes (if necessary). 875 // Emphasize the scheme for security UI display purposes (if necessary).
874 // Note that we check CurrentTextIsURL() because if we're replacing search 876 // Note that we check CurrentTextIsURL() because if we're replacing search
875 // URLs with search terms, we may have a non-URL even when the user is not 877 // URLs with search terms, we may have a non-URL even when the user is not
876 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser 878 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser
877 // may have incorrectly identified a qualifier as a scheme. 879 // may have incorrectly identified a qualifier as a scheme.
878 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 880 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
879 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 881 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
880 SkColor security_color = LocationBarView::GetColor( 882 SkColor security_color = LocationBarView::GetColor(
881 security_level_, LocationBarView::SECURITY_TEXT); 883 theme, security_level_, LocationBarView::SECURITY_TEXT);
882 bool use_strikethrough = (security_level_ == ToolbarModel::SECURITY_ERROR); 884 bool use_strikethrough = (security_level_ == ToolbarModel::SECURITY_ERROR);
883 ApplyURLStyle(textfield_, scheme.begin, scheme.end(), 885 ApplyURLStyle(textfield_, scheme.begin, scheme.end(),
884 security_color, use_strikethrough); 886 security_color, use_strikethrough);
885 } 887 }
886 } 888 }
887 889
888 void OmniboxViewViews::SetTextAndSelectedRange(const string16& text, 890 void OmniboxViewViews::SetTextAndSelectedRange(const string16& text,
889 const ui::Range& range) { 891 const ui::Range& range) {
890 if (text != GetText()) 892 if (text != GetText())
891 textfield_->SetText(text); 893 textfield_->SetText(text);
892 textfield_->SelectRange(range); 894 textfield_->SelectRange(range);
893 } 895 }
894 896
895 string16 OmniboxViewViews::GetSelectedText() const { 897 string16 OmniboxViewViews::GetSelectedText() const {
896 // TODO(oshima): Support instant, IME. 898 // TODO(oshima): Support instant, IME.
897 return textfield_->GetSelectedText(); 899 return textfield_->GetSelectedText();
898 } 900 }
899 901
900 void OmniboxViewViews::CopyURL() { 902 void OmniboxViewViews::CopyURL() {
901 const string16& text = toolbar_model()->GetText(false); 903 const string16& text = toolbar_model()->GetText(false);
902 DoCopy(text, true, toolbar_model()->GetURL(), text); 904 DoCopy(text, true, toolbar_model()->GetURL(), text);
903 } 905 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698