Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/single_web_contents_dialog_manager_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" | 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" |
| 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.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" | 10 #include "chrome/browser/ui/tab_dialogs.h" |
| 11 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 11 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 12 | 12 #include "content/public/browser/web_contents.h" |
| 13 using web_modal::SingleWebContentsDialogManagerDelegate; | |
| 14 | 13 |
| 15 SingleWebContentsDialogManagerCocoa::SingleWebContentsDialogManagerCocoa( | 14 SingleWebContentsDialogManagerCocoa::SingleWebContentsDialogManagerCocoa( |
| 16 ConstrainedWindowMac* client, | 15 ConstrainedWindowMac* client, |
| 17 id<ConstrainedWindowSheet> sheet, | 16 id<ConstrainedWindowSheet> sheet, |
| 18 web_modal::SingleWebContentsDialogManagerDelegate* delegate) | 17 web_modal::SingleWebContentsDialogManagerDelegate* delegate) |
| 19 : client_(client), | 18 : client_(client), |
| 20 sheet_([sheet retain]), | 19 sheet_([sheet retain]), |
| 21 delegate_(delegate), | 20 delegate_(delegate), |
| 22 shown_(false) { | 21 shown_(false) { |
| 23 if (client) | 22 if (client) |
| 24 client->set_manager(this); | 23 client->set_manager(this); |
| 25 } | 24 } |
| 26 | 25 |
| 27 SingleWebContentsDialogManagerCocoa::~SingleWebContentsDialogManagerCocoa() { | 26 SingleWebContentsDialogManagerCocoa::~SingleWebContentsDialogManagerCocoa() { |
| 28 } | 27 } |
| 29 | 28 |
| 30 void SingleWebContentsDialogManagerCocoa::Show() { | 29 void SingleWebContentsDialogManagerCocoa::Show() { |
| 31 if (shown_) | 30 if (shown_) |
| 32 return; | 31 return; |
| 33 | 32 |
| 34 content::WebContents* web_contents = delegate_->GetWebContents(); | 33 content::WebContents* web_contents = delegate_->GetWebContents(); |
| 35 NSWindow* parent_window = web_contents->GetTopLevelNativeWindow(); | 34 NSWindow* parent_window = web_contents->GetTopLevelNativeWindow(); |
| 36 NSView* parent_view = GetSheetParentViewForWebContents(web_contents); | 35 TabDialogs* tab_dialogs = TabDialogs::FromWebContents(web_contents); |
| 36 // |tab_dialogs| is null when |web_contents| is inside a packaged app window. | |
| 37 NSView* parent_view = tab_dialogs ? tab_dialogs->GetDialogParentView() | |
| 38 : web_contents->GetNativeView(); | |
|
Andre
2015/04/02 04:04:27
This is a change when showing a dialog over an app
| |
| 37 if (!parent_window || !parent_view) | 39 if (!parent_window || !parent_view) |
| 38 return; | 40 return; |
| 39 | 41 |
| 40 shown_ = true; | 42 shown_ = true; |
| 41 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] | 43 [[ConstrainedWindowSheetController controllerForParentWindow:parent_window] |
| 42 showSheet:sheet_ forParentView:parent_view]; | 44 showSheet:sheet_ forParentView:parent_view]; |
| 43 } | 45 } |
| 44 | 46 |
| 45 void SingleWebContentsDialogManagerCocoa::Hide() { | 47 void SingleWebContentsDialogManagerCocoa::Hide() { |
| 46 } | 48 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 64 pulseSheet:sheet_]; | 66 pulseSheet:sheet_]; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void SingleWebContentsDialogManagerCocoa::HostChanged( | 69 void SingleWebContentsDialogManagerCocoa::HostChanged( |
| 68 web_modal::WebContentsModalDialogHost* new_host) { | 70 web_modal::WebContentsModalDialogHost* new_host) { |
| 69 } | 71 } |
| 70 | 72 |
| 71 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() { | 73 gfx::NativeWindow SingleWebContentsDialogManagerCocoa::dialog() { |
| 72 return [sheet_ sheetWindow]; | 74 return [sheet_ sheetWindow]; |
| 73 } | 75 } |
| 74 | |
| 75 namespace web_modal { | |
| 76 | |
| 77 SingleWebContentsDialogManager* | |
| 78 WebContentsModalDialogManager::CreateNativeWebModalManager( | |
| 79 gfx::NativeWindow dialog, | |
| 80 SingleWebContentsDialogManagerDelegate* delegate) { | |
| 81 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | |
| 82 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:dialog]); | |
| 83 return new SingleWebContentsDialogManagerCocoa(nullptr, sheet, delegate); | |
| 84 } | |
| 85 | |
| 86 } // namespace web_modal | |
| OLD | NEW |