| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/cocoa/passwords/password_prompt_view_bridge.h" |
| 6 |
| 7 #include "chrome/browser/profiles/profile.h" |
| 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
| 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" |
| 10 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" |
| 11 #include "chrome/browser/ui/passwords/password_dialog_controller.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 |
| 14 PasswordPromptViewBridge::PasswordPromptViewBridge( |
| 15 PasswordDialogController* controller, |
| 16 content::WebContents* web_contents) |
| 17 : controller_(controller), |
| 18 web_contents_(web_contents) { |
| 19 } |
| 20 |
| 21 PasswordPromptViewBridge::~PasswordPromptViewBridge() = default; |
| 22 |
| 23 void PasswordPromptViewBridge::Show() { |
| 24 view_controller_.reset( |
| 25 [[AccountChooserViewController alloc] initWithBridge:this]); |
| 26 // Setup the constrained window that will show the view. |
| 27 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] |
| 28 initWithContentRect:[[view_controller_ view] bounds]]); |
| 29 [window setContentView:[view_controller_ view]]; |
| 30 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
| 31 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); |
| 32 constrained_window_.reset( |
| 33 new ConstrainedWindowMac(this, web_contents_, sheet)); |
| 34 } |
| 35 |
| 36 void PasswordPromptViewBridge::ControllerGone() { |
| 37 controller_ = nullptr; |
| 38 PerformClose(); |
| 39 } |
| 40 |
| 41 void PasswordPromptViewBridge::OnConstrainedWindowClosed( |
| 42 ConstrainedWindowMac* window) { |
| 43 if (controller_) |
| 44 controller_->OnCloseAccountChooser(); |
| 45 delete this; |
| 46 } |
| 47 |
| 48 void PasswordPromptViewBridge::PerformClose() { |
| 49 constrained_window_->CloseWebContentsModalDialog(); |
| 50 } |
| 51 |
| 52 PasswordDialogController* |
| 53 PasswordPromptViewBridge::GetDialogController() { |
| 54 return controller_; |
| 55 } |
| 56 |
| 57 net::URLRequestContextGetter* |
| 58 PasswordPromptViewBridge::GetRequestContext() const { |
| 59 return Profile::FromBrowserContext(web_contents_->GetBrowserContext())-> |
| 60 GetRequestContext(); |
| 61 } |
| 62 |
| 63 AccountChooserPrompt* CreateAccountChooserPromptView( |
| 64 PasswordDialogController* controller, content::WebContents* web_contents) { |
| 65 return new PasswordPromptViewBridge(controller, web_contents); |
| 66 } |
| OLD | NEW |