| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" | 5 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/window_properties.h" | 9 #include "ash/wm/window_properties.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh() | 281 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh() |
| 282 : delegate_(NULL), | 282 : delegate_(NULL), |
| 283 widget_(NULL), | 283 widget_(NULL), |
| 284 top_container_(NULL), | 284 top_container_(NULL), |
| 285 observers_enabled_(false), | 285 observers_enabled_(false), |
| 286 enabled_(false), | 286 enabled_(false), |
| 287 reveal_state_(CLOSED), | 287 reveal_state_(CLOSED), |
| 288 revealed_lock_count_(0), | 288 revealed_lock_count_(0), |
| 289 tab_indicator_visibility_(TAB_INDICATORS_HIDE), | 289 tab_indicator_visibility_(TAB_INDICATORS_HIDE), |
| 290 mouse_x_when_hit_top_(-1), | 290 mouse_x_when_hit_top_(-1), |
| 291 gesture_begun_(false), |
| 291 native_window_(NULL), | 292 native_window_(NULL), |
| 292 animation_(new ui::SlideAnimation(this)), | 293 animation_(new ui::SlideAnimation(this)), |
| 293 animations_disabled_for_test_(false), | 294 animations_disabled_for_test_(false), |
| 294 weak_ptr_factory_(this), | 295 weak_ptr_factory_(this) { |
| 295 gesture_begun_(false) { | |
| 296 } | 296 } |
| 297 | 297 |
| 298 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() { | 298 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() { |
| 299 // The browser view is being destroyed so there's no need to update its | 299 // The browser view is being destroyed so there's no need to update its |
| 300 // layout or layers, even if the top views are revealed. But the window | 300 // layout or layers, even if the top views are revealed. But the window |
| 301 // observers still need to be removed. | 301 // observers still need to be removed. |
| 302 EnableWindowObservers(false); | 302 EnableWindowObservers(false); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void ImmersiveModeControllerAsh::LockRevealedState( | 305 void ImmersiveModeControllerAsh::LockRevealedState( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 void ImmersiveModeControllerAsh::UnanchorWidgetFromTopContainer( | 434 void ImmersiveModeControllerAsh::UnanchorWidgetFromTopContainer( |
| 435 views::Widget* widget) { | 435 views::Widget* widget) { |
| 436 anchored_widget_manager_->RemoveAnchoredWidget(widget); | 436 anchored_widget_manager_->RemoveAnchoredWidget(widget); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void ImmersiveModeControllerAsh::OnTopContainerBoundsChanged() { | 439 void ImmersiveModeControllerAsh::OnTopContainerBoundsChanged() { |
| 440 anchored_widget_manager_->MaybeRepositionAnchoredWidgets(); | 440 anchored_widget_manager_->MaybeRepositionAnchoredWidgets(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 void ImmersiveModeControllerAsh::AddObserver(Observer* observer) { |
| 444 observers_.AddObserver(observer); |
| 445 } |
| 446 |
| 447 void ImmersiveModeControllerAsh::RemoveObserver(Observer* observer) { |
| 448 observers_.RemoveObserver(observer); |
| 449 } |
| 450 |
| 443 //////////////////////////////////////////////////////////////////////////////// | 451 //////////////////////////////////////////////////////////////////////////////// |
| 444 // Observers: | 452 // Observers: |
| 445 | 453 |
| 446 void ImmersiveModeControllerAsh::Observe( | 454 void ImmersiveModeControllerAsh::Observe( |
| 447 int type, | 455 int type, |
| 448 const content::NotificationSource& source, | 456 const content::NotificationSource& source, |
| 449 const content::NotificationDetails& details) { | 457 const content::NotificationDetails& details) { |
| 450 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 458 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 451 if (enabled_) | 459 if (enabled_) |
| 452 UpdateUseMinimalChrome(LAYOUT_YES); | 460 UpdateUseMinimalChrome(LAYOUT_YES); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 return; | 934 return; |
| 927 } | 935 } |
| 928 // Slide in the reveal view. | 936 // Slide in the reveal view. |
| 929 if (animate == ANIMATE_NO) { | 937 if (animate == ANIMATE_NO) { |
| 930 animation_->Reset(1); | 938 animation_->Reset(1); |
| 931 OnSlideOpenAnimationCompleted(LAYOUT_YES); | 939 OnSlideOpenAnimationCompleted(LAYOUT_YES); |
| 932 } else { | 940 } else { |
| 933 animation_->SetSlideDuration(GetAnimationDuration(animate)); | 941 animation_->SetSlideDuration(GetAnimationDuration(animate)); |
| 934 animation_->Show(); | 942 animation_->Show(); |
| 935 } | 943 } |
| 944 |
| 945 if (previous_reveal_state == CLOSED) { |
| 946 FOR_EACH_OBSERVER(Observer, observers_, OnStartedImmersiveReveal()); |
| 947 } |
| 936 } | 948 } |
| 937 | 949 |
| 938 void ImmersiveModeControllerAsh::EnablePaintToLayer(bool enable) { | 950 void ImmersiveModeControllerAsh::EnablePaintToLayer(bool enable) { |
| 939 top_container_->SetPaintToLayer(enable); | 951 top_container_->SetPaintToLayer(enable); |
| 940 | 952 |
| 941 // Views software compositing is not fully layer aware. If the bookmark bar | 953 // Views software compositing is not fully layer aware. If the bookmark bar |
| 942 // is detached while the top container layer slides on or off the screen, | 954 // is detached while the top container layer slides on or off the screen, |
| 943 // the pixels that become exposed are the remnants of the last software | 955 // the pixels that become exposed are the remnants of the last software |
| 944 // composite of the BrowserView, not the freshly-exposed bookmark bar. | 956 // composite of the BrowserView, not the freshly-exposed bookmark bar. |
| 945 // Force the bookmark bar to paint to a layer so the views composite | 957 // Force the bookmark bar to paint to a layer so the views composite |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 if (!native_window_) | 1071 if (!native_window_) |
| 1060 return; | 1072 return; |
| 1061 aura::RootWindow* root_window = native_window_->GetRootWindow(); | 1073 aura::RootWindow* root_window = native_window_->GetRootWindow(); |
| 1062 if (!root_window) | 1074 if (!root_window) |
| 1063 return; | 1075 return; |
| 1064 if (observers_enabled_) | 1076 if (observers_enabled_) |
| 1065 root_window->AddPreTargetHandler(this); | 1077 root_window->AddPreTargetHandler(this); |
| 1066 else | 1078 else |
| 1067 root_window->RemovePreTargetHandler(this); | 1079 root_window->RemovePreTargetHandler(this); |
| 1068 } | 1080 } |
| OLD | NEW |