| 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/web_dialog_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "chrome/browser/ui/browser_dialogs.h" | 10 #import "chrome/browser/ui/browser_dialogs.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 content::BrowserContext* context, | 37 content::BrowserContext* context, |
| 38 WebDialogDelegate* delegate); | 38 WebDialogDelegate* delegate); |
| 39 | 39 |
| 40 virtual ~WebDialogWindowDelegateBridge(); | 40 virtual ~WebDialogWindowDelegateBridge(); |
| 41 | 41 |
| 42 // Called when the window is directly closed, e.g. from the close | 42 // Called when the window is directly closed, e.g. from the close |
| 43 // button or from an accelerator. | 43 // button or from an accelerator. |
| 44 void WindowControllerClosed(); | 44 void WindowControllerClosed(); |
| 45 | 45 |
| 46 // WebDialogDelegate declarations. | 46 // WebDialogDelegate declarations. |
| 47 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 47 virtual ui::ModalType GetDialogModalType() const override; |
| 48 virtual base::string16 GetDialogTitle() const OVERRIDE; | 48 virtual base::string16 GetDialogTitle() const override; |
| 49 virtual GURL GetDialogContentURL() const OVERRIDE; | 49 virtual GURL GetDialogContentURL() const override; |
| 50 virtual void GetWebUIMessageHandlers( | 50 virtual void GetWebUIMessageHandlers( |
| 51 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 51 std::vector<WebUIMessageHandler*>* handlers) const override; |
| 52 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 52 virtual void GetDialogSize(gfx::Size* size) const override; |
| 53 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE; | 53 virtual void GetMinimumDialogSize(gfx::Size* size) const override; |
| 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 // WebDialogWebContentsDelegate declarations. | 60 // WebDialogWebContentsDelegate declarations. |
| 61 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) OVERRIDE; | 61 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) override; |
| 62 virtual void HandleKeyboardEvent( | 62 virtual void HandleKeyboardEvent( |
| 63 content::WebContents* source, | 63 content::WebContents* source, |
| 64 const NativeWebKeyboardEvent& event) OVERRIDE; | 64 const NativeWebKeyboardEvent& event) override; |
| 65 virtual void CloseContents(WebContents* source) OVERRIDE; | 65 virtual void CloseContents(WebContents* source) override; |
| 66 virtual content::WebContents* OpenURLFromTab( | 66 virtual content::WebContents* OpenURLFromTab( |
| 67 content::WebContents* source, | 67 content::WebContents* source, |
| 68 const content::OpenURLParams& params) OVERRIDE; | 68 const content::OpenURLParams& params) override; |
| 69 virtual void AddNewContents(content::WebContents* source, | 69 virtual void AddNewContents(content::WebContents* source, |
| 70 content::WebContents* new_contents, | 70 content::WebContents* new_contents, |
| 71 WindowOpenDisposition disposition, | 71 WindowOpenDisposition disposition, |
| 72 const gfx::Rect& initial_pos, | 72 const gfx::Rect& initial_pos, |
| 73 bool user_gesture, | 73 bool user_gesture, |
| 74 bool* was_blocked) OVERRIDE; | 74 bool* was_blocked) override; |
| 75 virtual void LoadingStateChanged(content::WebContents* source, | 75 virtual void LoadingStateChanged(content::WebContents* source, |
| 76 bool to_different_document) OVERRIDE; | 76 bool to_different_document) override; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 WebDialogWindowController* controller_; // weak | 79 WebDialogWindowController* controller_; // weak |
| 80 WebDialogDelegate* delegate_; // weak, owned by controller_ | 80 WebDialogDelegate* delegate_; // weak, owned by controller_ |
| 81 | 81 |
| 82 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out afterwards | 82 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out afterwards |
| 83 // so that no other WebDialogDelegate calls are sent to it. Returns whether or | 83 // so that no other WebDialogDelegate calls are sent to it. Returns whether or |
| 84 // not the OnDialogClosed() was actually called on the delegate. | 84 // not the OnDialogClosed() was actually called on the delegate. |
| 85 bool DelegateOnDialogClosed(const std::string& json_retval); | 85 bool DelegateOnDialogClosed(const std::string& json_retval); |
| 86 | 86 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 361 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
| 362 // to do the above doesn't work. | 362 // to do the above doesn't work. |
| 363 } | 363 } |
| 364 | 364 |
| 365 - (void)windowWillClose:(NSNotification*)notification { | 365 - (void)windowWillClose:(NSNotification*)notification { |
| 366 delegate_->WindowControllerClosed(); | 366 delegate_->WindowControllerClosed(); |
| 367 [self autorelease]; | 367 [self autorelease]; |
| 368 } | 368 } |
| 369 | 369 |
| 370 @end | 370 @end |
| OLD | NEW |