Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
Mike Wittman
2015/03/02 18:35:53
nit: Copyright 2015
Andre
2015/03/02 18:50:24
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" | |
| 6 | |
| 7 #import "chrome/browser/ui/cocoa/modal_dialog_client_cocoa.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_sheet_con troller.h" | |
| 10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | |
| 11 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
| 12 | |
| 13 using web_modal::NativeWebContentsModalDialog; | |
| 14 using web_modal::SingleWebContentsDialogManagerDelegate; | |
| 15 | |
| 16 SingleWebContentsDialogManagerCocoa::SingleWebContentsDialogManagerCocoa( | |
| 17 ModalDialogClientCocoa* client, | |
| 18 id<ConstrainedWindowSheet> sheet, | |
| 19 web_modal::SingleWebContentsDialogManagerDelegate* delegate) | |
| 20 : client_(client), | |
| 21 sheet_([sheet retain]), | |
| 22 delegate_(delegate), | |
| 23 shown_(false) { | |
| 24 if (client) | |
| 25 client->set_manager(this); | |
| 26 } | |
| 27 | |
| 28 SingleWebContentsDialogManagerCocoa::~SingleWebContentsDialogManagerCocoa() { | |
| 29 } | |
| 30 | |
| 31 void SingleWebContentsDialogManagerCocoa::Show() { | |
| 32 if (shown_) | |
| 33 return; | |
| 34 | |
| 35 content::WebContents* web_contents = delegate_->GetWebContents(); | |
| 36 NSWindow* parent_window = web_contents->GetTopLevelNativeWindow(); | |
| 37 NSView* parent_view = GetSheetParentViewForWebContents(web_contents); | |
| 38 if (!parent_window || !parent_view) | |
| 39 return; | |
| 40 | |
| 41 shown_ = true; | |
| 42 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] | |
| 43 showSheet:sheet_ forParentView:parent_view]; | |
| 44 } | |
| 45 | |
| 46 void SingleWebContentsDialogManagerCocoa::Hide() { | |
| 47 } | |
| 48 | |
| 49 void SingleWebContentsDialogManagerCocoa::Close() { | |
| 50 [[ConstrainedWindowSheetController controllerForSheet:sheet_] | |
| 51 closeSheet:sheet_]; | |
| 52 if (client_) { | |
| 53 client_->set_manager(nullptr); | |
| 54 client_->OnDialogClosing(); // client might delete itself here. | |
|
tapted
2015/03/02 04:28:50
nit: client -> |client_| (or "Client")
Andre
2015/03/02 18:47:31
Done.
| |
| 55 client_ = nullptr; | |
| 56 } | |
| 57 delegate_->WillClose(dialog()); | |
| 58 } | |
| 59 | |
| 60 void SingleWebContentsDialogManagerCocoa::Focus() { | |
| 61 } | |
| 62 | |
| 63 void SingleWebContentsDialogManagerCocoa::Pulse() { | |
| 64 [[ConstrainedWindowSheetController controllerForSheet:sheet_] | |
| 65 pulseSheet:sheet_]; | |
| 66 } | |
| 67 | |
| 68 void SingleWebContentsDialogManagerCocoa::HostChanged( | |
| 69 web_modal::WebContentsModalDialogHost* new_host) { | |
| 70 } | |
| 71 | |
| 72 NativeWebContentsModalDialog SingleWebContentsDialogManagerCocoa::dialog() { | |
| 73 return [sheet_ sheetWindow]; | |
| 74 } | |
| 75 | |
| 76 namespace web_modal { | |
| 77 | |
| 78 SingleWebContentsDialogManager* | |
| 79 WebContentsModalDialogManager::CreateNativeWebModalManager( | |
| 80 NativeWebContentsModalDialog dialog, | |
| 81 SingleWebContentsDialogManagerDelegate* delegate) { | |
| 82 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | |
| 83 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:dialog]); | |
| 84 return new SingleWebContentsDialogManagerCocoa(nullptr, sheet, delegate); | |
| 85 } | |
| 86 | |
| 87 } // namespace web_modal | |
| OLD | NEW |