| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
| 10 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" | 10 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // is, follow the chain of embedders to the outermost WebContents and use it. | 25 // is, follow the chain of embedders to the outermost WebContents and use it. |
| 26 web_contents = | 26 web_contents = |
| 27 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); | 27 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); |
| 28 | 28 |
| 29 auto manager = WebContentsModalDialogManager::FromWebContents(web_contents); | 29 auto manager = WebContentsModalDialogManager::FromWebContents(web_contents); |
| 30 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager( | 30 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager( |
| 31 new SingleWebContentsDialogManagerCocoa(this, sheet, manager)); | 31 new SingleWebContentsDialogManagerCocoa(this, sheet, manager)); |
| 32 manager->ShowDialogWithManager([sheet sheetWindow], native_manager.Pass()); | 32 manager->ShowDialogWithManager([sheet sheetWindow], native_manager.Pass()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool ConstrainedWindowMac::HasTopLevelDialogManager( |
| 36 content::WebContents* web_contents) { |
| 37 // |web_contents| may be embedded within a chain of nested GuestViews. If it |
| 38 // is, follow the chain of embedders to the outermost WebContents and use it. |
| 39 web_contents = |
| 40 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); |
| 41 |
| 42 return WebContentsModalDialogManager::FromWebContents(web_contents) != NULL; |
| 43 } |
| 44 |
| 35 ConstrainedWindowMac::~ConstrainedWindowMac() { | 45 ConstrainedWindowMac::~ConstrainedWindowMac() { |
| 36 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 46 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 37 DCHECK(!manager_); | 47 DCHECK(!manager_); |
| 38 } | 48 } |
| 39 | 49 |
| 40 void ConstrainedWindowMac::CloseWebContentsModalDialog() { | 50 void ConstrainedWindowMac::CloseWebContentsModalDialog() { |
| 41 if (manager_) | 51 if (manager_) |
| 42 manager_->Close(); | 52 manager_->Close(); |
| 43 } | 53 } |
| 44 | 54 |
| 45 void ConstrainedWindowMac::OnDialogClosing() { | 55 void ConstrainedWindowMac::OnDialogClosing() { |
| 46 if (delegate_) | 56 if (delegate_) |
| 47 delegate_->OnConstrainedWindowClosed(this); | 57 delegate_->OnConstrainedWindowClosed(this); |
| 48 } | 58 } |
| OLD | NEW |