| 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" | |
| 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( | |
| 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 } | 37 } |
| 52 | 38 |
| 53 void ExclusiveAccessController::Destroy() { | 39 void ExclusiveAccessController::Destroy() { |
| 54 views_bubble_.reset(); | 40 views_bubble_.reset(); |
| 55 [cocoa_bubble_ closeImmediately]; | |
| 56 cocoa_bubble_.reset(); | |
| 57 url_ = GURL(); | 41 url_ = GURL(); |
| 58 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; | 42 bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE; |
| 59 } | 43 } |
| 60 | 44 |
| 61 void ExclusiveAccessController::Layout(CGFloat max_y) { | 45 void ExclusiveAccessController::Layout(CGFloat max_y) { |
| 62 if (views_bubble_) | 46 if (views_bubble_) |
| 63 views_bubble_->RepositionIfVisible(); | 47 views_bubble_->RepositionIfVisible(); |
| 64 [cocoa_bubble_ positionInWindowAtTop:max_y]; | |
| 65 } | 48 } |
| 66 | 49 |
| 67 Profile* ExclusiveAccessController::GetProfile() { | 50 Profile* ExclusiveAccessController::GetProfile() { |
| 68 return browser_->profile(); | 51 return browser_->profile(); |
| 69 } | 52 } |
| 70 | 53 |
| 71 bool ExclusiveAccessController::IsFullscreen() const { | 54 bool ExclusiveAccessController::IsFullscreen() const { |
| 72 return [controller_ isInAnyFullscreenMode]; | 55 return [controller_ isInAnyFullscreenMode]; |
| 73 } | 56 } |
| 74 | 57 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 166 } |
| 184 | 167 |
| 185 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { | 168 gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() { |
| 186 NOTREACHED(); // Only used for ImmersiveMode. | 169 NOTREACHED(); // Only used for ImmersiveMode. |
| 187 return gfx::Rect(); | 170 return gfx::Rect(); |
| 188 } | 171 } |
| 189 | 172 |
| 190 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { | 173 BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const { |
| 191 return [controller_ browserWindow]; | 174 return [controller_ browserWindow]; |
| 192 } | 175 } |
| OLD | NEW |