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