Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm

Issue 538203002: Fix a crash on WebViewFocusHelper destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build; cleanup. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/webui/constrained_web_dialog_delegate_base.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
(...skipping 10 matching lines...) Expand all
21 using ui::WebDialogWebContentsDelegate; 21 using ui::WebDialogWebContentsDelegate;
22 using web_modal::NativeWebContentsModalDialog; 22 using web_modal::NativeWebContentsModalDialog;
23 23
24 namespace { 24 namespace {
25 25
26 class ConstrainedWebDialogDelegateMac 26 class ConstrainedWebDialogDelegateMac
27 : public ConstrainedWebDialogDelegateBase { 27 : public ConstrainedWebDialogDelegateBase {
28 public: 28 public:
29 ConstrainedWebDialogDelegateMac( 29 ConstrainedWebDialogDelegateMac(
30 content::BrowserContext* browser_context, 30 content::BrowserContext* browser_context,
31 WebDialogDelegate* delegate, 31 WebDialogDelegate* delegate)
32 WebDialogWebContentsDelegate* tab_delegate) 32 : ConstrainedWebDialogDelegateBase(browser_context, delegate, NULL) {}
33 : ConstrainedWebDialogDelegateBase(
34 browser_context, delegate, tab_delegate) {}
35 33
36 // WebDialogWebContentsDelegate interface. 34 // WebDialogWebContentsDelegate interface.
37 virtual void CloseContents(WebContents* source) OVERRIDE { 35 virtual void CloseContents(WebContents* source) OVERRIDE {
38 window_->CloseWebContentsModalDialog(); 36 window_->CloseWebContentsModalDialog();
39 } 37 }
40 38
41 void set_window(ConstrainedWindowMac* window) { window_ = window; } 39 void set_window(ConstrainedWindowMac* window) { window_ = window; }
42 ConstrainedWindowMac* window() const { return window_; } 40 ConstrainedWindowMac* window() const { return window_; }
43 41
44 private: 42 private:
45 // Weak, owned by ConstrainedWebDialogDelegateViewMac. 43 // Weak, owned by ConstrainedWebDialogDelegateViewMac.
46 ConstrainedWindowMac* window_; 44 ConstrainedWindowMac* window_;
47 45
48 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateMac); 46 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateMac);
49 }; 47 };
50 48
51 } // namespace 49 } // namespace
52 50
53 class ConstrainedWebDialogDelegateViewMac : 51 class ConstrainedWebDialogDelegateViewMac :
54 public ConstrainedWindowMacDelegate, 52 public ConstrainedWindowMacDelegate,
55 public ConstrainedWebDialogDelegate { 53 public ConstrainedWebDialogDelegate {
56 54
57 public: 55 public:
58 ConstrainedWebDialogDelegateViewMac( 56 ConstrainedWebDialogDelegateViewMac(
59 content::BrowserContext* browser_context, 57 content::BrowserContext* browser_context,
60 WebDialogDelegate* delegate, 58 WebDialogDelegate* delegate,
61 WebDialogWebContentsDelegate* tab_delegate,
62 content::WebContents* web_contents); 59 content::WebContents* web_contents);
63 virtual ~ConstrainedWebDialogDelegateViewMac() {} 60 virtual ~ConstrainedWebDialogDelegateViewMac() {}
64 61
65 // ConstrainedWebDialogDelegate interface 62 // ConstrainedWebDialogDelegate interface
66 virtual const WebDialogDelegate* 63 virtual const WebDialogDelegate*
67 GetWebDialogDelegate() const OVERRIDE { 64 GetWebDialogDelegate() const OVERRIDE {
68 return impl_->GetWebDialogDelegate(); 65 return impl_->GetWebDialogDelegate();
69 } 66 }
70 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { 67 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE {
71 return impl_->GetWebDialogDelegate(); 68 return impl_->GetWebDialogDelegate();
(...skipping 23 matching lines...) Expand all
95 scoped_ptr<ConstrainedWebDialogDelegateMac> impl_; 92 scoped_ptr<ConstrainedWebDialogDelegateMac> impl_;
96 scoped_ptr<ConstrainedWindowMac> constrained_window_; 93 scoped_ptr<ConstrainedWindowMac> constrained_window_;
97 base::scoped_nsobject<NSWindow> window_; 94 base::scoped_nsobject<NSWindow> window_;
98 95
99 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewMac); 96 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewMac);
100 }; 97 };
101 98
102 ConstrainedWebDialogDelegateViewMac::ConstrainedWebDialogDelegateViewMac( 99 ConstrainedWebDialogDelegateViewMac::ConstrainedWebDialogDelegateViewMac(
103 content::BrowserContext* browser_context, 100 content::BrowserContext* browser_context,
104 WebDialogDelegate* delegate, 101 WebDialogDelegate* delegate,
105 WebDialogWebContentsDelegate* tab_delegate,
106 content::WebContents* web_contents) 102 content::WebContents* web_contents)
107 : impl_(new ConstrainedWebDialogDelegateMac(browser_context, 103 : impl_(new ConstrainedWebDialogDelegateMac(browser_context, delegate)) {
108 delegate,
109 tab_delegate)) {
110 // Create a window to hold web_contents in the constrained sheet: 104 // Create a window to hold web_contents in the constrained sheet:
111 gfx::Size size; 105 gfx::Size size;
112 delegate->GetDialogSize(&size); 106 delegate->GetDialogSize(&size);
113 NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); 107 NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
114 108
115 window_.reset( 109 window_.reset(
116 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]); 110 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]);
117 [GetWebContents()->GetNativeView() setFrame:frame]; 111 [GetWebContents()->GetNativeView() setFrame:frame];
118 [[window_ contentView] addSubview:GetWebContents()->GetNativeView()]; 112 [[window_ contentView] addSubview:GetWebContents()->GetNativeView()];
119 113
120 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 114 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
121 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window_]); 115 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window_]);
122 constrained_window_.reset(new ConstrainedWindowMac( 116 constrained_window_.reset(new ConstrainedWindowMac(
123 this, web_contents, sheet)); 117 this, web_contents, sheet));
124 118
125 impl_->set_window(constrained_window_.get()); 119 impl_->set_window(constrained_window_.get());
126 } 120 }
127 121
128 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( 122 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
129 content::BrowserContext* browser_context, 123 content::BrowserContext* browser_context,
130 WebDialogDelegate* delegate, 124 WebDialogDelegate* delegate,
131 WebDialogWebContentsDelegate* tab_delegate,
132 content::WebContents* web_contents) { 125 content::WebContents* web_contents) {
133 // Deleted when the dialog closes. 126 // Deleted when the dialog closes.
134 ConstrainedWebDialogDelegateViewMac* constrained_delegate = 127 ConstrainedWebDialogDelegateViewMac* constrained_delegate =
135 new ConstrainedWebDialogDelegateViewMac( 128 new ConstrainedWebDialogDelegateViewMac(
136 browser_context, delegate, tab_delegate, web_contents); 129 browser_context, delegate, web_contents);
137 return constrained_delegate; 130 return constrained_delegate;
138 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698