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 <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
10 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" | 12 #import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h" |
11 #include "components/guest_view/browser/guest_view_base.h" | 13 #include "components/guest_view/browser/guest_view_base.h" |
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 14 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 | 16 |
15 using web_modal::WebContentsModalDialogManager; | 17 using web_modal::WebContentsModalDialogManager; |
16 | 18 |
17 ConstrainedWindowMac::ConstrainedWindowMac( | 19 ConstrainedWindowMac::ConstrainedWindowMac( |
18 ConstrainedWindowMacDelegate* delegate, | 20 ConstrainedWindowMacDelegate* delegate, |
19 content::WebContents* web_contents, | 21 content::WebContents* web_contents, |
20 id<ConstrainedWindowSheet> sheet) | 22 id<ConstrainedWindowSheet> sheet) |
21 : delegate_(delegate) { | 23 : delegate_(delegate) { |
22 DCHECK(sheet); | 24 DCHECK(sheet); |
23 | 25 |
24 // |web_contents| may be embedded within a chain of nested GuestViews. If it | 26 // |web_contents| may be embedded within a chain of nested GuestViews. If it |
25 // is, follow the chain of embedders to the outermost WebContents and use it. | 27 // is, follow the chain of embedders to the outermost WebContents and use it. |
26 web_contents = | 28 web_contents = |
27 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); | 29 guest_view::GuestViewBase::GetTopLevelWebContents(web_contents); |
28 | 30 |
29 auto manager = WebContentsModalDialogManager::FromWebContents(web_contents); | 31 auto manager = WebContentsModalDialogManager::FromWebContents(web_contents); |
30 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager( | 32 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager( |
31 new SingleWebContentsDialogManagerCocoa(this, sheet, manager)); | 33 new SingleWebContentsDialogManagerCocoa(this, sheet, manager)); |
32 manager->ShowDialogWithManager([sheet sheetWindow], native_manager.Pass()); | 34 manager->ShowDialogWithManager([sheet sheetWindow], |
| 35 std::move(native_manager)); |
33 } | 36 } |
34 | 37 |
35 ConstrainedWindowMac::~ConstrainedWindowMac() { | 38 ConstrainedWindowMac::~ConstrainedWindowMac() { |
36 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 39 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
37 DCHECK(!manager_); | 40 DCHECK(!manager_); |
38 } | 41 } |
39 | 42 |
40 void ConstrainedWindowMac::CloseWebContentsModalDialog() { | 43 void ConstrainedWindowMac::CloseWebContentsModalDialog() { |
41 if (manager_) | 44 if (manager_) |
42 manager_->Close(); | 45 manager_->Close(); |
43 } | 46 } |
44 | 47 |
45 void ConstrainedWindowMac::OnDialogClosing() { | 48 void ConstrainedWindowMac::OnDialogClosing() { |
46 if (delegate_) | 49 if (delegate_) |
47 delegate_->OnConstrainedWindowClosed(this); | 50 delegate_->OnConstrainedWindowClosed(this); |
48 } | 51 } |
OLD | NEW |