| 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 19 matching lines...) Expand all Loading... |
| 30 // WebDialogWindowController's member variables. | 30 // WebDialogWindowController's member variables. |
| 31 class WebDialogWindowDelegateBridge | 31 class WebDialogWindowDelegateBridge |
| 32 : public WebDialogDelegate, | 32 : public WebDialogDelegate, |
| 33 public WebDialogWebContentsDelegate { | 33 public WebDialogWebContentsDelegate { |
| 34 public: | 34 public: |
| 35 // All parameters must be non-NULL/non-nil. | 35 // All parameters must be non-NULL/non-nil. |
| 36 WebDialogWindowDelegateBridge(WebDialogWindowController* controller, | 36 WebDialogWindowDelegateBridge(WebDialogWindowController* controller, |
| 37 content::BrowserContext* context, | 37 content::BrowserContext* context, |
| 38 WebDialogDelegate* delegate); | 38 WebDialogDelegate* delegate); |
| 39 | 39 |
| 40 virtual ~WebDialogWindowDelegateBridge(); | 40 ~WebDialogWindowDelegateBridge() override; |
| 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 ui::ModalType GetDialogModalType() const override; |
| 48 virtual base::string16 GetDialogTitle() const override; | 48 base::string16 GetDialogTitle() const override; |
| 49 virtual GURL GetDialogContentURL() const override; | 49 GURL GetDialogContentURL() const override; |
| 50 virtual void GetWebUIMessageHandlers( | 50 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 void GetDialogSize(gfx::Size* size) const override; |
| 53 virtual void GetMinimumDialogSize(gfx::Size* size) const override; | 53 void GetMinimumDialogSize(gfx::Size* size) const override; |
| 54 virtual std::string GetDialogArgs() const override; | 54 std::string GetDialogArgs() const override; |
| 55 virtual void OnDialogClosed(const std::string& json_retval) override; | 55 void OnDialogClosed(const std::string& json_retval) override; |
| 56 virtual void OnCloseContents(WebContents* source, | 56 void OnCloseContents(WebContents* source, bool* out_close_dialog) override; |
| 57 bool* out_close_dialog) override; | 57 bool ShouldShowDialogTitle() const override { return true; } |
| 58 virtual bool ShouldShowDialogTitle() const override { return true; } | |
| 59 | 58 |
| 60 // WebDialogWebContentsDelegate declarations. | 59 // WebDialogWebContentsDelegate declarations. |
| 61 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) override; | 60 void MoveContents(WebContents* source, const gfx::Rect& pos) override; |
| 62 virtual void HandleKeyboardEvent( | 61 void HandleKeyboardEvent(content::WebContents* source, |
| 63 content::WebContents* source, | 62 const NativeWebKeyboardEvent& event) override; |
| 64 const NativeWebKeyboardEvent& event) override; | 63 void CloseContents(WebContents* source) override; |
| 65 virtual void CloseContents(WebContents* source) override; | 64 content::WebContents* OpenURLFromTab( |
| 66 virtual content::WebContents* OpenURLFromTab( | |
| 67 content::WebContents* source, | 65 content::WebContents* source, |
| 68 const content::OpenURLParams& params) override; | 66 const content::OpenURLParams& params) override; |
| 69 virtual void AddNewContents(content::WebContents* source, | 67 void AddNewContents(content::WebContents* source, |
| 70 content::WebContents* new_contents, | 68 content::WebContents* new_contents, |
| 71 WindowOpenDisposition disposition, | 69 WindowOpenDisposition disposition, |
| 72 const gfx::Rect& initial_pos, | 70 const gfx::Rect& initial_pos, |
| 73 bool user_gesture, | 71 bool user_gesture, |
| 74 bool* was_blocked) override; | 72 bool* was_blocked) override; |
| 75 virtual void LoadingStateChanged(content::WebContents* source, | 73 void LoadingStateChanged(content::WebContents* source, |
| 76 bool to_different_document) override; | 74 bool to_different_document) override; |
| 77 | 75 |
| 78 private: | 76 private: |
| 79 WebDialogWindowController* controller_; // weak | 77 WebDialogWindowController* controller_; // weak |
| 80 WebDialogDelegate* delegate_; // weak, owned by controller_ | 78 WebDialogDelegate* delegate_; // weak, owned by controller_ |
| 81 | 79 |
| 82 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out afterwards | 80 // Calls delegate_'s OnDialogClosed() exactly once, nulling it out afterwards |
| 83 // so that no other WebDialogDelegate calls are sent to it. Returns whether or | 81 // so that no other WebDialogDelegate calls are sent to it. Returns whether or |
| 84 // not the OnDialogClosed() was actually called on the delegate. | 82 // not the OnDialogClosed() was actually called on the delegate. |
| 85 bool DelegateOnDialogClosed(const std::string& json_retval); | 83 bool DelegateOnDialogClosed(const std::string& json_retval); |
| 86 | 84 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 359 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
| 362 // to do the above doesn't work. | 360 // to do the above doesn't work. |
| 363 } | 361 } |
| 364 | 362 |
| 365 - (void)windowWillClose:(NSNotification*)notification { | 363 - (void)windowWillClose:(NSNotification*)notification { |
| 366 delegate_->WindowControllerClosed(); | 364 delegate_->WindowControllerClosed(); |
| 367 [self autorelease]; | 365 [self autorelease]; |
| 368 } | 366 } |
| 369 | 367 |
| 370 @end | 368 @end |
| OLD | NEW |