File: exclusive_access_bubble.h

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (118 lines) | stat: -rw-r--r-- 4,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_
#define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_

#include "base/timer/timer.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/geometry/point.h"
#include "url/gurl.h"

class Browser;

namespace gfx {
class Rect;
}

// Bubble that informs the user when an exclusive access state is in effect and
// as to how to exit out of the state. Currently there are two exclusive access
// state, namely fullscreen and mouse lock.
class ExclusiveAccessBubble : public gfx::AnimationDelegate {
 public:
  explicit ExclusiveAccessBubble(Browser* browser,
                                 const GURL& url,
                                 ExclusiveAccessBubbleType bubble_type);
  ~ExclusiveAccessBubble() override;

 protected:
  static const int kPaddingPx;        // Amount of padding around the link
  static const int kInitialDelayMs;   // Initial time bubble remains onscreen
  static const int kIdleTimeMs;       // Time before mouse idle triggers hide
  static const int kPositionCheckHz;  // How fast to check the mouse position
  static const int kSlideInRegionHeightPx;
  // Height of region triggering
  // slide-in
  static const int kPopupTopPx;          // Space between the popup and the top
                                         // of the screen.
  static const int kSlideInDurationMs;   // Duration of slide-in animation
  static const int kSlideOutDurationMs;  // Duration of slide-out animation

  // Returns the current desirable rect for the popup window.  If
  // |ignore_animation_state| is true this returns the rect assuming the popup
  // is fully onscreen.
  virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0;
  virtual gfx::Point GetCursorScreenPoint() = 0;
  virtual bool WindowContainsPoint(gfx::Point pos) = 0;

  // Returns true if the window is active.
  virtual bool IsWindowActive() = 0;

  // Hides the bubble.  This is a separate function so it can be called by a
  // timer.
  virtual void Hide() = 0;

  // Shows the bubble.
  virtual void Show() = 0;

  virtual bool IsAnimating() = 0;

  // True if the mouse position can trigger sliding in the exit fullscreen
  // bubble when the bubble is hidden.
  virtual bool CanMouseTriggerSlideIn() const = 0;

  void StartWatchingMouse();
  void StopWatchingMouse();
  bool IsWatchingMouse() const;

  // Called repeatedly to get the current mouse position and animate the bubble
  // on or off the screen as appropriate.
  void CheckMousePosition();

  void ToggleFullscreen();
  // Accepts the request. Can cause FullscreenExitBubble to be deleted.
  void Accept();
  // Denys the request. Can cause FullscreenExitBubble to be deleted.
  void Cancel();

  // The following strings may change according to the content type and URL.
  base::string16 GetCurrentMessageText() const;
  base::string16 GetCurrentDenyButtonText() const;

  // The following strings never change.
  base::string16 GetAllowButtonText() const;
  base::string16 GetInstructionText() const;

  // The browser this bubble is in.
  Browser* browser_;

  // The host the bubble is for, can be empty.
  GURL url_;

  // The type of the bubble; controls e.g. which buttons to show.
  ExclusiveAccessBubbleType bubble_type_;

 private:
  // Timer to delay before allowing the bubble to hide after it's initially
  // shown.
  base::OneShotTimer<ExclusiveAccessBubble> initial_delay_;

  // Timer to see how long the mouse has been idle.
  base::OneShotTimer<ExclusiveAccessBubble> idle_timeout_;

  // Timer to poll the current mouse position.  We can't just listen for mouse
  // events without putting a non-empty HWND onscreen (or hooking Windows, which
  // has other problems), so instead we run a low-frequency poller to see if the
  // user has moved in or out of our show/hide regions.
  base::RepeatingTimer<ExclusiveAccessBubble> mouse_position_checker_;

  // The most recently seen mouse position, in screen coordinates.  Used to see
  // if the mouse has moved since our last check.
  gfx::Point last_mouse_pos_;

  DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubble);
};

#endif  // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_