external_protocol_dialog.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ 6#define CHROME_BROWSER_UI_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "base/time/time.h" 11#include "googleurl/src/gurl.h" 12#include "ui/views/window/dialog_delegate.h" 13 14namespace content { 15class WebContents; 16} 17 18namespace views { 19class MessageBoxView; 20} 21 22class ExternalProtocolDialog : public views::DialogDelegate { 23 public: 24 // RunExternalProtocolDialog calls this private constructor. 25 ExternalProtocolDialog(content::WebContents* web_contents, 26 const GURL& url, 27 const std::wstring& command); 28 29 // Returns the path of the application to be launched given the protocol 30 // of the requested url. Returns an empty string on failure. 31 static std::wstring GetApplicationForProtocol(const GURL& url); 32 33 virtual ~ExternalProtocolDialog(); 34 35 // views::DialogDelegate methods: 36 virtual int GetDefaultDialogButton() const OVERRIDE; 37 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 38 virtual string16 GetWindowTitle() const OVERRIDE; 39 virtual void DeleteDelegate() OVERRIDE; 40 virtual bool Cancel() OVERRIDE; 41 virtual bool Accept() OVERRIDE; 42 virtual views::View* GetContentsView() OVERRIDE; 43 virtual views::Widget* GetWidget() OVERRIDE; 44 virtual const views::Widget* GetWidget() const OVERRIDE; 45 46 private: 47 // The message box view whose commands we handle. 48 views::MessageBoxView* message_box_view_; 49 50 // The associated WebContents. 51 content::WebContents* web_contents_; 52 53 // URL of the external protocol request. 54 GURL url_; 55 56 // The time at which this dialog was created. 57 base::TimeTicks creation_time_; 58 59 DISALLOW_COPY_AND_ASSIGN(ExternalProtocolDialog); 60}; 61 62#endif // CHROME_BROWSER_UI_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ 63