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/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ::switches::kDisableDwmComposition)) { | 76 ::switches::kDisableDwmComposition)) { |
77 return false; | 77 return false; |
78 } | 78 } |
79 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) | 79 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
80 // Shadows are not supported on (non-ChromeOS) Linux. | 80 // Shadows are not supported on (non-ChromeOS) Linux. |
81 return false; | 81 return false; |
82 #endif | 82 #endif |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 // This view forwards the focus to the search box widget by providing it as a | |
87 // FocusTraversable when a focus search is provided. | |
88 class SearchBoxFocusHost : public views::View { | |
89 public: | |
90 explicit SearchBoxFocusHost(views::Widget* search_box_widget) | |
91 : search_box_widget_(search_box_widget) {} | |
92 | |
93 ~SearchBoxFocusHost() override {} | |
94 | |
95 views::FocusTraversable* GetFocusTraversable() override { | |
96 return search_box_widget_; | |
97 } | |
98 | |
99 private: | |
100 views::Widget* search_box_widget_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(SearchBoxFocusHost); | |
103 }; | |
104 | |
105 // The view for the App List overlay, which appears as a white rounded | 86 // The view for the App List overlay, which appears as a white rounded |
106 // rectangle with the given radius. | 87 // rectangle with the given radius. |
107 class AppListOverlayView : public views::View { | 88 class AppListOverlayView : public views::View { |
108 public: | 89 public: |
109 explicit AppListOverlayView(int corner_radius) | 90 explicit AppListOverlayView(int corner_radius) |
110 : corner_radius_(corner_radius) { | 91 : corner_radius_(corner_radius) { |
111 SetPaintToLayer(true); | 92 SetPaintToLayer(true); |
112 SetVisible(false); | 93 SetVisible(false); |
113 layer()->SetOpacity(0.0f); | 94 layer()->SetOpacity(0.0f); |
114 } | 95 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); | 175 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); |
195 }; | 176 }; |
196 | 177 |
197 //////////////////////////////////////////////////////////////////////////////// | 178 //////////////////////////////////////////////////////////////////////////////// |
198 // AppListView: | 179 // AppListView: |
199 | 180 |
200 AppListView::AppListView(AppListViewDelegate* delegate) | 181 AppListView::AppListView(AppListViewDelegate* delegate) |
201 : delegate_(delegate), | 182 : delegate_(delegate), |
202 app_list_main_view_(nullptr), | 183 app_list_main_view_(nullptr), |
203 speech_view_(nullptr), | 184 speech_view_(nullptr), |
204 search_box_focus_host_(nullptr), | |
205 search_box_widget_(nullptr), | 185 search_box_widget_(nullptr), |
206 search_box_view_(nullptr), | 186 search_box_view_(nullptr), |
207 overlay_view_(nullptr), | 187 overlay_view_(nullptr), |
208 animation_observer_(new HideViewAnimationObserver()) { | 188 animation_observer_(new HideViewAnimationObserver()) { |
209 CHECK(delegate); | 189 CHECK(delegate); |
210 | 190 |
211 delegate_->AddObserver(this); | 191 delegate_->AddObserver(this); |
212 delegate_->GetSpeechUI()->AddObserver(this); | 192 delegate_->GetSpeechUI()->AddObserver(this); |
213 } | 193 } |
214 | 194 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 search_box_widget_params.opacity = | 456 search_box_widget_params.opacity = |
477 views::Widget::InitParams::TRANSLUCENT_WINDOW; | 457 views::Widget::InitParams::TRANSLUCENT_WINDOW; |
478 | 458 |
479 // Create a widget for the SearchBoxView to live in. This allows the | 459 // Create a widget for the SearchBoxView to live in. This allows the |
480 // SearchBoxView to be on top of the custom launcher page's WebContents | 460 // SearchBoxView to be on top of the custom launcher page's WebContents |
481 // (otherwise the search box events will be captured by the WebContents). | 461 // (otherwise the search box events will be captured by the WebContents). |
482 search_box_widget_ = new views::Widget; | 462 search_box_widget_ = new views::Widget; |
483 search_box_widget_->Init(search_box_widget_params); | 463 search_box_widget_->Init(search_box_widget_params); |
484 search_box_widget_->SetContentsView(search_box_view_); | 464 search_box_widget_->SetContentsView(search_box_view_); |
485 | 465 |
486 // The search box will not naturally receive focus by itself (because it is in | |
487 // a separate widget). Create this SearchBoxFocusHost in the main widget to | |
488 // forward the focus search into to the search box. | |
489 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); | |
490 AddChildView(search_box_focus_host_); | |
491 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); | |
492 search_box_widget_->SetFocusTraversableParent( | |
493 GetWidget()->GetFocusTraversable()); | |
494 | |
495 #if defined(USE_AURA) | 466 #if defined(USE_AURA) |
496 // Mouse events on the search box shadow should not be captured. | 467 // Mouse events on the search box shadow should not be captured. |
497 aura::Window* window = search_box_widget_->GetNativeWindow(); | 468 aura::Window* window = search_box_widget_->GetNativeWindow(); |
498 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 469 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
499 new SearchBoxWindowTargeter(search_box_view_))); | 470 new SearchBoxWindowTargeter(search_box_view_))); |
500 #endif | 471 #endif |
501 | 472 |
502 app_list_main_view_->contents_view()->Layout(); | 473 app_list_main_view_->contents_view()->Layout(); |
503 } | 474 } |
504 | 475 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 | 770 |
800 if (will_appear) { | 771 if (will_appear) { |
801 speech_view_->SetVisible(true); | 772 speech_view_->SetVisible(true); |
802 } else { | 773 } else { |
803 app_list_main_view_->SetVisible(true); | 774 app_list_main_view_->SetVisible(true); |
804 search_box_view_->search_box()->RequestFocus(); | 775 search_box_view_->search_box()->RequestFocus(); |
805 } | 776 } |
806 } | 777 } |
807 | 778 |
808 } // namespace app_list | 779 } // namespace app_list |
OLD | NEW |