| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H__ | 5 #ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ |
| 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H__ | 6 #define CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ |
| 7 | 7 |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "views/window/dialog_delegate.h" | 10 #include "views/window/dialog_delegate.h" |
| 11 | 11 |
| 12 class MessageBoxView; | 12 class MessageBoxView; |
| 13 class TabContents; | 13 class TabContents; |
| 14 | 14 |
| 15 class ExternalProtocolDialog : public views::DialogDelegate { | 15 class ExternalProtocolDialog : public views::DialogDelegate { |
| 16 public: | 16 public: |
| 17 // Creates and runs a External Protocol dialog box. | 17 // RunExternalProtocolDialog calls this private constructor. |
| 18 // |url| - The url of the request. | 18 ExternalProtocolDialog(TabContents* tab_contents, |
| 19 // |command| - the command that ShellExecute will run. | 19 const GURL& url, |
| 20 // |render_process_host_id| and |routing_id| are used by | 20 const std::wstring& command); |
| 21 // tab_util::GetTabContentsByID to aquire the tab contents associated with | |
| 22 // this dialog. | |
| 23 // NOTE: There is a race between the Time of Check and the Time Of Use for | |
| 24 // the command line. Since the caller (web page) does not have access | |
| 25 // to change the command line by itself, we do not do anything special | |
| 26 // to protect against this scenario. | |
| 27 static void RunExternalProtocolDialog(const GURL& url, | |
| 28 const std::wstring& command, | |
| 29 int render_process_host_id, | |
| 30 int routing_id); | |
| 31 | 21 |
| 32 // Returns the path of the application to be launched given the protocol | 22 // Returns the path of the application to be launched given the protocol |
| 33 // of the requested url. Returns an empty string on failure. | 23 // of the requested url. Returns an empty string on failure. |
| 34 static std::wstring GetApplicationForProtocol(const GURL& url); | 24 static std::wstring GetApplicationForProtocol(const GURL& url); |
| 35 | 25 |
| 36 virtual ~ExternalProtocolDialog(); | 26 virtual ~ExternalProtocolDialog(); |
| 37 | 27 |
| 38 // views::DialogDelegate Methods: | 28 // views::DialogDelegate Methods: |
| 39 virtual int GetDefaultDialogButton() const; | 29 virtual int GetDefaultDialogButton() const; |
| 40 virtual std::wstring GetDialogButtonLabel( | 30 virtual std::wstring GetDialogButtonLabel( |
| 41 MessageBoxFlags::DialogButton button) const; | 31 MessageBoxFlags::DialogButton button) const; |
| 42 virtual std::wstring GetWindowTitle() const; | 32 virtual std::wstring GetWindowTitle() const; |
| 43 virtual void DeleteDelegate(); | 33 virtual void DeleteDelegate(); |
| 44 virtual bool Accept(); | 34 virtual bool Accept(); |
| 45 virtual views::View* GetContentsView(); | 35 virtual views::View* GetContentsView(); |
| 46 | 36 |
| 47 // views::WindowDelegate Methods: | 37 // views::WindowDelegate Methods: |
| 48 virtual bool IsAlwaysOnTop() const { return false; } | 38 virtual bool IsAlwaysOnTop() const { return false; } |
| 49 virtual bool IsModal() const { return false; } | 39 virtual bool IsModal() const { return false; } |
| 50 | 40 |
| 51 private: | 41 private: |
| 52 // RunExternalProtocolDialog calls this private constructor. | |
| 53 ExternalProtocolDialog(TabContents* tab_contents, | |
| 54 const GURL& url, | |
| 55 const std::wstring& command); | |
| 56 | |
| 57 // The message box view whose commands we handle. | 42 // The message box view whose commands we handle. |
| 58 MessageBoxView* message_box_view_; | 43 MessageBoxView* message_box_view_; |
| 59 | 44 |
| 60 // The associated TabContents. | 45 // The associated TabContents. |
| 61 TabContents* tab_contents_; | 46 TabContents* tab_contents_; |
| 62 | 47 |
| 63 // URL of the external protocol request. | 48 // URL of the external protocol request. |
| 64 GURL url_; | 49 GURL url_; |
| 65 | 50 |
| 66 // The time at which this dialog was created. | 51 // The time at which this dialog was created. |
| 67 base::Time creation_time_; | 52 base::Time creation_time_; |
| 68 | 53 |
| 69 DISALLOW_EVIL_CONSTRUCTORS(ExternalProtocolDialog); | 54 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolDialog); |
| 70 }; | 55 }; |
| 71 | 56 |
| 72 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H__ | 57 #endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ |
| OLD | NEW |