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

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

Issue 15734011: Correct immersive mode gestures under rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Other part of the change to address pkotwicz's comments Created 7 years, 7 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
« no previous file with comments | « chrome/browser/ui/views/frame/immersive_mode_controller_ash.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
8 #include <vector>
9
7 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 11 #include "ash/shell.h"
9 #include "ash/wm/window_properties.h" 12 #include "ash/wm/window_properties.h"
10 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h"
11 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 16 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
12 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 17 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
13 #include "chrome/browser/ui/views/frame/top_container_view.h" 18 #include "chrome/browser/ui/views/frame/top_container_view.h"
14 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
16 #include "ui/aura/client/activation_client.h" 21 #include "ui/aura/client/activation_client.h"
17 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/client/capture_client.h" 23 #include "ui/aura/client/capture_client.h"
19 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
25 #include "ui/aura/root_window.h"
20 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
21 #include "ui/aura/window_observer.h" 27 #include "ui/aura/window_observer.h"
22 #include "ui/base/gestures/gesture_configuration.h" 28 #include "ui/base/gestures/gesture_configuration.h"
29 #include "ui/base/ui_base_switches.h"
sadrul 2013/05/23 18:22:07 I think you don't need most of the new #includes
rharrison 2013/05/23 19:10:11 Done.
23 #include "ui/compositor/layer_animation_observer.h" 30 #include "ui/compositor/layer_animation_observer.h"
24 #include "ui/compositor/scoped_layer_animation_settings.h" 31 #include "ui/compositor/scoped_layer_animation_settings.h"
25 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
26 #include "ui/gfx/transform.h" 33 #include "ui/gfx/transform.h"
27 #include "ui/views/view.h" 34 #include "ui/views/view.h"
28 #include "ui/views/widget/widget.h" 35 #include "ui/views/widget/widget.h"
29 #include "ui/views/window/non_client_view.h" 36 #include "ui/views/window/non_client_view.h"
30 37
31 using ui::GestureConfiguration; 38 using ui::GestureConfiguration;
32 using views::View; 39 using views::View;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 302 }
296 303
297 //////////////////////////////////////////////////////////////////////////////// 304 ////////////////////////////////////////////////////////////////////////////////
298 305
299 // Observer to watch for window restore. views::Widget does not provide a hook 306 // Observer to watch for window restore. views::Widget does not provide a hook
300 // to observe for window restore, so do this at the Aura level. 307 // to observe for window restore, so do this at the Aura level.
301 class ImmersiveModeControllerAsh::WindowObserver : public aura::WindowObserver { 308 class ImmersiveModeControllerAsh::WindowObserver : public aura::WindowObserver {
302 public: 309 public:
303 explicit WindowObserver(ImmersiveModeControllerAsh* controller) 310 explicit WindowObserver(ImmersiveModeControllerAsh* controller)
304 : controller_(controller) { 311 : controller_(controller) {
305 controller_->native_window_->AddObserver(this); 312 window_ = controller_->native_window_;
313 window_->AddObserver(this);
306 } 314 }
307 315
308 virtual ~WindowObserver() { 316 virtual ~WindowObserver() {
309 controller_->native_window_->RemoveObserver(this); 317 window_->RemoveObserver(this);
310 } 318 }
311 319
312 // aura::WindowObserver overrides: 320 // aura::WindowObserver overrides:
313 virtual void OnWindowPropertyChanged(aura::Window* window, 321 virtual void OnWindowPropertyChanged(aura::Window* window,
314 const void* key, 322 const void* key,
315 intptr_t old) OVERRIDE { 323 intptr_t old) OVERRIDE {
316 using aura::client::kShowStateKey; 324 using aura::client::kShowStateKey;
317 if (key == kShowStateKey) { 325 if (key == kShowStateKey) {
318 // Disable immersive mode when leaving the fullscreen state. 326 // Disable immersive mode when leaving the fullscreen state.
319 ui::WindowShowState show_state = static_cast<ui::WindowShowState>( 327 ui::WindowShowState show_state = static_cast<ui::WindowShowState>(
320 window->GetProperty(kShowStateKey)); 328 window->GetProperty(kShowStateKey));
321 if (controller_->IsEnabled() && 329 if (controller_->IsEnabled() &&
322 show_state != ui::SHOW_STATE_FULLSCREEN && 330 show_state != ui::SHOW_STATE_FULLSCREEN &&
323 show_state != ui::SHOW_STATE_MINIMIZED) { 331 show_state != ui::SHOW_STATE_MINIMIZED) {
324 controller_->delegate_->FullscreenStateChanged(); 332 controller_->delegate_->FullscreenStateChanged();
325 } 333 }
326 return; 334 return;
327 } 335 }
328 } 336 }
329 337
338 virtual void OnWindowAddedToRootWindow(aura::Window* window) {
339 if (window == window_)
sadrul 2013/05/23 18:22:07 DCHECK_EQ(window_, window) instead.
rharrison 2013/05/23 19:10:11 Done.
340 controller_->SetPreTargetHandler();
sadrul 2013/05/23 18:22:07 Do you need to override OnWindowRemovedFromRootWin
rharrison 2013/05/23 19:10:11 Done.
341 }
342
330 private: 343 private:
331 ImmersiveModeControllerAsh* controller_; // Not owned. 344 ImmersiveModeControllerAsh* controller_; // Not owned.
345 aura::Window* window_; // Not owned.
332 346
333 DISALLOW_COPY_AND_ASSIGN(WindowObserver); 347 DISALLOW_COPY_AND_ASSIGN(WindowObserver);
334 }; 348 };
335 349
336 //////////////////////////////////////////////////////////////////////////////// 350 ////////////////////////////////////////////////////////////////////////////////
337 351
338 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh() 352 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh()
339 : delegate_(NULL), 353 : delegate_(NULL),
340 widget_(NULL), 354 widget_(NULL),
341 top_container_(NULL), 355 top_container_(NULL),
(...skipping 29 matching lines...) Expand all
371 if (revealed_lock_count_ == 0) { 385 if (revealed_lock_count_ == 0) {
372 // Always animate ending the reveal fast. 386 // Always animate ending the reveal fast.
373 MaybeEndReveal(ANIMATE_FAST); 387 MaybeEndReveal(ANIMATE_FAST);
374 } 388 }
375 } 389 }
376 390
377 void ImmersiveModeControllerAsh::MaybeRevealWithoutAnimation() { 391 void ImmersiveModeControllerAsh::MaybeRevealWithoutAnimation() {
378 MaybeStartReveal(ANIMATE_NO); 392 MaybeStartReveal(ANIMATE_NO);
379 } 393 }
380 394
395 void ImmersiveModeControllerAsh::SetPreTargetHandler() {
396 if (!native_window_)
397 return;
398 aura::RootWindow* root_window = native_window_->GetRootWindow();
399 if (!root_window)
400 return;
401 if (observers_enabled_)
402 root_window->AddPreTargetHandler(this);
403 else
404 root_window->RemovePreTargetHandler(this);
405 }
406
381 void ImmersiveModeControllerAsh::Init( 407 void ImmersiveModeControllerAsh::Init(
382 Delegate* delegate, 408 Delegate* delegate,
383 views::Widget* widget, 409 views::Widget* widget,
384 TopContainerView* top_container) { 410 TopContainerView* top_container) {
385 delegate_ = delegate; 411 delegate_ = delegate;
386 widget_ = widget; 412 widget_ = widget;
387 // Browser view is detached from its widget during destruction. Cache the 413 // Browser view is detached from its widget during destruction. Cache the
388 // window pointer so |this| can stop observing during destruction. 414 // window pointer so |this| can stop observing during destruction.
389 native_window_ = widget_->GetNativeWindow(); 415 native_window_ = widget_->GetNativeWindow();
390 top_container_ = top_container; 416 top_container_ = top_container;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 views::Widget::GetWidgetForNativeWindow(native_window_); 681 views::Widget::GetWidgetForNativeWindow(native_window_);
656 views::FocusManager* focus_manager = widget->GetFocusManager(); 682 views::FocusManager* focus_manager = widget->GetFocusManager();
657 if (enable) { 683 if (enable) {
658 widget->AddObserver(this); 684 widget->AddObserver(this);
659 focus_manager->AddFocusChangeListener(this); 685 focus_manager->AddFocusChangeListener(this);
660 } else { 686 } else {
661 widget->RemoveObserver(this); 687 widget->RemoveObserver(this);
662 focus_manager->RemoveFocusChangeListener(this); 688 focus_manager->RemoveFocusChangeListener(this);
663 } 689 }
664 690
665 if (enable) 691 SetPreTargetHandler();
666 native_window_->AddPreTargetHandler(this);
667 else
668 native_window_->RemovePreTargetHandler(this);
669 692
670 // The window observer adds and removes itself from the native window. 693 // The window observer adds and removes itself from the native window.
671 window_observer_.reset(enable ? new WindowObserver(this) : NULL); 694 window_observer_.reset(enable ? new WindowObserver(this) : NULL);
672 695
673 if (enable) { 696 if (enable) {
674 registrar_.Add( 697 registrar_.Add(
675 this, 698 this,
676 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 699 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
677 content::Source<FullscreenController>( 700 content::Source<FullscreenController>(
678 delegate_->GetFullscreenController())); 701 delegate_->GetFullscreenController()));
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return SWIPE_CLOSE; 1047 return SWIPE_CLOSE;
1025 else if (event->details().scroll_y() > 0) 1048 else if (event->details().scroll_y() > 0)
1026 return SWIPE_OPEN; 1049 return SWIPE_OPEN;
1027 return SWIPE_NONE; 1050 return SWIPE_NONE;
1028 } 1051 }
1029 1052
1030 bool ImmersiveModeControllerAsh::IsNearTopContainer(gfx::Point location) const { 1053 bool ImmersiveModeControllerAsh::IsNearTopContainer(gfx::Point location) const {
1031 gfx::Rect near_bounds = top_container_->GetTargetBoundsInScreen(); 1054 gfx::Rect near_bounds = top_container_->GetTargetBoundsInScreen();
1032 if (reveal_state_ == CLOSED) 1055 if (reveal_state_ == CLOSED)
1033 near_bounds.Inset(gfx::Insets(0, 0, -kNearTopContainerDistance, 0)); 1056 near_bounds.Inset(gfx::Insets(0, 0, -kNearTopContainerDistance, 0));
1034 return near_bounds.Contains(location); 1057 return near_bounds.Contains(location) ||
1058 ((location.y() < near_bounds.y()) &&
1059 (location.x() >= near_bounds.x()) &&
1060 (location.x() <= near_bounds.x() + near_bounds.width()));
1035 } 1061 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/immersive_mode_controller_ash.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698