1 // Copyright (c) 2011 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.
5 #include "components/app_modal/app_modal_dialog.h"
7 #include "base/logging.h"
8 #include "base/run_loop.h"
9 #include "components/app_modal/app_modal_dialog_queue.h"
10 #include "components/app_modal/native_app_modal_dialog.h"
12 using content::WebContents
;
17 AppModalDialogObserver
* app_modal_dialog_observer
= NULL
;
21 AppModalDialogObserver::AppModalDialogObserver() {
22 DCHECK(!app_modal_dialog_observer
);
23 app_modal_dialog_observer
= this;
26 AppModalDialogObserver::~AppModalDialogObserver() {
27 DCHECK(app_modal_dialog_observer
);
28 app_modal_dialog_observer
= NULL
;
31 AppModalDialog::AppModalDialog(WebContents
* web_contents
,
32 const base::string16
& title
)
37 web_contents_(web_contents
) {
40 AppModalDialog::~AppModalDialog() {
44 void AppModalDialog::ShowModalDialog() {
45 native_dialog_
= CreateNativeDialog();
46 native_dialog_
->ShowAppModalDialog();
47 if (app_modal_dialog_observer
)
48 app_modal_dialog_observer
->Notify(this);
51 bool AppModalDialog::IsValid() {
55 void AppModalDialog::Invalidate() {
59 bool AppModalDialog::IsJavaScriptModalDialog() {
63 void AppModalDialog::ActivateModalDialog() {
64 DCHECK(native_dialog_
);
65 native_dialog_
->ActivateAppModalDialog();
68 void AppModalDialog::CloseModalDialog() {
69 DCHECK(native_dialog_
);
70 native_dialog_
->CloseAppModalDialog();
73 void AppModalDialog::CompleteDialog() {
76 AppModalDialogQueue::GetInstance()->ShowNextDialog();
80 } // namespace app_modal