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 its | |
Matt Giuca
2015/02/27 06:29:38
"its" -> "it as a"
calamity
2015/03/02 03:34:53
Done.
| |
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 | |
86 // The view for the App List overlay, which appears as a white rounded | 105 // The view for the App List overlay, which appears as a white rounded |
87 // rectangle with the given radius. | 106 // rectangle with the given radius. |
88 class AppListOverlayView : public views::View { | 107 class AppListOverlayView : public views::View { |
89 public: | 108 public: |
90 explicit AppListOverlayView(int corner_radius) | 109 explicit AppListOverlayView(int corner_radius) |
91 : corner_radius_(corner_radius) { | 110 : corner_radius_(corner_radius) { |
92 SetPaintToLayer(true); | 111 SetPaintToLayer(true); |
93 SetVisible(false); | 112 SetVisible(false); |
94 layer()->SetOpacity(0.0f); | 113 layer()->SetOpacity(0.0f); |
95 } | 114 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); | 194 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); |
176 }; | 195 }; |
177 | 196 |
178 //////////////////////////////////////////////////////////////////////////////// | 197 //////////////////////////////////////////////////////////////////////////////// |
179 // AppListView: | 198 // AppListView: |
180 | 199 |
181 AppListView::AppListView(AppListViewDelegate* delegate) | 200 AppListView::AppListView(AppListViewDelegate* delegate) |
182 : delegate_(delegate), | 201 : delegate_(delegate), |
183 app_list_main_view_(nullptr), | 202 app_list_main_view_(nullptr), |
184 speech_view_(nullptr), | 203 speech_view_(nullptr), |
204 search_box_focus_host_(nullptr), | |
185 search_box_widget_(nullptr), | 205 search_box_widget_(nullptr), |
186 search_box_view_(nullptr), | 206 search_box_view_(nullptr), |
187 overlay_view_(nullptr), | 207 overlay_view_(nullptr), |
188 animation_observer_(new HideViewAnimationObserver()) { | 208 animation_observer_(new HideViewAnimationObserver()) { |
189 CHECK(delegate); | 209 CHECK(delegate); |
190 | 210 |
191 delegate_->AddObserver(this); | 211 delegate_->AddObserver(this); |
192 delegate_->GetSpeechUI()->AddObserver(this); | 212 delegate_->GetSpeechUI()->AddObserver(this); |
193 } | 213 } |
194 | 214 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 search_box_widget_params.opacity = | 476 search_box_widget_params.opacity = |
457 views::Widget::InitParams::TRANSLUCENT_WINDOW; | 477 views::Widget::InitParams::TRANSLUCENT_WINDOW; |
458 | 478 |
459 // Create a widget for the SearchBoxView to live in. This allows the | 479 // Create a widget for the SearchBoxView to live in. This allows the |
460 // SearchBoxView to be on top of the custom launcher page's WebContents | 480 // SearchBoxView to be on top of the custom launcher page's WebContents |
461 // (otherwise the search box events will be captured by the WebContents). | 481 // (otherwise the search box events will be captured by the WebContents). |
462 search_box_widget_ = new views::Widget; | 482 search_box_widget_ = new views::Widget; |
463 search_box_widget_->Init(search_box_widget_params); | 483 search_box_widget_->Init(search_box_widget_params); |
464 search_box_widget_->SetContentsView(search_box_view_); | 484 search_box_widget_->SetContentsView(search_box_view_); |
465 | 485 |
486 // Set up search box widget focus. | |
Matt Giuca
2015/02/27 06:29:38
// The search box will not naturally receive focus
calamity
2015/03/02 03:34:53
Reworded the end of the sentence since the SBFH ne
| |
487 search_box_focus_host_ = new SearchBoxFocusHost(search_box_widget_); | |
488 AddChildView(search_box_focus_host_); | |
489 search_box_widget_->SetFocusTraversableParentView(search_box_focus_host_); | |
490 search_box_widget_->SetFocusTraversableParent( | |
491 GetWidget()->GetFocusTraversable()); | |
492 | |
466 #if defined(USE_AURA) | 493 #if defined(USE_AURA) |
467 // Mouse events on the search box shadow should not be captured. | 494 // Mouse events on the search box shadow should not be captured. |
468 aura::Window* window = search_box_widget_->GetNativeWindow(); | 495 aura::Window* window = search_box_widget_->GetNativeWindow(); |
469 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( | 496 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
470 new SearchBoxWindowTargeter(search_box_view_))); | 497 new SearchBoxWindowTargeter(search_box_view_))); |
471 #endif | 498 #endif |
472 | 499 |
473 app_list_main_view_->contents_view()->Layout(); | 500 app_list_main_view_->contents_view()->Layout(); |
474 } | 501 } |
475 | 502 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 | 797 |
771 if (will_appear) { | 798 if (will_appear) { |
772 speech_view_->SetVisible(true); | 799 speech_view_->SetVisible(true); |
773 } else { | 800 } else { |
774 app_list_main_view_->SetVisible(true); | 801 app_list_main_view_->SetVisible(true); |
775 search_box_view_->search_box()->RequestFocus(); | 802 search_box_view_->search_box()->RequestFocus(); |
776 } | 803 } |
777 } | 804 } |
778 | 805 |
779 } // namespace app_list | 806 } // namespace app_list |
OLD | NEW |