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

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

Issue 11421204: Use native theme colors for textfields; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nix cursor color; adjust textfield functions; add read-only theme colors. Created 8 years 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 bool result = views::Textfield::OnMouseDragged(event); 187 bool result = views::Textfield::OnMouseDragged(event);
188 omnibox_view_->HandleMouseDragEvent(event); 188 omnibox_view_->HandleMouseDragEvent(event);
189 return result; 189 return result;
190 } 190 }
191 191
192 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { 192 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE {
193 views::Textfield::OnMouseReleased(event); 193 views::Textfield::OnMouseReleased(event);
194 omnibox_view_->HandleMouseReleaseEvent(event); 194 omnibox_view_->HandleMouseReleaseEvent(event);
195 } 195 }
196 196
197 protected:
198 // views::View implementation.
199 virtual void PaintChildren(gfx::Canvas* canvas) {
200 views::Textfield::PaintChildren(canvas);
201 }
202
203 private: 197 private:
204 OmniboxViewViews* omnibox_view_; 198 OmniboxViewViews* omnibox_view_;
205 LocationBarView* location_bar_view_; 199 LocationBarView* location_bar_view_;
206 200
207 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); 201 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield);
208 }; 202 };
209 203
210 // static 204 // static
211 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews"; 205 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews";
212 206
(...skipping 28 matching lines...) Expand all
241 //////////////////////////////////////////////////////////////////////////////// 235 ////////////////////////////////////////////////////////////////////////////////
242 // OmniboxViewViews public: 236 // OmniboxViewViews public:
243 237
244 void OmniboxViewViews::Init() { 238 void OmniboxViewViews::Init() {
245 // The height of the text view is going to change based on the font used. We 239 // The height of the text view is going to change based on the font used. We
246 // don't want to stretch the height, and we want it vertically centered. 240 // don't want to stretch the height, and we want it vertically centered.
247 // TODO(oshima): make sure the above happens with views. 241 // TODO(oshima): make sure the above happens with views.
248 textfield_ = new AutocompleteTextfield(this, location_bar_view_); 242 textfield_ = new AutocompleteTextfield(this, location_bar_view_);
249 textfield_->SetController(this); 243 textfield_->SetController(this);
250 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 244 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
251 textfield_->SetBackgroundColor(location_bar_view_->GetColor(
252 ToolbarModel::NONE, LocationBarView::BACKGROUND));
253
254 if (popup_window_mode_) 245 if (popup_window_mode_)
255 textfield_->SetReadOnly(true); 246 textfield_->SetReadOnly(true);
256 247
257 const int font_size = GetEditFontPixelSize(popup_window_mode_); 248 const int font_size = GetEditFontPixelSize(popup_window_mode_);
258 const int old_size = textfield_->font().GetFontSize(); 249 const int old_size = textfield_->font().GetFontSize();
259 if (font_size != old_size) 250 if (font_size != old_size)
260 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size)); 251 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size));
261 252
262 // Create popup view using the same font as |textfield_|'s. 253 // Create popup view using the same font as |textfield_|'s.
263 popup_view_.reset( 254 popup_view_.reset(
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (!text.empty()) { 925 if (!text.empty()) {
935 // Record this paste, so we can do different behavior. 926 // Record this paste, so we can do different behavior.
936 model()->on_paste(); 927 model()->on_paste();
937 // Force a Paste operation to trigger the text_changed code in 928 // Force a Paste operation to trigger the text_changed code in
938 // OnAfterPossibleChange(), even if identical contents are pasted into the 929 // OnAfterPossibleChange(), even if identical contents are pasted into the
939 // text box. 930 // text box.
940 text_before_change_.clear(); 931 text_before_change_.clear();
941 textfield_->ReplaceSelection(text); 932 textfield_->ReplaceSelection(text);
942 } 933 }
943 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698