| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 native_window_ = browser_view_->GetNativeWindow(); | 67 native_window_ = browser_view_->GetNativeWindow(); |
| 68 controller_->Init(this, browser_view_->frame(), | 68 controller_->Init(this, browser_view_->frame(), |
| 69 browser_view_->top_container()); | 69 browser_view_->top_container()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) { | 72 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) { |
| 73 if (controller_->IsEnabled() == enabled) | 73 if (controller_->IsEnabled() == enabled) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 EnableWindowObservers(enabled); | 76 EnableWindowObservers(enabled); |
| 77 | |
| 78 // Use a short "light bar" version of the tab strip when the top-of-window | |
| 79 // views are closed. If the user additionally enters into tab fullscreen, | |
| 80 // the tab indicators will be hidden. | |
| 81 use_tab_indicators_ = enabled; | |
| 82 | |
| 83 controller_->SetEnabled(enabled); | 77 controller_->SetEnabled(enabled); |
| 84 } | 78 } |
| 85 | 79 |
| 86 bool ImmersiveModeControllerAsh::IsEnabled() const { | 80 bool ImmersiveModeControllerAsh::IsEnabled() const { |
| 87 return controller_->IsEnabled(); | 81 return controller_->IsEnabled(); |
| 88 } | 82 } |
| 89 | 83 |
| 90 bool ImmersiveModeControllerAsh::ShouldHideTabIndicators() const { | 84 bool ImmersiveModeControllerAsh::ShouldHideTabIndicators() const { |
| 91 return !use_tab_indicators_; | 85 return !use_tab_indicators_; |
| 92 } | 86 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // |window| is NULL if the renderer crashed. | 156 // |window| is NULL if the renderer crashed. |
| 163 if (window) { | 157 if (window) { |
| 164 gfx::Insets inset(top_inset, 0, 0, 0); | 158 gfx::Insets inset(top_inset, 0, 0, 0); |
| 165 window->SetHitTestBoundsOverrideOuter( | 159 window->SetHitTestBoundsOverrideOuter( |
| 166 window->hit_test_bounds_override_outer_mouse(), | 160 window->hit_test_bounds_override_outer_mouse(), |
| 167 inset); | 161 inset); |
| 168 } | 162 } |
| 169 } | 163 } |
| 170 } | 164 } |
| 171 | 165 |
| 172 void ImmersiveModeControllerAsh::SetTabIndicatorsVisible(bool visible) { | 166 bool ImmersiveModeControllerAsh::UpdateTabIndicators() { |
| 173 DCHECK(!visible || use_tab_indicators_); | 167 bool has_tabstrip = browser_view_->IsBrowserTypeNormal(); |
| 174 if (browser_view_->tabstrip()) | 168 if (!IsEnabled() || !has_tabstrip) { |
| 175 browser_view_->tabstrip()->SetImmersiveStyle(visible); | 169 use_tab_indicators_ = false; |
| 170 } else { |
| 171 bool in_tab_fullscreen = browser_view_->browser()->fullscreen_controller()-> |
| 172 IsFullscreenForTabOrPending(); |
| 173 use_tab_indicators_ = !in_tab_fullscreen; |
| 174 } |
| 175 |
| 176 bool show_tab_indicators = use_tab_indicators_ && !IsRevealed(); |
| 177 if (show_tab_indicators != browser_view_->tabstrip()->IsImmersiveStyle()) { |
| 178 browser_view_->tabstrip()->SetImmersiveStyle(show_tab_indicators); |
| 179 return true; |
| 180 } |
| 181 return false; |
| 176 } | 182 } |
| 177 | 183 |
| 178 void ImmersiveModeControllerAsh::OnImmersiveRevealStarted() { | 184 void ImmersiveModeControllerAsh::OnImmersiveRevealStarted() { |
| 179 visible_fraction_ = 0; | 185 visible_fraction_ = 0; |
| 180 browser_view_->top_container()->SetPaintToLayer(true); | 186 browser_view_->top_container()->SetPaintToLayer(true); |
| 181 SetTabIndicatorsVisible(false); | 187 UpdateTabIndicators(); |
| 182 SetRenderWindowTopInsetsForTouch(0); | 188 SetRenderWindowTopInsetsForTouch(0); |
| 183 LayoutBrowserRootView(); | 189 LayoutBrowserRootView(); |
| 184 FOR_EACH_OBSERVER(Observer, observers_, OnImmersiveRevealStarted()); | 190 FOR_EACH_OBSERVER(Observer, observers_, OnImmersiveRevealStarted()); |
| 185 } | 191 } |
| 186 | 192 |
| 187 void ImmersiveModeControllerAsh::OnImmersiveRevealEnded() { | 193 void ImmersiveModeControllerAsh::OnImmersiveRevealEnded() { |
| 188 visible_fraction_ = 0; | 194 visible_fraction_ = 0; |
| 189 browser_view_->top_container()->SetPaintToLayer(false); | 195 browser_view_->top_container()->SetPaintToLayer(false); |
| 190 SetTabIndicatorsVisible(use_tab_indicators_); | 196 UpdateTabIndicators(); |
| 191 SetRenderWindowTopInsetsForTouch( | 197 SetRenderWindowTopInsetsForTouch( |
| 192 kStealTouchEventsFromWebContentsRegionHeightPx); | 198 kStealTouchEventsFromWebContentsRegionHeightPx); |
| 193 LayoutBrowserRootView(); | 199 LayoutBrowserRootView(); |
| 194 } | 200 } |
| 195 | 201 |
| 196 void ImmersiveModeControllerAsh::OnImmersiveFullscreenExited() { | 202 void ImmersiveModeControllerAsh::OnImmersiveFullscreenExited() { |
| 197 browser_view_->top_container()->SetPaintToLayer(false); | 203 browser_view_->top_container()->SetPaintToLayer(false); |
| 198 SetTabIndicatorsVisible(false); | 204 UpdateTabIndicators(); |
| 199 SetRenderWindowTopInsetsForTouch(0); | 205 SetRenderWindowTopInsetsForTouch(0); |
| 200 LayoutBrowserRootView(); | 206 LayoutBrowserRootView(); |
| 201 } | 207 } |
| 202 | 208 |
| 203 void ImmersiveModeControllerAsh::SetVisibleFraction(double visible_fraction) { | 209 void ImmersiveModeControllerAsh::SetVisibleFraction(double visible_fraction) { |
| 204 if (visible_fraction_ != visible_fraction) { | 210 if (visible_fraction_ != visible_fraction) { |
| 205 visible_fraction_ = visible_fraction; | 211 visible_fraction_ = visible_fraction; |
| 206 browser_view_->Layout(); | 212 browser_view_->Layout(); |
| 207 } | 213 } |
| 208 } | 214 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 246 } |
| 241 | 247 |
| 242 void ImmersiveModeControllerAsh::Observe( | 248 void ImmersiveModeControllerAsh::Observe( |
| 243 int type, | 249 int type, |
| 244 const content::NotificationSource& source, | 250 const content::NotificationSource& source, |
| 245 const content::NotificationDetails& details) { | 251 const content::NotificationDetails& details) { |
| 246 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 252 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 247 if (!controller_->IsEnabled()) | 253 if (!controller_->IsEnabled()) |
| 248 return; | 254 return; |
| 249 | 255 |
| 250 bool in_tab_fullscreen = content::Source<FullscreenController>(source)-> | 256 bool tab_indicator_visibility_changed = UpdateTabIndicators(); |
| 251 IsFullscreenForTabOrPending(); | |
| 252 | |
| 253 bool used_tab_indicators = use_tab_indicators_; | |
| 254 use_tab_indicators_ = !in_tab_fullscreen; | |
| 255 SetTabIndicatorsVisible(use_tab_indicators_ && !controller_->IsRevealed()); | |
| 256 | 257 |
| 257 // Auto hide the shelf in immersive browser fullscreen. When auto hidden, the | 258 // Auto hide the shelf in immersive browser fullscreen. When auto hidden, the |
| 258 // shelf displays a 3px 'light bar' when it is closed. When in immersive | 259 // shelf displays a 3px 'light bar' when it is closed. When in immersive |
| 259 // browser fullscreen and tab fullscreen, hide the shelf completely and | 260 // browser fullscreen and tab fullscreen, hide the shelf completely and |
| 260 // prevent it from being revealed. | 261 // prevent it from being revealed. |
| 262 bool in_tab_fullscreen = content::Source<FullscreenController>(source)-> |
| 263 IsFullscreenForTabOrPending(); |
| 261 ash::wm::GetWindowState(native_window_)->set_hide_shelf_when_fullscreen( | 264 ash::wm::GetWindowState(native_window_)->set_hide_shelf_when_fullscreen( |
| 262 in_tab_fullscreen); | 265 in_tab_fullscreen); |
| 263 ash::Shell::GetInstance()->UpdateShelfVisibility(); | 266 ash::Shell::GetInstance()->UpdateShelfVisibility(); |
| 264 | 267 |
| 265 if (use_tab_indicators_ != used_tab_indicators) | 268 if (tab_indicator_visibility_changed) |
| 266 LayoutBrowserRootView(); | 269 LayoutBrowserRootView(); |
| 267 } | 270 } |
| OLD | NEW |