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

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

Issue 10854017: Basic metro snap view omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromeos compilation. Created 8 years, 4 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 | 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/property_bag.h" 8 #include "base/property_bag.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 } // namespace 218 } // namespace
219 219
220 // static 220 // static
221 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews"; 221 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews";
222 222
223 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, 223 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
224 ToolbarModel* toolbar_model, 224 ToolbarModel* toolbar_model,
225 Profile* profile, 225 Profile* profile,
226 CommandUpdater* command_updater, 226 CommandUpdater* command_updater,
227 bool popup_window_mode, 227 WindowMode window_mode,
228 LocationBarView* location_bar) 228 LocationBarView* location_bar)
229 : OmniboxView(profile, controller, toolbar_model, command_updater), 229 : OmniboxView(profile, controller, toolbar_model, command_updater),
230 textfield_(NULL), 230 textfield_(NULL),
231 popup_window_mode_(popup_window_mode), 231 window_mode_(window_mode),
232 security_level_(ToolbarModel::NONE), 232 security_level_(ToolbarModel::NONE),
233 ime_composing_before_change_(false), 233 ime_composing_before_change_(false),
234 delete_at_end_pressed_(false), 234 delete_at_end_pressed_(false),
235 location_bar_view_(location_bar), 235 location_bar_view_(location_bar),
236 ime_candidate_window_open_(false), 236 ime_candidate_window_open_(false),
237 select_all_on_mouse_release_(false) { 237 select_all_on_mouse_release_(false) {
238 if (chrome::search::IsInstantExtendedAPIEnabled( 238 if (chrome::search::IsInstantExtendedAPIEnabled(
239 location_bar_view_->profile())) { 239 location_bar_view_->profile())) {
240 set_background(views::Background::CreateSolidBackground( 240 set_background(views::Background::CreateSolidBackground(
241 chrome::search::kOmniboxBackgroundColor)); 241 chrome::search::kOmniboxBackgroundColor));
(...skipping 15 matching lines...) Expand all
257 // OmniboxViewViews public: 257 // OmniboxViewViews public:
258 258
259 void OmniboxViewViews::Init(views::View* popup_parent_view) { 259 void OmniboxViewViews::Init(views::View* popup_parent_view) {
260 // The height of the text view is going to change based on the font used. We 260 // The height of the text view is going to change based on the font used. We
261 // don't want to stretch the height, and we want it vertically centered. 261 // don't want to stretch the height, and we want it vertically centered.
262 // TODO(oshima): make sure the above happens with views. 262 // TODO(oshima): make sure the above happens with views.
263 textfield_ = new AutocompleteTextfield(this, location_bar_view_); 263 textfield_ = new AutocompleteTextfield(this, location_bar_view_);
264 textfield_->SetController(this); 264 textfield_->SetController(this);
265 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 265 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
266 266
267 if (popup_window_mode_) 267 if (window_mode_ == POPUP)
268 textfield_->SetReadOnly(true); 268 textfield_->SetReadOnly(true);
269 269
270 const int font_size = 270 const int font_size =
271 !popup_window_mode_ && chrome::search::IsInstantExtendedAPIEnabled( 271 (window_mode_ != POPUP) && chrome::search::IsInstantExtendedAPIEnabled(
272 location_bar_view_->profile()) ? 272 location_bar_view_->profile()) ?
273 chrome::search::kOmniboxFontSize : 273 chrome::search::kOmniboxFontSize :
274 GetEditFontPixelSize(popup_window_mode_); 274 GetEditFontPixelSize(window_mode_ == POPUP);
275 const int old_size = textfield_->font().GetFontSize(); 275 const int old_size = textfield_->font().GetFontSize();
276 if (font_size != old_size) 276 if (font_size != old_size)
277 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size)); 277 textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size));
278 278
279 // Create popup view using the same font as |textfield_|'s. 279 // Create popup view using the same font as |textfield_|'s.
280 popup_view_.reset( 280 popup_view_.reset(
281 OmniboxPopupContentsView::Create( 281 OmniboxPopupContentsView::Create(
282 textfield_->font(), this, model(), location_bar_view_, 282 textfield_->font(), this, model(), location_bar_view_,
283 popup_parent_view)); 283 popup_parent_view));
284 284
285 // A null-border to zero out the focused border on textfield. 285 // A null-border to zero out the focused border on textfield.
286 const int vertical_margin = !popup_window_mode_ ? 286 const int vertical_margin = (window_mode_ != POPUP) ?
287 kAutocompleteVerticalMargin : kAutocompleteVerticalMarginInPopup; 287 kAutocompleteVerticalMargin : kAutocompleteVerticalMarginInPopup;
288 set_border(views::Border::CreateEmptyBorder(vertical_margin, 0, 288 set_border(views::Border::CreateEmptyBorder(vertical_margin, 0,
289 vertical_margin, 0)); 289 vertical_margin, 0));
290 #if defined(OS_CHROMEOS) 290 #if defined(OS_CHROMEOS)
291 chromeos::input_method::InputMethodManager::GetInstance()-> 291 chromeos::input_method::InputMethodManager::GetInstance()->
292 AddCandidateWindowObserver(this); 292 AddCandidateWindowObserver(this);
293 #endif 293 #endif
294 } 294 }
295 295
296 gfx::Font OmniboxViewViews::GetFont() { 296 gfx::Font OmniboxViewViews::GetFont() {
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 const ui::Range& range) { 899 const ui::Range& range) {
900 if (text != GetText()) 900 if (text != GetText())
901 textfield_->SetText(text); 901 textfield_->SetText(text);
902 textfield_->SelectRange(range); 902 textfield_->SelectRange(range);
903 } 903 }
904 904
905 string16 OmniboxViewViews::GetSelectedText() const { 905 string16 OmniboxViewViews::GetSelectedText() const {
906 // TODO(oshima): Support instant, IME. 906 // TODO(oshima): Support instant, IME.
907 return textfield_->GetSelectedText(); 907 return textfield_->GetSelectedText();
908 } 908 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698