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 "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
7 #include "base/logging.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
10 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_delegate.h"
15 using content::WebContents
;
17 AppModalDialog::AppModalDialog(WebContents
* web_contents
,
18 const base::string16
& title
)
23 web_contents_(web_contents
) {
26 AppModalDialog::~AppModalDialog() {
30 void AppModalDialog::ShowModalDialog() {
31 web_contents_
->GetDelegate()->ActivateContents(web_contents_
);
32 CreateAndShowDialog();
34 content::NotificationService::current()->Notify(
35 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN
,
36 content::Source
<AppModalDialog
>(this),
37 content::NotificationService::NoDetails());
40 void AppModalDialog::CreateAndShowDialog() {
41 native_dialog_
= CreateNativeDialog();
42 native_dialog_
->ShowAppModalDialog();
45 bool AppModalDialog::IsValid() {
49 void AppModalDialog::Invalidate() {
53 bool AppModalDialog::IsJavaScriptModalDialog() {
57 void AppModalDialog::ActivateModalDialog() {
58 DCHECK(native_dialog_
);
59 native_dialog_
->ActivateAppModalDialog();
62 void AppModalDialog::CloseModalDialog() {
63 DCHECK(native_dialog_
);
64 native_dialog_
->CloseAppModalDialog();
67 void AppModalDialog::CompleteDialog() {
70 AppModalDialogQueue::GetInstance()->ShowNextDialog();