| OLD | NEW |
| 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/search/toolbar_search_animator.h" | 5 #include "chrome/browser/ui/search/toolbar_search_animator.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/search/search_model.h" | 7 #include "chrome/browser/ui/search/search_model.h" |
| 8 #include "chrome/browser/ui/search/search_types.h" | 8 #include "chrome/browser/ui/search/search_types.h" |
| 9 #include "chrome/browser/ui/search/toolbar_search_animator_observer.h" | 9 #include "chrome/browser/ui/search/toolbar_search_animator_observer.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 11 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 12 #include "chrome/browser/ui/webui/instant_ui.h" | 11 #include "chrome/browser/ui/webui/instant_ui.h" |
| 13 #include "ui/base/animation/multi_animation.h" | 12 #include "ui/base/animation/multi_animation.h" |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 const int kBackgroundChangeDelayMs = 100; | 16 const int kBackgroundChangeDelayMs = 100; |
| 18 const int kBackgroundChangeDurationMs = 200; | 17 const int kBackgroundChangeDurationMs = 200; |
| 19 | 18 |
| 20 const double kMinOpacity = 0.0f; | 19 const double kMinOpacity = 0.0f; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 !toolbar_model_->input_in_progress()) || | 57 !toolbar_model_->input_in_progress()) || |
| 59 search_model_->mode().is_default()); | 58 search_model_->mode().is_default()); |
| 60 } | 59 } |
| 61 | 60 |
| 62 void ToolbarSearchAnimator::OnOmniboxPopupClosed() { | 61 void ToolbarSearchAnimator::OnOmniboxPopupClosed() { |
| 63 is_omnibox_popup_open_ = false; | 62 is_omnibox_popup_open_ = false; |
| 64 FOR_EACH_OBSERVER(ToolbarSearchAnimatorObserver, observers_, | 63 FOR_EACH_OBSERVER(ToolbarSearchAnimatorObserver, observers_, |
| 65 OnToolbarSeparatorChanged()); | 64 OnToolbarSeparatorChanged()); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void ToolbarSearchAnimator::FinishAnimation(TabContents* tab_contents) { | 67 void ToolbarSearchAnimator::FinishAnimation( |
| 69 Reset(tab_contents); | 68 content::WebContents* web_contents) { |
| 69 Reset(web_contents); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ToolbarSearchAnimator::AddObserver( | 72 void ToolbarSearchAnimator::AddObserver( |
| 73 ToolbarSearchAnimatorObserver* observer) { | 73 ToolbarSearchAnimatorObserver* observer) { |
| 74 observers_.AddObserver(observer); | 74 observers_.AddObserver(observer); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ToolbarSearchAnimator::RemoveObserver( | 77 void ToolbarSearchAnimator::RemoveObserver( |
| 78 ToolbarSearchAnimatorObserver* observer) { | 78 ToolbarSearchAnimatorObserver* observer) { |
| 79 observers_.RemoveObserver(observer); | 79 observers_.RemoveObserver(observer); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 background_animation_.reset(new ui::MultiAnimation(parts)); | 139 background_animation_.reset(new ui::MultiAnimation(parts)); |
| 140 background_animation_->set_continuous(false); | 140 background_animation_->set_continuous(false); |
| 141 background_animation_->set_delegate(this); | 141 background_animation_->set_delegate(this); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ToolbarSearchAnimator::StartBackgroundChange() { | 144 void ToolbarSearchAnimator::StartBackgroundChange() { |
| 145 InitBackgroundAnimation(); | 145 InitBackgroundAnimation(); |
| 146 background_animation_->Start(); | 146 background_animation_->Start(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ToolbarSearchAnimator::Reset(TabContents* tab_contents) { | 149 void ToolbarSearchAnimator::Reset(content::WebContents* web_contents) { |
| 150 bool notify_background_observers = | 150 bool notify_background_observers = |
| 151 background_animation_.get() && background_animation_->is_animating(); | 151 background_animation_.get() && background_animation_->is_animating(); |
| 152 | 152 |
| 153 background_animation_.reset(); | 153 background_animation_.reset(); |
| 154 | 154 |
| 155 // Notify observers of animation cancelation. | 155 // Notify observers of animation cancelation. |
| 156 if (notify_background_observers) { | 156 if (notify_background_observers) { |
| 157 FOR_EACH_OBSERVER(ToolbarSearchAnimatorObserver, observers_, | 157 FOR_EACH_OBSERVER(ToolbarSearchAnimatorObserver, observers_, |
| 158 OnToolbarBackgroundAnimatorCanceled(tab_contents)); | 158 OnToolbarBackgroundAnimatorCanceled(web_contents)); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace search | 162 } // namespace search |
| 163 } // namespace chrome | 163 } // namespace chrome |
| OLD | NEW |