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 native_dialog_
= CreateNativeDialog();
48 web_contents_
->GetDelegate()->ActivateContents(web_contents_
);
49 native_dialog_
->ShowAppModalDialog();
50 if (app_modal_dialog_observer
)
51 app_modal_dialog_observer
->Notify(this);
54 bool AppModalDialog::IsValid() {
58 void AppModalDialog::Invalidate() {
62 bool AppModalDialog::IsJavaScriptModalDialog() {
66 void AppModalDialog::ActivateModalDialog() {
67 DCHECK(native_dialog_
);
68 native_dialog_
->ActivateAppModalDialog();
71 void AppModalDialog::CloseModalDialog() {
72 DCHECK(native_dialog_
);
73 native_dialog_
->CloseAppModalDialog();
76 void AppModalDialog::CompleteDialog() {
79 AppModalDialogQueue::GetInstance()->ShowNextDialog();
83 } // namespace app_modal