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

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

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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/memory/scoped_nsobject.h" 9 #include "base/memory/scoped_nsobject.h"
10 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" 10 #include "chrome/browser/ui/cocoa/constrained_window_mac.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/browser/ui/webui/web_dialog_delegate.h"
13 #include "chrome/browser/ui/webui/web_dialog_ui.h"
14 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h"
15 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
16 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
14 #include "ui/web_dialogs/web_dialog_delegate.h"
15 #include "ui/web_dialogs/web_dialog_ui.h"
16 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
17 17
18 using content::WebContents; 18 using content::WebContents;
19 19
20 class ConstrainedWebDialogDelegateMac : 20 class ConstrainedWebDialogDelegateMac :
21 public ConstrainedWindowMacDelegateCustomSheet, 21 public ConstrainedWindowMacDelegateCustomSheet,
22 public ConstrainedWebDialogDelegate { 22 public ConstrainedWebDialogDelegate {
23 23
24 public: 24 public:
25 ConstrainedWebDialogDelegateMac( 25 ConstrainedWebDialogDelegateMac(
26 Profile* profile, 26 Profile* profile,
27 WebDialogDelegate* delegate, 27 web_dialogs::WebDialogDelegate* delegate,
28 WebDialogWebContentsDelegate* tab_delegate); 28 web_dialogs::WebDialogWebContentsDelegate* tab_delegate);
29 virtual ~ConstrainedWebDialogDelegateMac() {} 29 virtual ~ConstrainedWebDialogDelegateMac() {}
30 30
31 void set_window(ConstrainedWindow* window) { 31 void set_window(ConstrainedWindow* window) {
32 return impl_->set_window(window); 32 return impl_->set_window(window);
33 } 33 }
34 34
35 // ConstrainedWebDialogDelegate interface 35 // ConstrainedWebDialogDelegate interface
36 virtual const WebDialogDelegate* 36 virtual const web_dialogs::WebDialogDelegate*
37 GetWebDialogDelegate() const OVERRIDE { 37 GetWebDialogDelegate() const OVERRIDE {
38 return impl_->GetWebDialogDelegate(); 38 return impl_->GetWebDialogDelegate();
39 } 39 }
40 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { 40 virtual web_dialogs::WebDialogDelegate* GetWebDialogDelegate() OVERRIDE {
41 return impl_->GetWebDialogDelegate(); 41 return impl_->GetWebDialogDelegate();
42 } 42 }
43 virtual void OnDialogCloseFromWebUI() OVERRIDE { 43 virtual void OnDialogCloseFromWebUI() OVERRIDE {
44 return impl_->OnDialogCloseFromWebUI(); 44 return impl_->OnDialogCloseFromWebUI();
45 } 45 }
46 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { 46 virtual void ReleaseTabContentsOnDialogClose() OVERRIDE {
47 return impl_->ReleaseTabContentsOnDialogClose(); 47 return impl_->ReleaseTabContentsOnDialogClose();
48 } 48 }
49 virtual ConstrainedWindow* window() OVERRIDE { 49 virtual ConstrainedWindow* window() OVERRIDE {
50 return impl_->window(); 50 return impl_->window();
(...skipping 27 matching lines...) Expand all
78 } 78 }
79 - (id)initWithConstrainedWebDialogDelegateMac: 79 - (id)initWithConstrainedWebDialogDelegateMac:
80 (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac; 80 (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac;
81 - (void)sheetDidEnd:(NSWindow*)sheet 81 - (void)sheetDidEnd:(NSWindow*)sheet
82 returnCode:(int)returnCode 82 returnCode:(int)returnCode
83 contextInfo:(void*)contextInfo; 83 contextInfo:(void*)contextInfo;
84 @end 84 @end
85 85
86 ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac( 86 ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac(
87 Profile* profile, 87 Profile* profile,
88 WebDialogDelegate* delegate, 88 web_dialogs::WebDialogDelegate* delegate,
89 WebDialogWebContentsDelegate* tab_delegate) 89 web_dialogs::WebDialogWebContentsDelegate* tab_delegate)
90 : impl_(new ConstrainedWebDialogDelegateBase(profile, 90 : impl_(new ConstrainedWebDialogDelegateBase(profile,
91 delegate, 91 delegate,
92 tab_delegate)) { 92 tab_delegate)) {
93 // Create NSWindow to hold web_contents in the constrained sheet: 93 // Create NSWindow to hold web_contents in the constrained sheet:
94 gfx::Size size; 94 gfx::Size size;
95 delegate->GetDialogSize(&size); 95 delegate->GetDialogSize(&size);
96 NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); 96 NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
97 97
98 // |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when 98 // |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when
99 // the sheet is initialized. 99 // the sheet is initialized.
(...skipping 11 matching lines...) Expand all
111 window.get(), 111 window.get(),
112 [[[ConstrainedWebDialogSheetCocoa alloc] 112 [[[ConstrainedWebDialogSheetCocoa alloc]
113 initWithConstrainedWebDialogDelegateMac:this] autorelease], 113 initWithConstrainedWebDialogDelegateMac:this] autorelease],
114 @selector(sheetDidEnd:returnCode:contextInfo:)); 114 @selector(sheetDidEnd:returnCode:contextInfo:));
115 } 115 }
116 116
117 // static 117 // static
118 ConstrainedWebDialogDelegate* 118 ConstrainedWebDialogDelegate*
119 ConstrainedWebDialogUI::CreateConstrainedWebDialog( 119 ConstrainedWebDialogUI::CreateConstrainedWebDialog(
120 Profile* profile, 120 Profile* profile,
121 WebDialogDelegate* delegate, 121 web_dialogs::WebDialogDelegate* delegate,
122 WebDialogWebContentsDelegate* tab_delegate, 122 web_dialogs::WebDialogWebContentsDelegate* tab_delegate,
123 TabContentsWrapper* wrapper) { 123 TabContentsWrapper* wrapper) {
124 // Deleted when ConstrainedWebDialogDelegateMac::DeleteDelegate() runs. 124 // Deleted when ConstrainedWebDialogDelegateMac::DeleteDelegate() runs.
125 ConstrainedWebDialogDelegateMac* constrained_delegate = 125 ConstrainedWebDialogDelegateMac* constrained_delegate =
126 new ConstrainedWebDialogDelegateMac(profile, delegate, tab_delegate); 126 new ConstrainedWebDialogDelegateMac(profile, delegate, tab_delegate);
127 // Deleted when ConstrainedWebDialogDelegateMac::OnDialogCloseFromWebUI() 127 // Deleted when ConstrainedWebDialogDelegateMac::OnDialogCloseFromWebUI()
128 // runs. 128 // runs.
129 ConstrainedWindow* constrained_window = 129 ConstrainedWindow* constrained_window =
130 new ConstrainedWindowMac(wrapper, constrained_delegate); 130 new ConstrainedWindowMac(wrapper, constrained_delegate);
131 constrained_delegate->set_window(constrained_window); 131 constrained_delegate->set_window(constrained_window);
132 return constrained_delegate; 132 return constrained_delegate;
133 } 133 }
134 134
135 @implementation ConstrainedWebDialogSheetCocoa 135 @implementation ConstrainedWebDialogSheetCocoa
136 136
137 - (id)initWithConstrainedWebDialogDelegateMac: 137 - (id)initWithConstrainedWebDialogDelegateMac:
138 (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac { 138 (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac {
139 if ((self = [super init])) 139 if ((self = [super init]))
140 constrainedWebDelegate_ = ConstrainedWebDialogDelegateMac; 140 constrainedWebDelegate_ = ConstrainedWebDialogDelegateMac;
141 return self; 141 return self;
142 } 142 }
143 143
144 - (void)sheetDidEnd:(NSWindow*)sheet 144 - (void)sheetDidEnd:(NSWindow*)sheet
145 returnCode:(int)returnCode 145 returnCode:(int)returnCode
146 contextInfo:(void *)contextInfo { 146 contextInfo:(void *)contextInfo {
147 [sheet orderOut:self]; 147 [sheet orderOut:self];
148 } 148 }
149 149
150 @end 150 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698