OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" | 5 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" |
6 | 6 |
7 #include "chrome/browser/download/download_shelf.h" | 7 #include "chrome/browser/download/download_shelf.h" |
8 #include "chrome/browser/fullscreen.h" | 8 #include "chrome/browser/fullscreen.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
11 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h" |
| 13 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
12 #include "chrome/browser/ui/status_bubble.h" | 14 #include "chrome/browser/ui/status_bubble.h" |
| 15 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 16 #import "ui/gfx/mac/coordinate_conversion.h" |
13 | 17 |
14 ExclusiveAccessController::ExclusiveAccessController( | 18 ExclusiveAccessController::ExclusiveAccessController( |
15 BrowserWindowController* controller, | 19 BrowserWindowController* controller, |
16 Browser* browser) | 20 Browser* browser) |
17 : controller_(controller), | 21 : controller_(controller), |
18 browser_(browser), | 22 browser_(browser), |
19 bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) {} | 23 bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) {} |
20 | 24 |
21 ExclusiveAccessController::~ExclusiveAccessController() {} | 25 ExclusiveAccessController::~ExclusiveAccessController() {} |
22 | 26 |
23 void ExclusiveAccessController::Show() { | 27 void ExclusiveAccessController::Show() { |
| 28 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
| 29 views_bubble_.reset( |
| 30 new ExclusiveAccessBubbleViews(this, url_, bubble_type_)); |
| 31 return; |
| 32 } |
| 33 |
24 [cocoa_bubble_ closeImmediately]; | 34 [cocoa_bubble_ closeImmediately]; |
25 cocoa_bubble_.reset([[ExclusiveAccessBubbleWindowController alloc] | 35 cocoa_bubble_.reset([[ExclusiveAccessBubbleWindowController alloc] |
26 initWithOwner:controller_ | 36 initWithOwner:controller_ |
27 exclusive_access_manager:browser_->exclusive_access_manager() | 37 exclusive_access_manager:browser_->exclusive_access_manager() |
28 profile:browser_->profile() | 38 profile:browser_->profile() |
29 url:url_ | 39 url:url_ |
30 bubbleType:bubble_type_]); | 40 bubbleType:bubble_type_]); |
31 [cocoa_bubble_ showWindow]; | 41 [cocoa_bubble_ showWindow]; |
32 } | 42 } |
33 | 43 |
34 void ExclusiveAccessController::Destroy() { | 44 void ExclusiveAccessController::Destroy() { |
| 45 views_bubble_.reset(); |
35 [cocoa_bubble_ closeImmediately]; | 46 [cocoa_bubble_ closeImmediately]; |
36 cocoa_bubble_.reset(); | 47 cocoa_bubble_.reset(); |
37 url_ = GURL(); | 48 url_ = GURL(); |
38 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; | 49 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; |
39 } | 50 } |
40 | 51 |
41 void ExclusiveAccessController::Layout(CGFloat max_y) { | 52 void ExclusiveAccessController::Layout(CGFloat max_y) { |
| 53 if (views_bubble_) |
| 54 views_bubble_->RepositionIfVisible(); |
42 [cocoa_bubble_ positionInWindowAtTop:max_y]; | 55 [cocoa_bubble_ positionInWindowAtTop:max_y]; |
43 } | 56 } |
44 | 57 |
45 Profile* ExclusiveAccessController::GetProfile() { | 58 Profile* ExclusiveAccessController::GetProfile() { |
46 return browser_->profile(); | 59 return browser_->profile(); |
47 } | 60 } |
48 | 61 |
49 bool ExclusiveAccessController::IsFullscreen() const { | 62 bool ExclusiveAccessController::IsFullscreen() const { |
50 return [controller_ isInAnyFullscreenMode]; | 63 return [controller_ isInAnyFullscreenMode]; |
51 } | 64 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 104 |
92 void ExclusiveAccessController::UpdateExclusiveAccessExitBubbleContent( | 105 void ExclusiveAccessController::UpdateExclusiveAccessExitBubbleContent( |
93 const GURL& url, | 106 const GURL& url, |
94 ExclusiveAccessBubbleType bubble_type) { | 107 ExclusiveAccessBubbleType bubble_type) { |
95 url_ = url; | 108 url_ = url; |
96 bubble_type_ = bubble_type; | 109 bubble_type_ = bubble_type; |
97 [controller_ updateFullscreenExitBubble]; | 110 [controller_ updateFullscreenExitBubble]; |
98 } | 111 } |
99 | 112 |
100 void ExclusiveAccessController::OnExclusiveAccessUserInput() { | 113 void ExclusiveAccessController::OnExclusiveAccessUserInput() { |
101 // TODO(mgiuca): Route this signal to the exclusive access bubble on Mac. | 114 if (views_bubble_) |
| 115 views_bubble_->OnUserInput(); |
102 } | 116 } |
103 | 117 |
104 content::WebContents* ExclusiveAccessController::GetActiveWebContents() { | 118 content::WebContents* ExclusiveAccessController::GetActiveWebContents() { |
105 return browser_->tab_strip_model()->GetActiveWebContents(); | 119 return browser_->tab_strip_model()->GetActiveWebContents(); |
106 } | 120 } |
107 | 121 |
108 void ExclusiveAccessController::UnhideDownloadShelf() { | 122 void ExclusiveAccessController::UnhideDownloadShelf() { |
109 GetBrowserWindow()->GetDownloadShelf()->Unhide(); | 123 GetBrowserWindow()->GetDownloadShelf()->Unhide(); |
110 } | 124 } |
111 | 125 |
112 void ExclusiveAccessController::HideDownloadShelf() { | 126 void ExclusiveAccessController::HideDownloadShelf() { |
113 GetBrowserWindow()->GetDownloadShelf()->Hide(); | 127 GetBrowserWindow()->GetDownloadShelf()->Hide(); |
114 StatusBubble* statusBubble = GetBrowserWindow()->GetStatusBubble(); | 128 StatusBubble* statusBubble = GetBrowserWindow()->GetStatusBubble(); |
115 if (statusBubble) | 129 if (statusBubble) |
116 statusBubble->Hide(); | 130 statusBubble->Hide(); |
117 } | 131 } |
118 | 132 |
| 133 bool ExclusiveAccessController::GetAcceleratorForCommandId( |
| 134 int cmd_id, |
| 135 ui::Accelerator* accelerator) { |
| 136 *accelerator = |
| 137 *AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(cmd_id); |
| 138 return true; |
| 139 } |
| 140 |
| 141 ExclusiveAccessManager* ExclusiveAccessController::GetExclusiveAccessManager() { |
| 142 return browser_->exclusive_access_manager(); |
| 143 } |
| 144 |
| 145 views::Widget* ExclusiveAccessController::GetBubbleAssociatedWidget() { |
| 146 NOTREACHED(); // Only used for non-simplified UI. |
| 147 return nullptr; |
| 148 } |
| 149 |
| 150 ui::AcceleratorProvider* ExclusiveAccessController::GetAcceleratorProvider() { |
| 151 return this; |
| 152 } |
| 153 |
| 154 gfx::NativeView ExclusiveAccessController::GetBubbleParentView() const { |
| 155 return [[controller_ window] contentView]; |
| 156 } |
| 157 |
| 158 gfx::Point ExclusiveAccessController::GetCursorPointInParent() const { |
| 159 NSWindow* window = [controller_ window]; |
| 160 NSPoint location = [window convertScreenToBase:[NSEvent mouseLocation]]; |
| 161 return gfx::Point(location.x, |
| 162 NSHeight([[window contentView] frame]) - location.y); |
| 163 } |
| 164 |
| 165 gfx::Rect ExclusiveAccessController::GetClientAreaBoundsInScreen() const { |
| 166 return gfx::ScreenRectFromNSRect([[controller_ window] frame]); |
| 167 } |
| 168 |
| 169 bool ExclusiveAccessController::IsImmersiveModeEnabled() { |
| 170 return false; |
| 171 } |
| 172 |
| 173 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { |
| 174 NOTREACHED(); // Only used for ImmersiveMode. |
| 175 return gfx::Rect(); |
| 176 } |
| 177 |
119 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { | 178 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { |
120 return [controller_ browserWindow]; | 179 return [controller_ browserWindow]; |
121 } | 180 } |
OLD | NEW |