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

Side by Side Diff: chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc

Issue 2702663002: [Merge to M57] cros-md: Remove the non-MD immersive mode code paths (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/shared/immersive_revealed_lock.h" 9 #include "ash/shared/immersive_revealed_lock.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 16 matching lines...) Expand all
27 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
28 #include "ui/compositor/paint_context.h" 28 #include "ui/compositor/paint_context.h"
29 #include "ui/compositor/paint_recorder.h" 29 #include "ui/compositor/paint_recorder.h"
30 #include "ui/views/mus/mus_client.h" 30 #include "ui/views/mus/mus_client.h"
31 #include "ui/views/view.h" 31 #include "ui/views/view.h"
32 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
33 #include "ui/views/window/non_client_view.h" 33 #include "ui/views/window/non_client_view.h"
34 34
35 namespace { 35 namespace {
36 36
37 // Revealing the TopContainerView looks better if the animation starts and ends
38 // just a few pixels before the view goes offscreen, which reduces the visual
39 // "pop" as the 3-pixel tall "light bar" style tab strip becomes visible.
40 const int kAnimationOffsetY = 3;
41
42 // Converts from ImmersiveModeController::AnimateReveal to 37 // Converts from ImmersiveModeController::AnimateReveal to
43 // ash::ImmersiveFullscreenController::AnimateReveal. 38 // ash::ImmersiveFullscreenController::AnimateReveal.
44 ash::ImmersiveFullscreenController::AnimateReveal 39 ash::ImmersiveFullscreenController::AnimateReveal
45 ToImmersiveFullscreenControllerAnimateReveal( 40 ToImmersiveFullscreenControllerAnimateReveal(
46 ImmersiveModeController::AnimateReveal animate_reveal) { 41 ImmersiveModeController::AnimateReveal animate_reveal) {
47 switch (animate_reveal) { 42 switch (animate_reveal) {
48 case ImmersiveModeController::ANIMATE_REVEAL_YES: 43 case ImmersiveModeController::ANIMATE_REVEAL_YES:
49 return ash::ImmersiveFullscreenController::ANIMATE_REVEAL_YES; 44 return ash::ImmersiveFullscreenController::ANIMATE_REVEAL_YES;
50 case ImmersiveModeController::ANIMATE_REVEAL_NO: 45 case ImmersiveModeController::ANIMATE_REVEAL_NO:
51 return ash::ImmersiveFullscreenController::ANIMATE_REVEAL_NO; 46 return ash::ImmersiveFullscreenController::ANIMATE_REVEAL_NO;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }; 81 };
87 82
88 } // namespace 83 } // namespace
89 84
90 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh() 85 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh()
91 : ImmersiveModeController(Type::ASH), 86 : ImmersiveModeController(Type::ASH),
92 controller_(new ash::ImmersiveFullscreenController), 87 controller_(new ash::ImmersiveFullscreenController),
93 browser_view_(nullptr), 88 browser_view_(nullptr),
94 native_window_(nullptr), 89 native_window_(nullptr),
95 observers_enabled_(false), 90 observers_enabled_(false),
96 use_tab_indicators_(false),
97 visible_fraction_(1) {} 91 visible_fraction_(1) {}
98 92
99 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() { 93 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() {
100 EnableWindowObservers(false); 94 EnableWindowObservers(false);
101 } 95 }
102 96
103 void ImmersiveModeControllerAsh::Init(BrowserView* browser_view) { 97 void ImmersiveModeControllerAsh::Init(BrowserView* browser_view) {
104 browser_view_ = browser_view; 98 browser_view_ = browser_view;
105 native_window_ = browser_view_->GetNativeWindow(); 99 native_window_ = browser_view_->GetNativeWindow();
106 controller_->Init(this, browser_view_->frame(), 100 controller_->Init(this, browser_view_->frame(),
107 browser_view_->top_container()); 101 browser_view_->top_container());
108 } 102 }
109 103
110 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) { 104 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) {
111 if (controller_->IsEnabled() == enabled) 105 if (controller_->IsEnabled() == enabled)
112 return; 106 return;
113 107
114 EnableWindowObservers(enabled); 108 EnableWindowObservers(enabled);
115 109
116 controller_->SetEnabled(browser_view_->browser()->is_app() ? 110 controller_->SetEnabled(browser_view_->browser()->is_app() ?
117 ash::ImmersiveFullscreenController::WINDOW_TYPE_HOSTED_APP : 111 ash::ImmersiveFullscreenController::WINDOW_TYPE_HOSTED_APP :
118 ash::ImmersiveFullscreenController::WINDOW_TYPE_BROWSER 112 ash::ImmersiveFullscreenController::WINDOW_TYPE_BROWSER
119 , enabled); 113 , enabled);
120 } 114 }
121 115
122 bool ImmersiveModeControllerAsh::IsEnabled() const { 116 bool ImmersiveModeControllerAsh::IsEnabled() const {
123 return controller_->IsEnabled(); 117 return controller_->IsEnabled();
124 } 118 }
125 119
126 bool ImmersiveModeControllerAsh::ShouldHideTabIndicators() const {
127 return !use_tab_indicators_;
128 }
129
130 bool ImmersiveModeControllerAsh::ShouldHideTopViews() const { 120 bool ImmersiveModeControllerAsh::ShouldHideTopViews() const {
131 return controller_->IsEnabled() && !controller_->IsRevealed(); 121 return controller_->IsEnabled() && !controller_->IsRevealed();
132 } 122 }
133 123
134 bool ImmersiveModeControllerAsh::IsRevealed() const { 124 bool ImmersiveModeControllerAsh::IsRevealed() const {
135 return controller_->IsRevealed(); 125 return controller_->IsRevealed();
136 } 126 }
137 127
138 int ImmersiveModeControllerAsh::GetTopContainerVerticalOffset( 128 int ImmersiveModeControllerAsh::GetTopContainerVerticalOffset(
139 const gfx::Size& top_container_size) const { 129 const gfx::Size& top_container_size) const {
140 if (!IsEnabled()) 130 if (!IsEnabled())
141 return 0; 131 return 0;
142 132
143 // The TopContainerView is flush with the top of |browser_view_| when the 133 return static_cast<int>(top_container_size.height() *
144 // top-of-window views are fully closed so that when the tab indicators are 134 (visible_fraction_ - 1));
145 // used, the "light bar" style tab strip is flush with the top of
146 // |browser_view_|.
147 if (!IsRevealed())
148 return 0;
149
150 int height = top_container_size.height() - kAnimationOffsetY;
151 return static_cast<int>(height * (visible_fraction_ - 1));
152 } 135 }
153 136
154 ImmersiveRevealedLock* ImmersiveModeControllerAsh::GetRevealedLock( 137 ImmersiveRevealedLock* ImmersiveModeControllerAsh::GetRevealedLock(
155 AnimateReveal animate_reveal) { 138 AnimateReveal animate_reveal) {
156 return new ImmersiveRevealedLockAsh(controller_->GetRevealedLock( 139 return new ImmersiveRevealedLockAsh(controller_->GetRevealedLock(
157 ToImmersiveFullscreenControllerAnimateReveal(animate_reveal))); 140 ToImmersiveFullscreenControllerAnimateReveal(animate_reveal)));
158 } 141 }
159 142
160 void ImmersiveModeControllerAsh::OnFindBarVisibleBoundsChanged( 143 void ImmersiveModeControllerAsh::OnFindBarVisibleBoundsChanged(
161 const gfx::Rect& new_visible_bounds_in_screen) { 144 const gfx::Rect& new_visible_bounds_in_screen) {
(...skipping 29 matching lines...) Expand all
191 174
192 void ImmersiveModeControllerAsh::LayoutBrowserRootView() { 175 void ImmersiveModeControllerAsh::LayoutBrowserRootView() {
193 views::Widget* widget = browser_view_->frame(); 176 views::Widget* widget = browser_view_->frame();
194 // Update the window caption buttons. 177 // Update the window caption buttons.
195 widget->non_client_view()->frame_view()->ResetWindowControls(); 178 widget->non_client_view()->frame_view()->ResetWindowControls();
196 widget->non_client_view()->frame_view()->InvalidateLayout(); 179 widget->non_client_view()->frame_view()->InvalidateLayout();
197 browser_view_->InvalidateLayout(); 180 browser_view_->InvalidateLayout();
198 widget->GetRootView()->Layout(); 181 widget->GetRootView()->Layout();
199 } 182 }
200 183
201 // TODO(yiyix|tdanderson): Once Chrome OS material design is enabled by default,
202 // remove all code related to immersive mode hints (here, in TabStrip and
203 // BrowserNonClientFrameViewAsh::OnPaint()). See crbug.com/614453.
204 bool ImmersiveModeControllerAsh::UpdateTabIndicators() {
205 if (ash::MaterialDesignController::IsImmersiveModeMaterial())
206 return false;
207
208 bool has_tabstrip = browser_view_->IsBrowserTypeNormal();
209 if (!IsEnabled() || !has_tabstrip) {
210 use_tab_indicators_ = false;
211 } else {
212 bool in_tab_fullscreen = browser_view_->browser()
213 ->exclusive_access_manager()
214 ->fullscreen_controller()
215 ->IsWindowFullscreenForTabOrPending();
216 use_tab_indicators_ = !in_tab_fullscreen;
217 }
218
219 bool show_tab_indicators = use_tab_indicators_ && !IsRevealed();
220 if (show_tab_indicators != browser_view_->tabstrip()->IsImmersiveStyle()) {
221 browser_view_->tabstrip()->SetImmersiveStyle(show_tab_indicators);
222 return true;
223 }
224 return false;
225 }
226
227 void ImmersiveModeControllerAsh::CreateMashRevealWidget() { 184 void ImmersiveModeControllerAsh::CreateMashRevealWidget() {
228 if (!chrome::IsRunningInMash()) 185 if (!chrome::IsRunningInMash())
229 return; 186 return;
230 187
231 DCHECK(!mash_reveal_widget_); 188 DCHECK(!mash_reveal_widget_);
232 mash_reveal_widget_ = base::MakeUnique<views::Widget>(); 189 mash_reveal_widget_ = base::MakeUnique<views::Widget>();
233 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_POPUP); 190 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_POPUP);
234 init_params.mus_properties 191 init_params.mus_properties
235 [ui::mojom::WindowManager::kRenderParentTitleArea_Property] = 192 [ui::mojom::WindowManager::kRenderParentTitleArea_Property] =
236 mojo::ConvertTo<std::vector<uint8_t>>( 193 mojo::ConvertTo<std::vector<uint8_t>>(
(...skipping 18 matching lines...) Expand all
255 void ImmersiveModeControllerAsh::DestroyMashRevealWidget() { 212 void ImmersiveModeControllerAsh::DestroyMashRevealWidget() {
256 mash_reveal_widget_.reset(); 213 mash_reveal_widget_.reset();
257 } 214 }
258 215
259 void ImmersiveModeControllerAsh::OnImmersiveRevealStarted() { 216 void ImmersiveModeControllerAsh::OnImmersiveRevealStarted() {
260 DestroyMashRevealWidget(); 217 DestroyMashRevealWidget();
261 218
262 visible_fraction_ = 0; 219 visible_fraction_ = 0;
263 browser_view_->top_container()->SetPaintToLayer(true); 220 browser_view_->top_container()->SetPaintToLayer(true);
264 browser_view_->top_container()->layer()->SetFillsBoundsOpaquely(false); 221 browser_view_->top_container()->layer()->SetFillsBoundsOpaquely(false);
265 UpdateTabIndicators();
266 LayoutBrowserRootView(); 222 LayoutBrowserRootView();
267 CreateMashRevealWidget(); 223 CreateMashRevealWidget();
268 for (Observer& observer : observers_) 224 for (Observer& observer : observers_)
269 observer.OnImmersiveRevealStarted(); 225 observer.OnImmersiveRevealStarted();
270 } 226 }
271 227
272 void ImmersiveModeControllerAsh::OnImmersiveRevealEnded() { 228 void ImmersiveModeControllerAsh::OnImmersiveRevealEnded() {
273 DestroyMashRevealWidget(); 229 DestroyMashRevealWidget();
274 visible_fraction_ = 0; 230 visible_fraction_ = 0;
275 browser_view_->top_container()->SetPaintToLayer(false); 231 browser_view_->top_container()->SetPaintToLayer(false);
276 UpdateTabIndicators();
277 LayoutBrowserRootView(); 232 LayoutBrowserRootView();
278 } 233 }
279 234
280 void ImmersiveModeControllerAsh::OnImmersiveFullscreenExited() { 235 void ImmersiveModeControllerAsh::OnImmersiveFullscreenExited() {
281 DestroyMashRevealWidget(); 236 DestroyMashRevealWidget();
282 browser_view_->top_container()->SetPaintToLayer(false); 237 browser_view_->top_container()->SetPaintToLayer(false);
283 UpdateTabIndicators();
284 LayoutBrowserRootView(); 238 LayoutBrowserRootView();
285 } 239 }
286 240
287 void ImmersiveModeControllerAsh::SetVisibleFraction(double visible_fraction) { 241 void ImmersiveModeControllerAsh::SetVisibleFraction(double visible_fraction) {
288 if (visible_fraction_ != visible_fraction) { 242 if (visible_fraction_ != visible_fraction) {
289 visible_fraction_ = visible_fraction; 243 visible_fraction_ = visible_fraction;
290 browser_view_->Layout(); 244 browser_view_->Layout();
291 245
292 if (mash_reveal_widget_) { 246 if (mash_reveal_widget_) {
293 gfx::Rect bounds = mash_reveal_widget_->GetNativeWindow()->bounds(); 247 gfx::Rect bounds = mash_reveal_widget_->GetNativeWindow()->bounds();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); 290 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type);
337 if (!controller_->IsEnabled()) 291 if (!controller_->IsEnabled())
338 return; 292 return;
339 293
340 if (chrome::IsRunningInMash()) { 294 if (chrome::IsRunningInMash()) {
341 // TODO: http://crbug.com/640384. 295 // TODO: http://crbug.com/640384.
342 NOTIMPLEMENTED(); 296 NOTIMPLEMENTED();
343 return; 297 return;
344 } 298 }
345 299
346 bool tab_indicator_visibility_changed = UpdateTabIndicators(); 300 // Auto hide the shelf in immersive browser fullscreen.
347
348 // Auto hide the shelf in immersive browser fullscreen. When auto hidden and
349 // Material Design is not enabled, the shelf displays a 3px 'light bar' when
350 // it is closed. When in immersive browser fullscreen and tab fullscreen, hide
351 // the shelf completely and prevent it from being revealed.
352 bool in_tab_fullscreen = content::Source<FullscreenController>(source)-> 301 bool in_tab_fullscreen = content::Source<FullscreenController>(source)->
353 IsWindowFullscreenForTabOrPending(); 302 IsWindowFullscreenForTabOrPending();
354 ash::wm::GetWindowState(native_window_) 303 ash::wm::GetWindowState(native_window_)
355 ->set_hide_shelf_when_fullscreen(in_tab_fullscreen); 304 ->set_hide_shelf_when_fullscreen(in_tab_fullscreen);
356 ash::Shell::GetInstance()->UpdateShelfVisibility(); 305 ash::Shell::GetInstance()->UpdateShelfVisibility();
357
358 if (tab_indicator_visibility_changed)
359 LayoutBrowserRootView();
360 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698