| 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 "ui/app_list/views/search_box_view.h" | 5 #include "ui/app_list/views/search_box_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return CustomButton::OnKeyPressed(event); | 98 return CustomButton::OnKeyPressed(event); |
| 99 } | 99 } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 // views::View overrides: | 102 // views::View overrides: |
| 103 void OnPaintBackground(gfx::Canvas* canvas) override { | 103 void OnPaintBackground(gfx::Canvas* canvas) override { |
| 104 if (state() == STATE_HOVERED || state() == STATE_PRESSED || selected_) | 104 if (state() == STATE_HOVERED || state() == STATE_PRESSED || selected_) |
| 105 canvas->FillRect(gfx::Rect(size()), kSelectedColor); | 105 canvas->FillRect(gfx::Rect(size()), kSelectedColor); |
| 106 } | 106 } |
| 107 | 107 |
| 108 const char* GetClassName() const override { return "SearchBoxImageButton"; } |
| 109 |
| 108 bool selected_; | 110 bool selected_; |
| 109 | 111 |
| 110 DISALLOW_COPY_AND_ASSIGN(SearchBoxImageButton); | 112 DISALLOW_COPY_AND_ASSIGN(SearchBoxImageButton); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, | 115 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, |
| 114 AppListViewDelegate* view_delegate) | 116 AppListViewDelegate* view_delegate) |
| 115 : delegate_(delegate), | 117 : delegate_(delegate), |
| 116 view_delegate_(view_delegate), | 118 view_delegate_(view_delegate), |
| 117 model_(NULL), | 119 model_(NULL), |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 296 |
| 295 return false; | 297 return false; |
| 296 } | 298 } |
| 297 | 299 |
| 298 void SearchBoxView::OnEnabledChanged() { | 300 void SearchBoxView::OnEnabledChanged() { |
| 299 search_box_->SetEnabled(enabled()); | 301 search_box_->SetEnabled(enabled()); |
| 300 if (speech_button_) | 302 if (speech_button_) |
| 301 speech_button_->SetEnabled(enabled()); | 303 speech_button_->SetEnabled(enabled()); |
| 302 } | 304 } |
| 303 | 305 |
| 306 const char* SearchBoxView::GetClassName() const { |
| 307 return "SearchBoxView"; |
| 308 } |
| 309 |
| 304 void SearchBoxView::UpdateModel() { | 310 void SearchBoxView::UpdateModel() { |
| 305 // Temporarily remove from observer to ignore notifications caused by us. | 311 // Temporarily remove from observer to ignore notifications caused by us. |
| 306 model_->search_box()->RemoveObserver(this); | 312 model_->search_box()->RemoveObserver(this); |
| 307 model_->search_box()->Update(search_box_->text(), false); | 313 model_->search_box()->Update(search_box_->text(), false); |
| 308 model_->search_box()->SetSelectionModel(search_box_->GetSelectionModel()); | 314 model_->search_box()->SetSelectionModel(search_box_->GetSelectionModel()); |
| 309 model_->search_box()->AddObserver(this); | 315 model_->search_box()->AddObserver(this); |
| 310 } | 316 } |
| 311 | 317 |
| 312 void SearchBoxView::NotifyQueryChanged() { | 318 void SearchBoxView::NotifyQueryChanged() { |
| 313 DCHECK(delegate_); | 319 DCHECK(delegate_); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 NotifyQueryChanged(); | 433 NotifyQueryChanged(); |
| 428 } | 434 } |
| 429 | 435 |
| 430 void SearchBoxView::OnSpeechRecognitionStateChanged( | 436 void SearchBoxView::OnSpeechRecognitionStateChanged( |
| 431 SpeechRecognitionState new_state) { | 437 SpeechRecognitionState new_state) { |
| 432 SpeechRecognitionButtonPropChanged(); | 438 SpeechRecognitionButtonPropChanged(); |
| 433 SchedulePaint(); | 439 SchedulePaint(); |
| 434 } | 440 } |
| 435 | 441 |
| 436 } // namespace app_list | 442 } // namespace app_list |
| OLD | NEW |