OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/html_dialog_window_controller.h" | 5 #import "chrome/browser/cocoa/html_dialog_window_controller.h" |
6 | 6 |
7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 virtual GURL GetDialogContentURL() const; | 37 virtual GURL GetDialogContentURL() const; |
38 virtual void GetDOMMessageHandlers( | 38 virtual void GetDOMMessageHandlers( |
39 std::vector<DOMMessageHandler*>* handlers) const; | 39 std::vector<DOMMessageHandler*>* handlers) const; |
40 virtual void GetDialogSize(gfx::Size* size) const; | 40 virtual void GetDialogSize(gfx::Size* size) const; |
41 virtual std::string GetDialogArgs() const; | 41 virtual std::string GetDialogArgs() const; |
42 virtual void OnDialogClosed(const std::string& json_retval); | 42 virtual void OnDialogClosed(const std::string& json_retval); |
43 | 43 |
44 // HtmlDialogTabContentsDelegate declarations. | 44 // HtmlDialogTabContentsDelegate declarations. |
45 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); | 45 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); |
46 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); | 46 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); |
| 47 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
47 | 48 |
48 private: | 49 private: |
49 HtmlDialogWindowController* controller_; // weak | 50 HtmlDialogWindowController* controller_; // weak |
50 HtmlDialogUIDelegate* delegate_; // weak, owned by controller_ | 51 HtmlDialogUIDelegate* delegate_; // weak, owned by controller_ |
51 | 52 |
52 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out | 53 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out |
53 // afterwards so that no other HtmlDialogUIDelegate calls are sent | 54 // afterwards so that no other HtmlDialogUIDelegate calls are sent |
54 // to it. Returns whether or not the OnDialogClosed() was actually | 55 // to it. Returns whether or not the OnDialogClosed() was actually |
55 // called on the delegate. | 56 // called on the delegate. |
56 bool DelegateOnDialogClosed(const std::string& json_retval); | 57 bool DelegateOnDialogClosed(const std::string& json_retval); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void HtmlDialogWindowDelegateBridge::MoveContents(TabContents* source, | 162 void HtmlDialogWindowDelegateBridge::MoveContents(TabContents* source, |
162 const gfx::Rect& pos) { | 163 const gfx::Rect& pos) { |
163 // TODO(akalin): Actually set the window bounds. | 164 // TODO(akalin): Actually set the window bounds. |
164 } | 165 } |
165 | 166 |
166 void HtmlDialogWindowDelegateBridge::ToolbarSizeChanged( | 167 void HtmlDialogWindowDelegateBridge::ToolbarSizeChanged( |
167 TabContents* source, bool is_animating) { | 168 TabContents* source, bool is_animating) { |
168 // TODO(akalin): Figure out what to do here. | 169 // TODO(akalin): Figure out what to do here. |
169 } | 170 } |
170 | 171 |
| 172 // A simplified version of BrowserWindowCocoa::HandleKeyboardEvent(). |
| 173 // We don't handle global keyboard shortcuts here, but that's fine since |
| 174 // they're all browser-specific. (This may change in the future.) |
| 175 void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( |
| 176 const NativeWebKeyboardEvent& event) { |
| 177 if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char) |
| 178 return; |
| 179 |
| 180 ChromeEventProcessingWindow* event_window = |
| 181 static_cast<ChromeEventProcessingWindow*>([controller_ window]); |
| 182 |
| 183 [event_window redispatchEvent:event.os_event]; |
| 184 } |
| 185 |
171 @implementation HtmlDialogWindowController (InternalAPI) | 186 @implementation HtmlDialogWindowController (InternalAPI) |
172 | 187 |
173 // This gets called whenever a chrome-specific keyboard shortcut is performed | 188 // This gets called whenever a chrome-specific keyboard shortcut is performed |
174 // in the HTML dialog window. We simply swallow all those events. | 189 // in the HTML dialog window. We simply swallow all those events. |
175 - (void)executeCommand:(int)command {} | 190 - (void)executeCommand:(int)command {} |
176 | 191 |
177 @end | 192 @end |
178 | 193 |
179 @implementation HtmlDialogWindowController | 194 @implementation HtmlDialogWindowController |
180 | 195 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // to do the above doesn't work. | 259 // to do the above doesn't work. |
245 } | 260 } |
246 | 261 |
247 - (void)windowWillClose:(NSNotification*)notification { | 262 - (void)windowWillClose:(NSNotification*)notification { |
248 delegate_->WindowControllerClosed(); | 263 delegate_->WindowControllerClosed(); |
249 [self autorelease]; | 264 [self autorelease]; |
250 } | 265 } |
251 | 266 |
252 @end | 267 @end |
253 | 268 |
OLD | NEW |