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"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_contents_delegate.h"
14 using content::WebContents
;
19 AppModalDialogObserver
* app_modal_dialog_observer
= NULL
;
23 AppModalDialogObserver::AppModalDialogObserver() {
24 DCHECK(!app_modal_dialog_observer
);
25 app_modal_dialog_observer
= this;
28 AppModalDialogObserver::~AppModalDialogObserver() {
29 DCHECK(app_modal_dialog_observer
);
30 app_modal_dialog_observer
= NULL
;
33 AppModalDialog::AppModalDialog(WebContents
* web_contents
,
34 const base::string16
& title
)
39 web_contents_(web_contents
) {
42 AppModalDialog::~AppModalDialog() {
46 void AppModalDialog::ShowModalDialog() {
47 web_contents_
->GetDelegate()->ActivateContents(web_contents_
);
48 CreateAndShowDialog();
49 if (app_modal_dialog_observer
)
50 app_modal_dialog_observer
->Notify(this);
53 void AppModalDialog::CreateAndShowDialog() {
54 native_dialog_
= CreateNativeDialog();
55 native_dialog_
->ShowAppModalDialog();
58 bool AppModalDialog::IsValid() {
62 void AppModalDialog::Invalidate() {
66 bool AppModalDialog::IsJavaScriptModalDialog() {
70 void AppModalDialog::ActivateModalDialog() {
71 DCHECK(native_dialog_
);
72 native_dialog_
->ActivateAppModalDialog();
75 void AppModalDialog::CloseModalDialog() {
76 DCHECK(native_dialog_
);
77 native_dialog_
->CloseAppModalDialog();
80 void AppModalDialog::CompleteDialog() {
83 AppModalDialogQueue::GetInstance()->ShowNextDialog();
87 } // namespace app_modal