Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/exclusive_access/exclusive_access_bubble.h" | 5 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/strings/grit/ui_strings.h" | 17 #include "ui/strings/grit/ui_strings.h" |
| 18 | 18 |
| 19 // NOTE(koz): Linux doesn't use the thick shadowed border, so we add padding | 19 // NOTE(koz): Linux doesn't use the thick shadowed border, so we add padding |
| 20 // here. | 20 // here. |
| 21 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
| 22 const int ExclusiveAccessBubble::kPaddingPx = 8; | 22 const int ExclusiveAccessBubble::kPaddingPx = 8; |
| 23 #else | 23 #else |
| 24 const int ExclusiveAccessBubble::kPaddingPx = 15; | 24 const int ExclusiveAccessBubble::kPaddingPx = 15; |
| 25 #endif | 25 #endif |
| 26 const int ExclusiveAccessBubble::kInitialDelayMs = 3800; | 26 const int ExclusiveAccessBubble::kInitialDelayMs = 3800; |
| 27 const int ExclusiveAccessBubble::kIdleTimeMs = 2300; | 27 const int ExclusiveAccessBubble::kIdleTimeMs = 2300; |
| 28 const int ExclusiveAccessBubble::kPositionCheckHz = 10; | 28 const int ExclusiveAccessBubble::kPositionCheckHz = 10; |
| 29 const int ExclusiveAccessBubble::kSlideInRegionHeightPx = 4; | 29 const int ExclusiveAccessBubble::kSlideInRegionHeightPx = 4; |
| 30 const int ExclusiveAccessBubble::kSlideInDurationMs = 350; | 30 const int ExclusiveAccessBubble::kSlideInDurationMs = 350; |
| 31 const int ExclusiveAccessBubble::kSlideOutDurationMs = 700; | 31 const int ExclusiveAccessBubble::kSlideOutDurationMs = 700; |
| 32 const int ExclusiveAccessBubble::kPopupTopPx = 15; | 32 const int ExclusiveAccessBubble::kPopupTopPx = 15; |
| 33 | 33 |
| 34 ExclusiveAccessBubble::ExclusiveAccessBubble( | 34 ExclusiveAccessBubble::ExclusiveAccessBubble( |
| 35 Browser* browser, | 35 ExclusiveAccessManager* manager, |
| 36 const GURL& url, | 36 const GURL& url, |
| 37 ExclusiveAccessBubbleType bubble_type) | 37 ExclusiveAccessBubbleType bubble_type) |
| 38 : browser_(browser), url_(url), bubble_type_(bubble_type) { | 38 : manager_(manager), url_(url), bubble_type_(bubble_type) { |
| 39 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_); | 39 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 ExclusiveAccessBubble::~ExclusiveAccessBubble() { | 42 ExclusiveAccessBubble::~ExclusiveAccessBubble() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 void ExclusiveAccessBubble::StartWatchingMouse() { | 45 void ExclusiveAccessBubble::StartWatchingMouse() { |
| 46 // Start the initial delay timer and begin watching the mouse. | 46 // Start the initial delay timer and begin watching the mouse. |
| 47 initial_delay_.Start(FROM_HERE, | 47 initial_delay_.Start(FROM_HERE, |
| 48 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, | 48 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } else if (cursor_pos.y() < kSlideInRegionHeightPx && | 107 } else if (cursor_pos.y() < kSlideInRegionHeightPx && |
| 108 CanMouseTriggerSlideIn()) { | 108 CanMouseTriggerSlideIn()) { |
| 109 Show(); | 109 Show(); |
| 110 } else if (IsAnimating()) { | 110 } else if (IsAnimating()) { |
| 111 // The cursor is not idle and either it's in the slide-in region or it's in | 111 // The cursor is not idle and either it's in the slide-in region or it's in |
| 112 // the neutral region and we're sliding in or out. | 112 // the neutral region and we're sliding in or out. |
| 113 Show(); | 113 Show(); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ExclusiveAccessBubble::ToggleFullscreen() { | 117 void ExclusiveAccessBubble::ToggleFullscreen() { |
|
scheib
2015/02/25 19:30:13
While here, would you fix this too please: Rename
Sriram
2015/02/25 21:53:27
Actually this is explicitly dealing with fullscree
scheib
2015/02/25 22:31:51
It shouldn't be "Toggle", it is definitely not Tog
Sriram
2015/02/25 23:15:59
Done.
| |
| 118 browser_->exclusive_access_manager() | 118 manager_->fullscreen_controller()->ExitExclusiveAccessToPreviousState(); |
| 119 ->fullscreen_controller() | |
| 120 ->ExitExclusiveAccessToPreviousState(); | |
| 121 } | 119 } |
| 122 | 120 |
| 123 void ExclusiveAccessBubble::Accept() { | 121 void ExclusiveAccessBubble::Accept() { |
| 124 browser_->exclusive_access_manager()->OnAcceptExclusiveAccessPermission(); | 122 manager_->OnAcceptExclusiveAccessPermission(); |
| 125 } | 123 } |
| 126 | 124 |
| 127 void ExclusiveAccessBubble::Cancel() { | 125 void ExclusiveAccessBubble::Cancel() { |
| 128 browser_->exclusive_access_manager()->OnDenyExclusiveAccessPermission(); | 126 manager_->OnDenyExclusiveAccessPermission(); |
| 129 } | 127 } |
| 130 | 128 |
| 131 base::string16 ExclusiveAccessBubble::GetCurrentMessageText() const { | 129 base::string16 ExclusiveAccessBubble::GetCurrentMessageText() const { |
| 132 return exclusive_access_bubble::GetLabelTextForType( | 130 return exclusive_access_bubble::GetLabelTextForType( |
| 133 bubble_type_, url_, | 131 bubble_type_, url_, |
| 134 extensions::ExtensionRegistry::Get(browser_->profile())); | 132 extensions::ExtensionRegistry::Get( |
| 133 manager_->exclusive_access_context()->GetProfile())); | |
| 135 } | 134 } |
| 136 | 135 |
| 137 base::string16 ExclusiveAccessBubble::GetCurrentDenyButtonText() const { | 136 base::string16 ExclusiveAccessBubble::GetCurrentDenyButtonText() const { |
| 138 return exclusive_access_bubble::GetDenyButtonTextForType(bubble_type_); | 137 return exclusive_access_bubble::GetDenyButtonTextForType(bubble_type_); |
| 139 } | 138 } |
| 140 | 139 |
| 141 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const { | 140 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const { |
| 142 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_); | 141 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_); |
| 143 } | 142 } |
| 144 | 143 |
| 145 base::string16 ExclusiveAccessBubble::GetInstructionText() const { | 144 base::string16 ExclusiveAccessBubble::GetInstructionText() const { |
| 146 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, | 145 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, |
| 147 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); | 146 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); |
| 148 } | 147 } |
| OLD | NEW |