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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 #include "ui/app_list/app_list_constants.h" | 12 #include "ui/app_list/app_list_constants.h" |
13 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
14 #include "ui/app_list/app_list_view_delegate.h" | 14 #include "ui/app_list/app_list_view_delegate.h" |
15 #include "ui/app_list/pagination_model.h" | 15 #include "ui/app_list/pagination_model.h" |
16 #include "ui/app_list/signin_delegate.h" | |
17 #include "ui/app_list/speech_ui_model.h" | 16 #include "ui/app_list/speech_ui_model.h" |
18 #include "ui/app_list/views/app_list_background.h" | 17 #include "ui/app_list/views/app_list_background.h" |
19 #include "ui/app_list/views/app_list_folder_view.h" | 18 #include "ui/app_list/views/app_list_folder_view.h" |
20 #include "ui/app_list/views/app_list_main_view.h" | 19 #include "ui/app_list/views/app_list_main_view.h" |
21 #include "ui/app_list/views/app_list_view_observer.h" | 20 #include "ui/app_list/views/app_list_view_observer.h" |
22 #include "ui/app_list/views/apps_container_view.h" | 21 #include "ui/app_list/views/apps_container_view.h" |
23 #include "ui/app_list/views/contents_view.h" | 22 #include "ui/app_list/views/contents_view.h" |
24 #include "ui/app_list/views/search_box_view.h" | 23 #include "ui/app_list/views/search_box_view.h" |
25 #include "ui/app_list/views/signin_view.h" | |
26 #include "ui/app_list/views/speech_view.h" | 24 #include "ui/app_list/views/speech_view.h" |
27 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
28 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
29 #include "ui/compositor/layer_animation_observer.h" | 27 #include "ui/compositor/layer_animation_observer.h" |
30 #include "ui/compositor/scoped_layer_animation_settings.h" | 28 #include "ui/compositor/scoped_layer_animation_settings.h" |
31 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
33 #include "ui/gfx/insets.h" | 31 #include "ui/gfx/insets.h" |
34 #include "ui/gfx/path.h" | 32 #include "ui/gfx/path.h" |
35 #include "ui/gfx/skia_util.h" | 33 #include "ui/gfx/skia_util.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 139 |
142 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); | 140 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); |
143 }; | 141 }; |
144 | 142 |
145 //////////////////////////////////////////////////////////////////////////////// | 143 //////////////////////////////////////////////////////////////////////////////// |
146 // AppListView: | 144 // AppListView: |
147 | 145 |
148 AppListView::AppListView(AppListViewDelegate* delegate) | 146 AppListView::AppListView(AppListViewDelegate* delegate) |
149 : delegate_(delegate), | 147 : delegate_(delegate), |
150 app_list_main_view_(NULL), | 148 app_list_main_view_(NULL), |
151 signin_view_(NULL), | |
calamity
2014/06/02 04:36:15
This file needs corresponding changes to the heade
benwells
2014/06/02 07:48:55
Done.
| |
152 speech_view_(NULL), | 149 speech_view_(NULL), |
153 overlay_view_(NULL), | 150 overlay_view_(NULL), |
154 animation_observer_(new HideViewAnimationObserver()) { | 151 animation_observer_(new HideViewAnimationObserver()) { |
155 CHECK(delegate); | 152 CHECK(delegate); |
156 | 153 |
157 delegate_->AddObserver(this); | 154 delegate_->AddObserver(this); |
158 delegate_->GetSpeechUI()->AddObserver(this); | 155 delegate_->GetSpeechUI()->AddObserver(this); |
159 } | 156 } |
160 | 157 |
161 AppListView::~AppListView() { | 158 AppListView::~AppListView() { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 244 |
248 bool AppListView::ShouldHandleSystemCommands() const { | 245 bool AppListView::ShouldHandleSystemCommands() const { |
249 return true; | 246 return true; |
250 } | 247 } |
251 | 248 |
252 void AppListView::Prerender() { | 249 void AppListView::Prerender() { |
253 app_list_main_view_->Prerender(); | 250 app_list_main_view_->Prerender(); |
254 } | 251 } |
255 | 252 |
256 void AppListView::OnProfilesChanged() { | 253 void AppListView::OnProfilesChanged() { |
257 SigninDelegate* signin_delegate = | |
258 delegate_ ? delegate_->GetSigninDelegate() : NULL; | |
259 bool show_signin_view = signin_delegate && signin_delegate->NeedSignin(); | |
260 | |
261 signin_view_->SetVisible(show_signin_view); | |
262 app_list_main_view_->SetVisible(!show_signin_view); | |
263 app_list_main_view_->search_box_view()->InvalidateMenu(); | 254 app_list_main_view_->search_box_view()->InvalidateMenu(); |
264 } | 255 } |
265 | 256 |
266 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { | 257 void AppListView::SetProfileByPath(const base::FilePath& profile_path) { |
267 delegate_->SetProfileByPath(profile_path); | 258 delegate_->SetProfileByPath(profile_path); |
268 app_list_main_view_->ModelChanged(); | 259 app_list_main_view_->ModelChanged(); |
269 } | 260 } |
270 | 261 |
271 void AppListView::AddObserver(AppListViewObserver* observer) { | 262 void AppListView::AddObserver(AppListViewObserver* observer) { |
272 observers_.AddObserver(observer); | 263 observers_.AddObserver(observer); |
(...skipping 28 matching lines...) Expand all Loading... | |
301 app_list_main_view_ = new AppListMainView(delegate_.get(), | 292 app_list_main_view_ = new AppListMainView(delegate_.get(), |
302 pagination_model, | 293 pagination_model, |
303 parent); | 294 parent); |
304 AddChildView(app_list_main_view_); | 295 AddChildView(app_list_main_view_); |
305 #if defined(USE_AURA) | 296 #if defined(USE_AURA) |
306 app_list_main_view_->SetPaintToLayer(true); | 297 app_list_main_view_->SetPaintToLayer(true); |
307 app_list_main_view_->SetFillsBoundsOpaquely(false); | 298 app_list_main_view_->SetFillsBoundsOpaquely(false); |
308 app_list_main_view_->layer()->SetMasksToBounds(true); | 299 app_list_main_view_->layer()->SetMasksToBounds(true); |
309 #endif | 300 #endif |
310 | 301 |
311 signin_view_ = | |
312 new SigninView(delegate_->GetSigninDelegate(), | |
313 app_list_main_view_->GetPreferredSize().width()); | |
314 AddChildView(signin_view_); | |
315 | |
316 // Speech recognition is available only when the start page exists. | 302 // Speech recognition is available only when the start page exists. |
317 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { | 303 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { |
318 speech_view_ = new SpeechView(delegate_.get()); | 304 speech_view_ = new SpeechView(delegate_.get()); |
319 speech_view_->SetVisible(false); | 305 speech_view_->SetVisible(false); |
320 #if defined(USE_AURA) | 306 #if defined(USE_AURA) |
321 speech_view_->SetPaintToLayer(true); | 307 speech_view_->SetPaintToLayer(true); |
322 speech_view_->SetFillsBoundsOpaquely(false); | 308 speech_view_->SetFillsBoundsOpaquely(false); |
323 speech_view_->layer()->SetOpacity(0.0f); | 309 speech_view_->layer()->SetOpacity(0.0f); |
324 #endif | 310 #endif |
325 AddChildView(speech_view_); | 311 AddChildView(speech_view_); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 } | 438 } |
453 return true; | 439 return true; |
454 } | 440 } |
455 | 441 |
456 return false; | 442 return false; |
457 } | 443 } |
458 | 444 |
459 void AppListView::Layout() { | 445 void AppListView::Layout() { |
460 const gfx::Rect contents_bounds = GetContentsBounds(); | 446 const gfx::Rect contents_bounds = GetContentsBounds(); |
461 app_list_main_view_->SetBoundsRect(contents_bounds); | 447 app_list_main_view_->SetBoundsRect(contents_bounds); |
462 signin_view_->SetBoundsRect(contents_bounds); | |
463 | 448 |
464 if (speech_view_) { | 449 if (speech_view_) { |
465 gfx::Rect speech_bounds = contents_bounds; | 450 gfx::Rect speech_bounds = contents_bounds; |
466 int preferred_height = speech_view_->GetPreferredSize().height(); | 451 int preferred_height = speech_view_->GetPreferredSize().height(); |
467 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); | 452 speech_bounds.Inset(kSpeechUIMargin, kSpeechUIMargin); |
468 speech_bounds.set_height(std::min(speech_bounds.height(), | 453 speech_bounds.set_height(std::min(speech_bounds.height(), |
469 preferred_height)); | 454 preferred_height)); |
470 speech_bounds.Inset(-speech_view_->GetInsets()); | 455 speech_bounds.Inset(-speech_view_->GetInsets()); |
471 speech_view_->SetBoundsRect(speech_bounds); | 456 speech_view_->SetBoundsRect(speech_bounds); |
472 } | 457 } |
(...skipping 23 matching lines...) Expand all Loading... | |
496 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, | 481 void AppListView::OnWidgetVisibilityChanged(views::Widget* widget, |
497 bool visible) { | 482 bool visible) { |
498 BubbleDelegateView::OnWidgetVisibilityChanged(widget, visible); | 483 BubbleDelegateView::OnWidgetVisibilityChanged(widget, visible); |
499 | 484 |
500 if (widget != GetWidget()) | 485 if (widget != GetWidget()) |
501 return; | 486 return; |
502 | 487 |
503 if (!visible) | 488 if (!visible) |
504 app_list_main_view_->ResetForShow(); | 489 app_list_main_view_->ResetForShow(); |
505 | 490 |
506 // Whether we need to signin or not may have changed since last time we were | 491 // Whether we need to signin or not may have changed since last time we were |
calamity
2014/06/02 04:36:15
nit: update comment.
benwells
2014/06/02 07:48:55
Done.
| |
507 // shown. | 492 // shown. |
508 Layout(); | 493 Layout(); |
509 } | 494 } |
510 | 495 |
511 void AppListView::OnSpeechRecognitionStateChanged( | 496 void AppListView::OnSpeechRecognitionStateChanged( |
512 SpeechRecognitionState new_state) { | 497 SpeechRecognitionState new_state) { |
513 if (signin_view_->visible() || !speech_view_) | 498 if (!speech_view_) |
514 return; | 499 return; |
515 | 500 |
516 bool recognizing = (new_state == SPEECH_RECOGNITION_RECOGNIZING || | 501 bool recognizing = (new_state == SPEECH_RECOGNITION_RECOGNIZING || |
517 new_state == SPEECH_RECOGNITION_IN_SPEECH); | 502 new_state == SPEECH_RECOGNITION_IN_SPEECH); |
518 // No change for this class. | 503 // No change for this class. |
519 if (speech_view_->visible() == recognizing) | 504 if (speech_view_->visible() == recognizing) |
520 return; | 505 return; |
521 | 506 |
522 if (recognizing) | 507 if (recognizing) |
523 speech_view_->Reset(); | 508 speech_view_->Reset(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 #else | 547 #else |
563 speech_view_->SetVisible(recognizing); | 548 speech_view_->SetVisible(recognizing); |
564 app_list_main_view_->SetVisible(!recognizing); | 549 app_list_main_view_->SetVisible(!recognizing); |
565 | 550 |
566 // Needs to schedule paint of AppListView itself, to repaint the background. | 551 // Needs to schedule paint of AppListView itself, to repaint the background. |
567 GetBubbleFrameView()->SchedulePaint(); | 552 GetBubbleFrameView()->SchedulePaint(); |
568 #endif | 553 #endif |
569 } | 554 } |
570 | 555 |
571 } // namespace app_list | 556 } // namespace app_list |
OLD | NEW |