Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: ash/wm/immersive_fullscreen_controller.cc

Issue 132013004: Moves transient window observer methods out of WindowObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments and update gyp Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/wm/immersive_fullscreen_controller.h" 5 #include "ash/wm/immersive_fullscreen_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "ui/aura/client/activation_client.h" 12 #include "ui/aura/client/activation_client.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/client/capture_client.h" 14 #include "ui/aura/client/capture_client.h"
15 #include "ui/aura/client/cursor_client.h" 15 #include "ui/aura/client/cursor_client.h"
16 #include "ui/aura/client/screen_position_client.h" 16 #include "ui/aura/client/screen_position_client.h"
17 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
18 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/gfx/animation/slide_animation.h" 20 #include "ui/gfx/animation/slide_animation.h"
21 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
22 #include "ui/gfx/point.h" 22 #include "ui/gfx/point.h"
23 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
24 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
25 #include "ui/views/bubble/bubble_delegate.h" 25 #include "ui/views/bubble/bubble_delegate.h"
26 #include "ui/views/corewm/transient_window_manager.h"
26 #include "ui/views/corewm/window_util.h" 27 #include "ui/views/corewm/window_util.h"
27 #include "ui/views/view.h" 28 #include "ui/views/view.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 30
30 using views::View; 31 using views::View;
31 32
32 namespace ash { 33 namespace ash {
33 34
34 namespace { 35 namespace {
35 36
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 467 }
467 468
468 void ImmersiveFullscreenController::AnimationProgressed( 469 void ImmersiveFullscreenController::AnimationProgressed(
469 const gfx::Animation* animation) { 470 const gfx::Animation* animation) {
470 delegate_->SetVisibleFraction(animation->GetCurrentValue()); 471 delegate_->SetVisibleFraction(animation->GetCurrentValue());
471 } 472 }
472 473
473 //////////////////////////////////////////////////////////////////////////////// 474 ////////////////////////////////////////////////////////////////////////////////
474 // aura::WindowObserver overrides: 475 // aura::WindowObserver overrides:
475 476
476 void ImmersiveFullscreenController::OnAddTransientChild( 477 void ImmersiveFullscreenController::OnTransientChildAdded(
477 aura::Window* window, 478 aura::Window* window,
478 aura::Window* transient) { 479 aura::Window* transient) {
479 views::BubbleDelegateView* bubble_delegate = AsBubbleDelegate(transient); 480 views::BubbleDelegateView* bubble_delegate = AsBubbleDelegate(transient);
480 if (bubble_delegate && 481 if (bubble_delegate &&
481 bubble_delegate->GetAnchorView() && 482 bubble_delegate->GetAnchorView() &&
482 top_container_->Contains(bubble_delegate->GetAnchorView())) { 483 top_container_->Contains(bubble_delegate->GetAnchorView())) {
483 // Observe the aura::Window because the BubbleDelegateView may not be 484 // Observe the aura::Window because the BubbleDelegateView may not be
484 // parented to the widget's root view yet so |bubble_delegate->GetWidget()| 485 // parented to the widget's root view yet so |bubble_delegate->GetWidget()|
485 // may still return NULL. 486 // may still return NULL.
486 bubble_manager_->StartObserving(transient); 487 bubble_manager_->StartObserving(transient);
487 } 488 }
488 } 489 }
489 490
490 void ImmersiveFullscreenController::OnRemoveTransientChild( 491 void ImmersiveFullscreenController::OnTransientChildRemoved(
491 aura::Window* window, 492 aura::Window* window,
492 aura::Window* transient) { 493 aura::Window* transient) {
493 bubble_manager_->StopObserving(transient); 494 bubble_manager_->StopObserving(transient);
494 } 495 }
495 496
496 //////////////////////////////////////////////////////////////////////////////// 497 ////////////////////////////////////////////////////////////////////////////////
497 // ash::ImmersiveRevealedLock::Delegate overrides: 498 // ash::ImmersiveRevealedLock::Delegate overrides:
498 499
499 void ImmersiveFullscreenController::LockRevealedState( 500 void ImmersiveFullscreenController::LockRevealedState(
500 AnimateReveal animate_reveal) { 501 AnimateReveal animate_reveal) {
(...skipping 19 matching lines...) Expand all
520 if (observers_enabled_ == enable) 521 if (observers_enabled_ == enable)
521 return; 522 return;
522 observers_enabled_ = enable; 523 observers_enabled_ = enable;
523 524
524 views::FocusManager* focus_manager = widget_->GetFocusManager(); 525 views::FocusManager* focus_manager = widget_->GetFocusManager();
525 526
526 if (enable) { 527 if (enable) {
527 widget_->AddObserver(this); 528 widget_->AddObserver(this);
528 focus_manager->AddFocusChangeListener(this); 529 focus_manager->AddFocusChangeListener(this);
529 Shell::GetInstance()->AddPreTargetHandler(this); 530 Shell::GetInstance()->AddPreTargetHandler(this);
530 native_window_->AddObserver(this); 531 views::corewm::TransientWindowManager::Get(native_window_)->
532 AddObserver(this);
531 533
532 RecreateBubbleManager(); 534 RecreateBubbleManager();
533 } else { 535 } else {
534 widget_->RemoveObserver(this); 536 widget_->RemoveObserver(this);
535 focus_manager->RemoveFocusChangeListener(this); 537 focus_manager->RemoveFocusChangeListener(this);
536 Shell::GetInstance()->RemovePreTargetHandler(this); 538 Shell::GetInstance()->RemovePreTargetHandler(this);
537 native_window_->RemoveObserver(this); 539 views::corewm::TransientWindowManager::Get(native_window_)->
540 RemoveObserver(this);
538 541
539 // We have stopped observing whether transient children are added or removed 542 // We have stopped observing whether transient children are added or removed
540 // to |native_window_|. The set of bubbles that BubbleManager is observing 543 // to |native_window_|. The set of bubbles that BubbleManager is observing
541 // will become stale really quickly. Destroy BubbleManager and recreate it 544 // will become stale really quickly. Destroy BubbleManager and recreate it
542 // when we start observing |native_window_| again. 545 // when we start observing |native_window_| again.
543 bubble_manager_.reset(); 546 bubble_manager_.reset();
544 547
545 animation_->Stop(); 548 animation_->Stop();
546 } 549 }
547 } 550 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 AsBubbleDelegate(transient_child); 927 AsBubbleDelegate(transient_child);
925 if (bubble_delegate && 928 if (bubble_delegate &&
926 bubble_delegate->GetAnchorView() && 929 bubble_delegate->GetAnchorView() &&
927 top_container_->Contains(bubble_delegate->GetAnchorView())) { 930 top_container_->Contains(bubble_delegate->GetAnchorView())) {
928 bubble_manager_->StartObserving(transient_child); 931 bubble_manager_->StartObserving(transient_child);
929 } 932 }
930 } 933 }
931 } 934 }
932 935
933 } // namespace ash 936 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698