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

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

Issue 11369137: Implement {Start,Stop}CapturingKeyStrokes for Instant. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Switch order in BIC. 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
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool popup_window_mode, 217 bool popup_window_mode,
218 LocationBarView* location_bar) 218 LocationBarView* location_bar)
219 : OmniboxView(profile, controller, toolbar_model, command_updater), 219 : OmniboxView(profile, controller, toolbar_model, command_updater),
220 textfield_(NULL), 220 textfield_(NULL),
221 popup_window_mode_(popup_window_mode), 221 popup_window_mode_(popup_window_mode),
222 security_level_(ToolbarModel::NONE), 222 security_level_(ToolbarModel::NONE),
223 ime_composing_before_change_(false), 223 ime_composing_before_change_(false),
224 delete_at_end_pressed_(false), 224 delete_at_end_pressed_(false),
225 location_bar_view_(location_bar), 225 location_bar_view_(location_bar),
226 ime_candidate_window_open_(false), 226 ime_candidate_window_open_(false),
227 select_all_on_mouse_release_(false) { 227 select_all_on_mouse_release_(false),
228 visible_caret_color_(SK_ColorBLACK) {
228 } 229 }
229 230
230 OmniboxViewViews::~OmniboxViewViews() { 231 OmniboxViewViews::~OmniboxViewViews() {
231 #if defined(OS_CHROMEOS) 232 #if defined(OS_CHROMEOS)
232 chromeos::input_method::InputMethodManager::GetInstance()-> 233 chromeos::input_method::InputMethodManager::GetInstance()->
233 RemoveCandidateWindowObserver(this); 234 RemoveCandidateWindowObserver(this);
234 #endif 235 #endif
235 236
236 // Explicitly teardown members which have a reference to us. Just to be safe 237 // Explicitly teardown members which have a reference to us. Just to be safe
237 // we want them to be destroyed before destroying any other internal state. 238 // we want them to be destroyed before destroying any other internal state.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 std::string OmniboxViewViews::GetClassName() const { 439 std::string OmniboxViewViews::GetClassName() const {
439 return kViewClassName; 440 return kViewClassName;
440 } 441 }
441 442
442 void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { 443 void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
443 if (popup_view_->IsOpen()) 444 if (popup_view_->IsOpen())
444 popup_view_->UpdatePopupAppearance(); 445 popup_view_->UpdatePopupAppearance();
445 } 446 }
446 447
447 //////////////////////////////////////////////////////////////////////////////// 448 ////////////////////////////////////////////////////////////////////////////////
448 // OmniboxViewViews, AutocopmleteEditView implementation: 449 // OmniboxViewViews, OmniboxView implementation:
449 450
450 void OmniboxViewViews::SaveStateToTab(WebContents* tab) { 451 void OmniboxViewViews::SaveStateToTab(WebContents* tab) {
451 DCHECK(tab); 452 DCHECK(tab);
452 453
453 // We don't want to keep the IME status, so force quit the current 454 // We don't want to keep the IME status, so force quit the current
454 // session here. It may affect the selection status, so order is 455 // session here. It may affect the selection status, so order is
455 // also important. 456 // also important.
456 if (textfield_->IsIMEComposing()) { 457 if (textfield_->IsIMEComposing()) {
457 textfield_->GetTextInputClient()->ConfirmCompositionText(); 458 textfield_->GetTextInputClient()->ConfirmCompositionText();
458 textfield_->GetInputMethod()->CancelComposition(textfield_); 459 textfield_->GetInputMethod()->CancelComposition(textfield_);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // the text, or in the middle of composition. 568 // the text, or in the middle of composition.
568 ui::Range sel; 569 ui::Range sel;
569 textfield_->GetSelectedRange(&sel); 570 textfield_->GetSelectedRange(&sel);
570 bool no_inline_autocomplete = 571 bool no_inline_autocomplete =
571 sel.GetMax() < GetTextLength() || textfield_->IsIMEComposing(); 572 sel.GetMax() < GetTextLength() || textfield_->IsIMEComposing();
572 573
573 model()->StartAutocomplete(!sel.is_empty(), no_inline_autocomplete); 574 model()->StartAutocomplete(!sel.is_empty(), no_inline_autocomplete);
574 } 575 }
575 576
576 void OmniboxViewViews::SetFocus() { 577 void OmniboxViewViews::SetFocus() {
578 model()->SetFocusVisibility(true);
577 // In views-implementation, the focus is on textfield rather than OmniboxView. 579 // In views-implementation, the focus is on textfield rather than OmniboxView.
578 textfield_->RequestFocus(); 580 textfield_->RequestFocus();
579 } 581 }
580 582
583 void OmniboxViewViews::ApplyFocusVisibility() {
584 if (textfield_->cursor_color() != textfield_->background_color()) {
Peter Kasting 2012/12/04 02:00:52 Nit: No {}
samarth 2012/12/04 04:55:35 Done.
585 visible_caret_color_ = textfield_->cursor_color();
586 }
587 // Setting the color of the text cursor (caret) to the background color
588 // effectively hides it.
589 textfield_->SetCursorColor(model()->is_focus_visible() ?
590 visible_caret_color_ : textfield_->background_color());
591 }
592
581 void OmniboxViewViews::OnTemporaryTextMaybeChanged( 593 void OmniboxViewViews::OnTemporaryTextMaybeChanged(
582 const string16& display_text, 594 const string16& display_text,
583 bool save_original_selection) { 595 bool save_original_selection) {
584 if (save_original_selection) 596 if (save_original_selection)
585 textfield_->GetSelectedRange(&saved_temporary_selection_); 597 textfield_->GetSelectedRange(&saved_temporary_selection_);
586 598
587 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); 599 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true);
588 } 600 }
589 601
590 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged( 602 bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
591 const string16& display_text, 603 const string16& display_text,
592 size_t user_text_length) { 604 size_t user_text_length) {
593 if (display_text == GetText()) 605 if (display_text == GetText())
594 return false; 606 return false;
595 ui::Range range(display_text.size(), user_text_length); 607 ui::Range range(display_text.size(), user_text_length);
596 SetTextAndSelectedRange(display_text, range); 608 SetTextAndSelectedRange(display_text, range);
597 TextChanged(); 609 TextChanged();
598 return true; 610 return true;
599 } 611 }
600 612
601 void OmniboxViewViews::OnRevertTemporaryText() { 613 void OmniboxViewViews::OnRevertTemporaryText() {
602 textfield_->SelectRange(saved_temporary_selection_); 614 textfield_->SelectRange(saved_temporary_selection_);
603 TextChanged(); 615 TextChanged();
604 } 616 }
605 617
606 void OmniboxViewViews::OnBeforePossibleChange() { 618 void OmniboxViewViews::OnBeforePossibleChange() {
619 // We set the focus to visible here to cover two cases. This is called when
620 // the user directly clicks on the omnibox as well as when a character is
Peter Kasting 2012/12/04 02:00:52 Really, this is called when the user clicks on the
samarth 2012/12/04 04:55:35 It comes through OnBeforeUserAction() which is tri
Peter Kasting 2012/12/04 22:23:32 That's odd.
621 // about to be entered.
622 model()->SetFocusVisibility(true);
607 // Record our state. 623 // Record our state.
608 text_before_change_ = GetText(); 624 text_before_change_ = GetText();
609 textfield_->GetSelectedRange(&sel_before_change_); 625 textfield_->GetSelectedRange(&sel_before_change_);
610 ime_composing_before_change_ = textfield_->IsIMEComposing(); 626 ime_composing_before_change_ = textfield_->IsIMEComposing();
611 } 627 }
612 628
613 bool OmniboxViewViews::OnAfterPossibleChange() { 629 bool OmniboxViewViews::OnAfterPossibleChange() {
614 ui::Range new_sel; 630 ui::Range new_sel;
615 textfield_->GetSelectedRange(&new_sel); 631 textfield_->GetSelectedRange(&new_sel);
616 632
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (!text.empty()) { 950 if (!text.empty()) {
935 // Record this paste, so we can do different behavior. 951 // Record this paste, so we can do different behavior.
936 model()->on_paste(); 952 model()->on_paste();
937 // Force a Paste operation to trigger the text_changed code in 953 // Force a Paste operation to trigger the text_changed code in
938 // OnAfterPossibleChange(), even if identical contents are pasted into the 954 // OnAfterPossibleChange(), even if identical contents are pasted into the
939 // text box. 955 // text box.
940 text_before_change_.clear(); 956 text_before_change_.clear();
941 textfield_->ReplaceSelection(text); 957 textfield_->ReplaceSelection(text);
942 } 958 }
943 } 959 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698