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_COCOA_JAVASCRIPT_APP_MODAL_DIALOG_COCOA_H_ 6#define CHROME_BROWSER_UI_COCOA_JAVASCRIPT_APP_MODAL_DIALOG_COCOA_H_ 7 8#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 9 10#include "base/logging.h" 11#include "base/mac/scoped_nsobject.h" 12#include "base/memory/scoped_ptr.h" 13 14#if __OBJC__ 15@class NSAlert; 16@class JavaScriptAppModalDialogHelper; 17#else 18class NSAlert; 19class JavaScriptAppModalDialogHelper; 20#endif 21 22class JavaScriptAppModalDialogCocoa : public NativeAppModalDialog { 23 public: 24 explicit JavaScriptAppModalDialogCocoa(JavaScriptAppModalDialog* dialog); 25 virtual ~JavaScriptAppModalDialogCocoa(); 26 27 // Overridden from NativeAppModalDialog: 28 virtual int GetAppModalDialogButtons() const OVERRIDE; 29 virtual void ShowAppModalDialog() OVERRIDE; 30 virtual void ActivateAppModalDialog() OVERRIDE; 31 virtual void CloseAppModalDialog() OVERRIDE; 32 virtual void AcceptAppModalDialog() OVERRIDE; 33 virtual void CancelAppModalDialog() OVERRIDE; 34 35 JavaScriptAppModalDialog* dialog() const { return dialog_.get(); } 36 37 private: 38 // Returns the NSAlert associated with the modal dialog. 39 NSAlert* GetAlert() const; 40 41 scoped_ptr<JavaScriptAppModalDialog> dialog_; 42 43 // Created in the constructor and destroyed in the destructor. 44 base::scoped_nsobject<JavaScriptAppModalDialogHelper> helper_; 45 46 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialogCocoa); 47}; 48 49#endif // CHROME_BROWSER_UI_COCOA_JAVASCRIPT_APP_MODAL_DIALOG_COCOA_H_ 50