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 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
9 #include "base/property_bag.h" | 9 #include "base/property_bag.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 virtual std::string GetDialogArgs() const OVERRIDE; | 54 virtual std::string GetDialogArgs() const OVERRIDE; |
55 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 55 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
56 virtual void OnCloseContents(WebContents* source, | 56 virtual void OnCloseContents(WebContents* source, |
57 bool* out_close_dialog) OVERRIDE; | 57 bool* out_close_dialog) OVERRIDE; |
58 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } | 58 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } |
59 | 59 |
60 // HtmlDialogTabContentsDelegate declarations. | 60 // HtmlDialogTabContentsDelegate declarations. |
61 virtual void MoveContents(WebContents* source, const gfx::Rect& pos); | 61 virtual void MoveContents(WebContents* source, const gfx::Rect& pos); |
62 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 62 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
63 virtual void CloseContents(WebContents* source) OVERRIDE; | 63 virtual void CloseContents(WebContents* source) OVERRIDE; |
64 virtual content::WebContents* OpenURLFromTab( | |
65 content::WebContents* source, | |
66 const content::OpenURLParams& params) OVERRIDE; | |
67 virtual void AddNewContents(content::WebContents* source, | |
68 content::WebContents* new_contents, | |
69 WindowOpenDisposition disposition, | |
70 const gfx::Rect& initial_pos, | |
71 bool user_gesture) OVERRIDE; | |
64 | 72 |
65 private: | 73 private: |
66 HtmlDialogWindowController* controller_; // weak | 74 HtmlDialogWindowController* controller_; // weak |
67 HtmlDialogUIDelegate* delegate_; // weak, owned by controller_ | 75 HtmlDialogUIDelegate* delegate_; // weak, owned by controller_ |
68 HtmlDialogController* dialog_controller_; | 76 HtmlDialogController* dialog_controller_; |
69 | 77 |
70 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out | 78 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out |
71 // afterwards so that no other HtmlDialogUIDelegate calls are sent | 79 // afterwards so that no other HtmlDialogUIDelegate calls are sent |
72 // to it. Returns whether or not the OnDialogClosed() was actually | 80 // to it. Returns whether or not the OnDialogClosed() was actually |
73 // called on the delegate. | 81 // called on the delegate. |
(...skipping 16 matching lines...) Expand all Loading... | |
90 gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, | 98 gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, |
91 Profile* profile, | 99 Profile* profile, |
92 Browser* browser, | 100 Browser* browser, |
93 HtmlDialogUIDelegate* delegate, | 101 HtmlDialogUIDelegate* delegate, |
94 DialogStyle style) { | 102 DialogStyle style) { |
95 return [HtmlDialogWindowController showHtmlDialog:delegate | 103 return [HtmlDialogWindowController showHtmlDialog:delegate |
96 profile:profile | 104 profile:profile |
97 browser:browser]; | 105 browser:browser]; |
98 } | 106 } |
99 | 107 |
108 void CloseHtmlDialog(gfx::NativeWindow window) { | |
109 [window performClose:nil]; | |
110 } | |
111 | |
100 } // namespace html_dialog_window_controller | 112 } // namespace html_dialog_window_controller |
101 | 113 |
102 HtmlDialogWindowDelegateBridge::HtmlDialogWindowDelegateBridge( | 114 HtmlDialogWindowDelegateBridge::HtmlDialogWindowDelegateBridge( |
103 HtmlDialogWindowController* controller, | 115 HtmlDialogWindowController* controller, |
104 Profile* profile, | 116 Profile* profile, |
105 Browser* browser, | 117 Browser* browser, |
106 HtmlDialogUIDelegate* delegate) | 118 HtmlDialogUIDelegate* delegate) |
107 : HtmlDialogTabContentsDelegate(profile), | 119 : HtmlDialogTabContentsDelegate(profile), |
108 controller_(controller), | 120 controller_(controller), |
109 delegate_(delegate), | 121 delegate_(delegate), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 *out_close_dialog = true; | 205 *out_close_dialog = true; |
194 } | 206 } |
195 | 207 |
196 void HtmlDialogWindowDelegateBridge::CloseContents(WebContents* source) { | 208 void HtmlDialogWindowDelegateBridge::CloseContents(WebContents* source) { |
197 bool close_dialog = false; | 209 bool close_dialog = false; |
198 OnCloseContents(source, &close_dialog); | 210 OnCloseContents(source, &close_dialog); |
199 if (close_dialog) | 211 if (close_dialog) |
200 OnDialogClosed(std::string()); | 212 OnDialogClosed(std::string()); |
201 } | 213 } |
202 | 214 |
215 content::WebContents* HtmlDialogWindowDelegateBridge::OpenURLFromTab( | |
216 content::WebContents* source, | |
217 const content::OpenURLParams& params) { | |
218 content::WebContents* new_contents = NULL; | |
219 if (delegate_ && | |
220 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { | |
221 return new_contents; | |
222 } | |
223 return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); | |
224 } | |
225 | |
226 void HtmlDialogWindowDelegateBridge::AddNewContents( | |
227 content::WebContents* source, | |
228 content::WebContents* new_contents, | |
229 WindowOpenDisposition disposition, | |
230 const gfx::Rect& initial_pos, | |
231 bool user_gesture) { | |
232 if (delegate_ && delegate_->HandleAddNewContents( | |
233 source, new_contents, disposition, initial_pos, user_gesture)) { | |
Dan Beam
2012/01/30 18:10:05
probably need to indent this + ^\s{4}
sail
2012/01/30 21:00:39
Done.
| |
234 return; | |
235 } | |
236 HtmlDialogTabContentsDelegate::AddNewContents( | |
237 source, new_contents, disposition, initial_pos, user_gesture); | |
238 } | |
239 | |
203 void HtmlDialogWindowDelegateBridge::MoveContents(WebContents* source, | 240 void HtmlDialogWindowDelegateBridge::MoveContents(WebContents* source, |
204 const gfx::Rect& pos) { | 241 const gfx::Rect& pos) { |
205 // TODO(akalin): Actually set the window bounds. | 242 // TODO(akalin): Actually set the window bounds. |
206 } | 243 } |
207 | 244 |
208 // A simplified version of BrowserWindowCocoa::HandleKeyboardEvent(). | 245 // A simplified version of BrowserWindowCocoa::HandleKeyboardEvent(). |
209 // We don't handle global keyboard shortcuts here, but that's fine since | 246 // We don't handle global keyboard shortcuts here, but that's fine since |
210 // they're all browser-specific. (This may change in the future.) | 247 // they're all browser-specific. (This may change in the future.) |
211 void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( | 248 void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( |
212 const NativeWebKeyboardEvent& event) { | 249 const NativeWebKeyboardEvent& event) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 357 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
321 // to do the above doesn't work. | 358 // to do the above doesn't work. |
322 } | 359 } |
323 | 360 |
324 - (void)windowWillClose:(NSNotification*)notification { | 361 - (void)windowWillClose:(NSNotification*)notification { |
325 delegate_->WindowControllerClosed(); | 362 delegate_->WindowControllerClosed(); |
326 [self autorelease]; | 363 [self autorelease]; |
327 } | 364 } |
328 | 365 |
329 @end | 366 @end |
OLD | NEW |