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 #include "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
12 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h" | |
tapted
2016/05/25 03:53:27
Delete exclusive_access_bubble_window_controller.h
Matt Giuca
2016/05/26 04:15:40
Acknowledged.
| |
13 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 12 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
14 #include "chrome/browser/ui/status_bubble.h" | 13 #include "chrome/browser/ui/status_bubble.h" |
15 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 14 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
16 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
17 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
18 #include "ui/base/cocoa/cocoa_base_utils.h" | 17 #include "ui/base/cocoa/cocoa_base_utils.h" |
19 #import "ui/gfx/mac/coordinate_conversion.h" | 18 #import "ui/gfx/mac/coordinate_conversion.h" |
20 | 19 |
21 ExclusiveAccessController::ExclusiveAccessController( | 20 ExclusiveAccessController::ExclusiveAccessController( |
22 BrowserWindowController* controller, | 21 BrowserWindowController* controller, |
23 Browser* browser) | 22 Browser* browser) |
24 : controller_(controller), | 23 : controller_(controller), |
25 browser_(browser), | 24 browser_(browser), |
26 bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) { | 25 bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) { |
27 pref_registrar_.Init(GetProfile()->GetPrefs()); | 26 pref_registrar_.Init(GetProfile()->GetPrefs()); |
28 pref_registrar_.Add( | 27 pref_registrar_.Add( |
29 prefs::kShowFullscreenToolbar, | 28 prefs::kShowFullscreenToolbar, |
30 base::Bind(&ExclusiveAccessController::UpdateFullscreenToolbar, | 29 base::Bind(&ExclusiveAccessController::UpdateFullscreenToolbar, |
31 base::Unretained(this))); | 30 base::Unretained(this))); |
32 } | 31 } |
33 | 32 |
34 ExclusiveAccessController::~ExclusiveAccessController() {} | 33 ExclusiveAccessController::~ExclusiveAccessController() {} |
35 | 34 |
36 void ExclusiveAccessController::Show() { | 35 void ExclusiveAccessController::Show() { |
37 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 36 views_bubble_.reset(new ExclusiveAccessBubbleViews(this, url_, bubble_type_)); |
38 views_bubble_.reset( | 37 return; |
scheib
2016/05/24 19:43:47
return; not needed.
Matt Giuca
2016/05/26 04:15:40
Done.
| |
39 new ExclusiveAccessBubbleViews(this, url_, bubble_type_)); | |
40 return; | |
41 } | |
42 | |
43 [cocoa_bubble_ closeImmediately]; | |
44 cocoa_bubble_.reset([[ExclusiveAccessBubbleWindowController alloc] | |
45 initWithOwner:controller_ | |
46 exclusive_access_manager:browser_->exclusive_access_manager() | |
47 profile:browser_->profile() | |
48 url:url_ | |
49 bubbleType:bubble_type_]); | |
50 [cocoa_bubble_ showWindow]; | |
51 } | 38 } |
52 | 39 |
53 void ExclusiveAccessController::Destroy() { | 40 void ExclusiveAccessController::Destroy() { |
54 views_bubble_.reset(); | 41 views_bubble_.reset(); |
55 [cocoa_bubble_ closeImmediately]; | |
56 cocoa_bubble_.reset(); | |
57 url_ = GURL(); | 42 url_ = GURL(); |
58 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; | 43 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; |
59 } | 44 } |
60 | 45 |
61 void ExclusiveAccessController::Layout(CGFloat max_y) { | 46 void ExclusiveAccessController::Layout(CGFloat max_y) { |
62 if (views_bubble_) | 47 if (views_bubble_) |
63 views_bubble_->RepositionIfVisible(); | 48 views_bubble_->RepositionIfVisible(); |
64 [cocoa_bubble_ positionInWindowAtTop:max_y]; | |
65 } | 49 } |
66 | 50 |
67 Profile* ExclusiveAccessController::GetProfile() { | 51 Profile* ExclusiveAccessController::GetProfile() { |
68 return browser_->profile(); | 52 return browser_->profile(); |
69 } | 53 } |
70 | 54 |
71 bool ExclusiveAccessController::IsFullscreen() const { | 55 bool ExclusiveAccessController::IsFullscreen() const { |
72 return [controller_ isInAnyFullscreenMode]; | 56 return [controller_ isInAnyFullscreenMode]; |
73 } | 57 } |
74 | 58 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 *accelerator = | 131 *accelerator = |
148 *AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(cmd_id); | 132 *AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(cmd_id); |
149 return true; | 133 return true; |
150 } | 134 } |
151 | 135 |
152 ExclusiveAccessManager* ExclusiveAccessController::GetExclusiveAccessManager() { | 136 ExclusiveAccessManager* ExclusiveAccessController::GetExclusiveAccessManager() { |
153 return browser_->exclusive_access_manager(); | 137 return browser_->exclusive_access_manager(); |
154 } | 138 } |
155 | 139 |
156 views::Widget* ExclusiveAccessController::GetBubbleAssociatedWidget() { | 140 views::Widget* ExclusiveAccessController::GetBubbleAssociatedWidget() { |
157 NOTREACHED(); // Only used for non-simplified UI. | 141 NOTREACHED(); // Only used for non-simplified UI. |
tapted
2016/05/25 03:53:27
Can this be hit now? That is, if we're partially a
Matt Giuca
2016/05/26 04:15:40
I haven't actually tested this (outside of running
tapted
2016/05/26 05:08:41
It crash:
[21133:1295:0526/150654:FATAL:exclusive
Matt Giuca
2016/05/26 05:57:30
OK. Sent out a CL to disable the flag on Mac which
| |
158 return nullptr; | 142 return nullptr; |
159 } | 143 } |
160 | 144 |
161 ui::AcceleratorProvider* ExclusiveAccessController::GetAcceleratorProvider() { | 145 ui::AcceleratorProvider* ExclusiveAccessController::GetAcceleratorProvider() { |
162 return this; | 146 return this; |
163 } | 147 } |
164 | 148 |
165 gfx::NativeView ExclusiveAccessController::GetBubbleParentView() const { | 149 gfx::NativeView ExclusiveAccessController::GetBubbleParentView() const { |
166 return [[controller_ window] contentView]; | 150 return [[controller_ window] contentView]; |
167 } | 151 } |
(...skipping 15 matching lines...) Expand all Loading... | |
183 } | 167 } |
184 | 168 |
185 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { | 169 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { |
186 NOTREACHED(); // Only used for ImmersiveMode. | 170 NOTREACHED(); // Only used for ImmersiveMode. |
187 return gfx::Rect(); | 171 return gfx::Rect(); |
188 } | 172 } |
189 | 173 |
190 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { | 174 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { |
191 return [controller_ browserWindow]; | 175 return [controller_ browserWindow]; |
192 } | 176 } |
OLD | NEW |