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

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: 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/browser_view.h" 18 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/frame/top_container_view.h" 19 #include "chrome/browser/ui/views/frame/top_container_view.h"
15 #include "chrome/browser/ui/views/tabs/tab_strip.h" 20 #include "chrome/browser/ui/views/tabs/tab_strip.h"
16 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
17 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
18 #include "ui/aura/client/activation_client.h" 23 #include "ui/aura/client/activation_client.h"
19 #include "ui/aura/client/aura_constants.h" 24 #include "ui/aura/client/aura_constants.h"
20 #include "ui/aura/client/capture_client.h" 25 #include "ui/aura/client/capture_client.h"
21 #include "ui/aura/env.h" 26 #include "ui/aura/env.h"
27 #include "ui/aura/root_window.h"
22 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
23 #include "ui/aura/window_observer.h" 29 #include "ui/aura/window_observer.h"
30 #include "ui/base/ui_base_switches.h"
24 #include "ui/compositor/layer_animation_observer.h" 31 #include "ui/compositor/layer_animation_observer.h"
25 #include "ui/compositor/scoped_layer_animation_settings.h" 32 #include "ui/compositor/scoped_layer_animation_settings.h"
26 #include "ui/gfx/screen.h" 33 #include "ui/gfx/screen.h"
27 #include "ui/gfx/transform.h" 34 #include "ui/gfx/transform.h"
28 #include "ui/views/view.h" 35 #include "ui/views/view.h"
29 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
30 #include "ui/views/window/non_client_view.h" 37 #include "ui/views/window/non_client_view.h"
31 38
32 using views::View; 39 using views::View;
33 40
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 //////////////////////////////////////////////////////////////////////////////// 348 ////////////////////////////////////////////////////////////////////////////////
342 349
343 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh() 350 ImmersiveModeControllerAsh::ImmersiveModeControllerAsh()
344 : browser_view_(NULL), 351 : browser_view_(NULL),
345 observers_enabled_(false), 352 observers_enabled_(false),
346 enabled_(false), 353 enabled_(false),
347 reveal_state_(CLOSED), 354 reveal_state_(CLOSED),
348 revealed_lock_count_(0), 355 revealed_lock_count_(0),
349 tab_indicator_visibility_(TAB_INDICATORS_HIDE), 356 tab_indicator_visibility_(TAB_INDICATORS_HIDE),
350 native_window_(NULL), 357 native_window_(NULL),
358 root_window_(NULL),
351 weak_ptr_factory_(this), 359 weak_ptr_factory_(this),
352 gesture_begun_(false) { 360 gesture_begun_(false),
361 bezel_inset_(0) {
353 } 362 }
354 363
355 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() { 364 ImmersiveModeControllerAsh::~ImmersiveModeControllerAsh() {
356 // The browser view is being destroyed so there's no need to update its 365 // The browser view is being destroyed so there's no need to update its
357 // layout or layers, even if the top views are revealed. But the window 366 // layout or layers, even if the top views are revealed. But the window
358 // observers still need to be removed. 367 // observers still need to be removed.
359 EnableWindowObservers(false); 368 EnableWindowObservers(false);
360 } 369 }
361 370
362 void ImmersiveModeControllerAsh::LockRevealedState( 371 void ImmersiveModeControllerAsh::LockRevealedState(
(...skipping 16 matching lines...) Expand all
379 void ImmersiveModeControllerAsh::MaybeRevealWithoutAnimation() { 388 void ImmersiveModeControllerAsh::MaybeRevealWithoutAnimation() {
380 MaybeStartReveal(ANIMATE_NO); 389 MaybeStartReveal(ANIMATE_NO);
381 } 390 }
382 391
383 void ImmersiveModeControllerAsh::Init(BrowserView* browser_view) { 392 void ImmersiveModeControllerAsh::Init(BrowserView* browser_view) {
384 browser_view_ = browser_view; 393 browser_view_ = browser_view;
385 // Browser view is detached from its widget during destruction. Cache the 394 // Browser view is detached from its widget during destruction. Cache the
386 // window pointer so |this| can stop observing during destruction. 395 // window pointer so |this| can stop observing during destruction.
387 native_window_ = browser_view_->GetNativeWindow(); 396 native_window_ = browser_view_->GetNativeWindow();
388 DCHECK(native_window_); 397 DCHECK(native_window_);
398 root_window_ = native_window_->GetRootWindow();
399 DCHECK(root_window_);
389 400
390 // Optionally allow the tab indicators to be hidden. 401 // Optionally allow the tab indicators to be hidden.
391 if (CommandLine::ForCurrentProcess()-> 402 if (CommandLine::ForCurrentProcess()->
392 HasSwitch(ash::switches::kAshImmersiveHideTabIndicators)) { 403 HasSwitch(ash::switches::kAshImmersiveHideTabIndicators)) {
393 tab_indicator_visibility_ = TAB_INDICATORS_FORCE_HIDE; 404 tab_indicator_visibility_ = TAB_INDICATORS_FORCE_HIDE;
394 } 405 }
395 406
396 anchored_widget_manager_.reset(new AnchoredWidgetManager(this)); 407 anchored_widget_manager_.reset(new AnchoredWidgetManager(this));
408
409 // Add inset to account for maximum bezel sensor.
410 #if defined(USE_XI2_MT)
411 std::vector<std::string> parts;
412 if (Tokenize(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
413 switches::kTouchCalibration), ",", &parts) >= 4) {
414 for (int i = 0; i < 4; i++) {
415 int new_inset;
416 if (base::StringToInt(parts[i], &new_inset)) {
417 bezel_inset_ = std::max(new_inset, bezel_inset_);
418 }
419 }
420 }
421 #endif
397 } 422 }
398 423
399 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) { 424 void ImmersiveModeControllerAsh::SetEnabled(bool enabled) {
400 DCHECK(browser_view_) << "Must initialize before enabling"; 425 DCHECK(browser_view_) << "Must initialize before enabling";
401 if (enabled_ == enabled) 426 if (enabled_ == enabled)
402 return; 427 return;
403 enabled_ = enabled; 428 enabled_ = enabled;
404 429
405 // Delay the initialization of the window observers till the first call to 430 // Delay the initialization of the window observers till the first call to
406 // SetEnabled(true) because FullscreenController is not yet initialized when 431 // SetEnabled(true) because FullscreenController is not yet initialized when
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 views::FocusManager* focus_manager = widget->GetFocusManager(); 691 views::FocusManager* focus_manager = widget->GetFocusManager();
667 if (enable) { 692 if (enable) {
668 widget->AddObserver(this); 693 widget->AddObserver(this);
669 focus_manager->AddFocusChangeListener(this); 694 focus_manager->AddFocusChangeListener(this);
670 } else { 695 } else {
671 widget->RemoveObserver(this); 696 widget->RemoveObserver(this);
672 focus_manager->RemoveFocusChangeListener(this); 697 focus_manager->RemoveFocusChangeListener(this);
673 } 698 }
674 699
675 if (enable) 700 if (enable)
676 native_window_->AddPreTargetHandler(this); 701 root_window_->AddPreTargetHandler(this);
677 else 702 else
678 native_window_->RemovePreTargetHandler(this); 703 root_window_->RemovePreTargetHandler(this);
sadrul 2013/05/22 18:22:45 Is it possible for root_window_ to become invalid
rharrison 2013/05/22 20:58:49 Done.
679 704
680 // The window observer adds and removes itself from the native window. 705 // The window observer adds and removes itself from the native window.
681 window_observer_.reset(enable ? new WindowObserver(this) : NULL); 706 window_observer_.reset(enable ? new WindowObserver(this) : NULL);
682 707
683 if (enable) { 708 if (enable) {
684 registrar_.Add( 709 registrar_.Add(
685 this, 710 this,
686 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 711 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
687 content::Source<FullscreenController>( 712 content::Source<FullscreenController>(
688 browser_view_->browser()->fullscreen_controller())); 713 browser_view_->browser()->fullscreen_controller()));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 return SWIPE_CLOSE; 1015 return SWIPE_CLOSE;
991 else if (event->details().scroll_y() > 0) 1016 else if (event->details().scroll_y() > 0)
992 return SWIPE_OPEN; 1017 return SWIPE_OPEN;
993 return SWIPE_NONE; 1018 return SWIPE_NONE;
994 } 1019 }
995 1020
996 bool ImmersiveModeControllerAsh::IsNearTopContainer(gfx::Point location) const { 1021 bool ImmersiveModeControllerAsh::IsNearTopContainer(gfx::Point location) const {
997 gfx::Rect near_bounds = 1022 gfx::Rect near_bounds =
998 browser_view_->top_container()->GetTargetBoundsInScreen(); 1023 browser_view_->top_container()->GetTargetBoundsInScreen();
999 if (reveal_state_ == CLOSED) 1024 if (reveal_state_ == CLOSED)
1000 near_bounds.Inset(gfx::Insets(0, 0, -kNearTopContainerDistance, 0)); 1025 near_bounds.Inset(gfx::Insets(-bezel_inset_,
1026 0,
1027 -kNearTopContainerDistance,
1028 0));
1001 return near_bounds.Contains(location); 1029 return near_bounds.Contains(location);
sadrul 2013/05/22 18:22:45 Could you just do: return near_bounds.Contains
rharrison 2013/05/22 20:58:49 Done.
1002 } 1030 }
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