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

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

Issue 302453002: New animation for the origin chip URL showing/hiding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test failure by checking for NULL extension Created 6 years, 6 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 25 matching lines...) Expand all
36 #include "ui/base/clipboard/scoped_clipboard_writer.h" 36 #include "ui/base/clipboard/scoped_clipboard_writer.h"
37 #include "ui/base/dragdrop/drag_drop_types.h" 37 #include "ui/base/dragdrop/drag_drop_types.h"
38 #include "ui/base/dragdrop/os_exchange_data.h" 38 #include "ui/base/dragdrop/os_exchange_data.h"
39 #include "ui/base/ime/text_input_client.h" 39 #include "ui/base/ime/text_input_client.h"
40 #include "ui/base/ime/text_input_type.h" 40 #include "ui/base/ime/text_input_type.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/models/simple_menu_model.h" 42 #include "ui/base/models/simple_menu_model.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/compositor/layer.h" 44 #include "ui/compositor/layer.h"
45 #include "ui/events/event.h" 45 #include "ui/events/event.h"
46 #include "ui/gfx/animation/slide_animation.h"
47 #include "ui/gfx/canvas.h" 46 #include "ui/gfx/canvas.h"
48 #include "ui/gfx/font_list.h" 47 #include "ui/gfx/font_list.h"
49 #include "ui/gfx/selection_model.h" 48 #include "ui/gfx/selection_model.h"
50 #include "ui/views/border.h" 49 #include "ui/views/border.h"
51 #include "ui/views/button_drag_utils.h" 50 #include "ui/views/button_drag_utils.h"
52 #include "ui/views/controls/textfield/textfield.h" 51 #include "ui/views/controls/textfield/textfield.h"
53 #include "ui/views/ime/input_method.h" 52 #include "ui/views/ime/input_method.h"
54 #include "ui/views/layout/fill_layout.h" 53 #include "ui/views/layout/fill_layout.h"
55 #include "ui/views/views_delegate.h" 54 #include "ui/views/views_delegate.h"
56 #include "ui/views/widget/widget.h" 55 #include "ui/views/widget/widget.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 SetReadOnly(true); 169 SetReadOnly(true);
171 170
172 // Initialize the popup view using the same font. 171 // Initialize the popup view using the same font.
173 popup_view_.reset(OmniboxPopupContentsView::Create( 172 popup_view_.reset(OmniboxPopupContentsView::Create(
174 GetFontList(), this, model(), location_bar_view_)); 173 GetFontList(), this, model(), location_bar_view_));
175 174
176 #if defined(OS_CHROMEOS) 175 #if defined(OS_CHROMEOS)
177 chromeos::input_method::InputMethodManager::Get()-> 176 chromeos::input_method::InputMethodManager::Get()->
178 AddCandidateWindowObserver(this); 177 AddCandidateWindowObserver(this);
179 #endif 178 #endif
180
181 fade_in_animation_.reset(new gfx::SlideAnimation(this));
182 fade_in_animation_->SetTweenType(gfx::Tween::LINEAR);
183 fade_in_animation_->SetSlideDuration(300);
184 }
185
186 void OmniboxViewViews::FadeIn() {
187 fade_in_animation_->Show();
188 } 179 }
189 180
190 void OmniboxViewViews::SaveStateToTab(content::WebContents* tab) { 181 void OmniboxViewViews::SaveStateToTab(content::WebContents* tab) {
191 DCHECK(tab); 182 DCHECK(tab);
192 183
193 // We don't want to keep the IME status, so force quit the current 184 // We don't want to keep the IME status, so force quit the current
194 // session here. It may affect the selection status, so order is 185 // session here. It may affect the selection status, so order is
195 // also important. 186 // also important.
196 if (IsIMEComposing()) { 187 if (IsIMEComposing()) {
197 GetTextInputClient()->ConfirmCompositionText(); 188 GetTextInputClient()->ConfirmCompositionText();
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 return true; 785 return true;
795 } 786 }
796 return Textfield::SkipDefaultKeyEventProcessing(event); 787 return Textfield::SkipDefaultKeyEventProcessing(event);
797 } 788 }
798 789
799 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { 790 void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) {
800 location_bar_view_->GetAccessibleState(state); 791 location_bar_view_->GetAccessibleState(state);
801 state->role = ui::AX_ROLE_TEXT_FIELD; 792 state->role = ui::AX_ROLE_TEXT_FIELD;
802 } 793 }
803 794
804 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) {
805 if (fade_in_animation_->is_animating()) {
806 canvas->SaveLayerAlpha(static_cast<uint8>(
807 fade_in_animation_->CurrentValueBetween(0, 255)));
808 views::Textfield::OnPaint(canvas);
809 canvas->Restore();
810 } else {
811 views::Textfield::OnPaint(canvas);
812 }
813 }
814
815 void OmniboxViewViews::OnFocus() { 795 void OmniboxViewViews::OnFocus() {
816 views::Textfield::OnFocus(); 796 views::Textfield::OnFocus();
817 // TODO(oshima): Get control key state. 797 // TODO(oshima): Get control key state.
818 model()->OnSetFocus(false); 798 model()->OnSetFocus(false);
819 // Don't call controller()->OnSetFocus, this view has already acquired focus. 799 // Don't call controller()->OnSetFocus, this view has already acquired focus.
820 800
821 // Restore the selection we saved in OnBlur() if it's still valid. 801 // Restore the selection we saved in OnBlur() if it's still valid.
822 if (saved_selection_for_focus_change_.IsValid()) { 802 if (saved_selection_for_focus_change_.IsValid()) {
823 SelectRange(saved_selection_for_focus_change_); 803 SelectRange(saved_selection_for_focus_change_);
824 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); 804 saved_selection_for_focus_change_ = gfx::Range::InvalidRange();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 return controller()->GetToolbarModel()->WouldReplaceURL(); 843 return controller()->GetToolbarModel()->WouldReplaceURL();
864 return command_id == IDS_MOVE_DOWN || command_id == IDS_MOVE_UP || 844 return command_id == IDS_MOVE_DOWN || command_id == IDS_MOVE_UP ||
865 Textfield::IsCommandIdEnabled(command_id) || 845 Textfield::IsCommandIdEnabled(command_id) ||
866 command_updater()->IsCommandEnabled(command_id); 846 command_updater()->IsCommandEnabled(command_id);
867 } 847 }
868 848
869 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { 849 base::string16 OmniboxViewViews::GetSelectionClipboardText() const {
870 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); 850 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText());
871 } 851 }
872 852
873 void OmniboxViewViews::AnimationProgressed(const gfx::Animation* animation) {
874 SchedulePaint();
875 }
876
877 void OmniboxViewViews::AnimationEnded(const gfx::Animation* animation) {
878 fade_in_animation_->Reset();
879 }
880
881 #if defined(OS_CHROMEOS) 853 #if defined(OS_CHROMEOS)
882 void OmniboxViewViews::CandidateWindowOpened( 854 void OmniboxViewViews::CandidateWindowOpened(
883 chromeos::input_method::InputMethodManager* manager) { 855 chromeos::input_method::InputMethodManager* manager) {
884 ime_candidate_window_open_ = true; 856 ime_candidate_window_open_ = true;
885 } 857 }
886 858
887 void OmniboxViewViews::CandidateWindowClosed( 859 void OmniboxViewViews::CandidateWindowClosed(
888 chromeos::input_method::InputMethodManager* manager) { 860 chromeos::input_method::InputMethodManager* manager) {
889 ime_candidate_window_open_ = false; 861 ime_candidate_window_open_ = false;
890 } 862 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 menu_contents->InsertItemWithStringIdAt( 1009 menu_contents->InsertItemWithStringIdAt(
1038 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1010 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1039 } 1011 }
1040 1012
1041 // Minor note: We use IDC_ for command id here while the underlying textfield 1013 // Minor note: We use IDC_ for command id here while the underlying textfield
1042 // is using IDS_ for all its command ids. This is because views cannot depend 1014 // is using IDS_ for all its command ids. This is because views cannot depend
1043 // on IDC_ for now. 1015 // on IDC_ for now.
1044 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1016 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1045 IDS_EDIT_SEARCH_ENGINES); 1017 IDS_EDIT_SEARCH_ENGINES);
1046 } 1018 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698