blob: 8689b7fc03a199bdde4a33b8cb146113ec0c88a1 [file] [log] [blame]
[email protected]7f070d42011-03-09 20:25:321// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]0bfa713f2009-04-07 20:18:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
oshimaf65398422014-11-18 23:30:425#include "components/app_modal/app_modal_dialog.h"
[email protected]0bfa713f2009-04-07 20:18:286
[email protected]83a2610a2012-01-05 01:00:277#include "base/logging.h"
oshima82f72482014-10-24 14:14:328#include "base/run_loop.h"
oshimaf65398422014-11-18 23:30:429#include "components/app_modal/app_modal_dialog_queue.h"
10#include "components/app_modal/native_app_modal_dialog.h"
[email protected]0bfa713f2009-04-07 20:18:2811
[email protected]51da7e32012-01-30 19:24:5212using content::WebContents;
13
oshima0929be2a2014-11-19 22:21:0314namespace app_modal {
oshima82f72482014-10-24 14:14:3215namespace {
16
17AppModalDialogObserver* app_modal_dialog_observer = NULL;
18
19} // namespace
20
21AppModalDialogObserver::AppModalDialogObserver() {
22 DCHECK(!app_modal_dialog_observer);
23 app_modal_dialog_observer = this;
24}
25
26AppModalDialogObserver::~AppModalDialogObserver() {
27 DCHECK(app_modal_dialog_observer);
28 app_modal_dialog_observer = NULL;
29}
30
[email protected]dcd0249872013-12-06 23:58:4531AppModalDialog::AppModalDialog(WebContents* web_contents,
32 const base::string16& title)
[email protected]1f422a7c2013-05-15 17:06:4133 : title_(title),
34 completed_(false),
35 valid_(true),
[email protected]160ad3d2010-09-28 15:40:2036 native_dialog_(NULL),
[email protected]1f422a7c2013-05-15 17:06:4137 web_contents_(web_contents) {
[email protected]160ad3d2010-09-28 15:40:2038}
39
40AppModalDialog::~AppModalDialog() {
[email protected]94036902012-08-22 03:15:5641 CompleteDialog();
[email protected]0bfa713f2009-04-07 20:18:2842}
43
[email protected]0bfa713f2009-04-07 20:18:2844void AppModalDialog::ShowModalDialog() {
jochen55ff3502014-12-18 20:52:5745 native_dialog_ = CreateNativeDialog();
jochen55ff3502014-12-18 20:52:5746 native_dialog_->ShowAppModalDialog();
oshima82f72482014-10-24 14:14:3247 if (app_modal_dialog_observer)
48 app_modal_dialog_observer->Notify(this);
[email protected]0bfa713f2009-04-07 20:18:2849}
50
[email protected]ddb1e5a2010-12-13 20:10:4551bool AppModalDialog::IsValid() {
[email protected]a1e97f02011-06-30 14:04:3452 return valid_;
53}
54
55void AppModalDialog::Invalidate() {
56 valid_ = false;
[email protected]ddb1e5a2010-12-13 20:10:4557}
58
[email protected]16623742011-05-16 20:04:2659bool AppModalDialog::IsJavaScriptModalDialog() {
60 return false;
61}
62
[email protected]160ad3d2010-09-28 15:40:2063void AppModalDialog::ActivateModalDialog() {
64 DCHECK(native_dialog_);
65 native_dialog_->ActivateAppModalDialog();
66}
67
68void AppModalDialog::CloseModalDialog() {
69 DCHECK(native_dialog_);
70 native_dialog_->CloseAppModalDialog();
[email protected]571e31152009-05-15 19:34:0271}
[email protected]12f74a92010-02-05 22:32:1472
73void AppModalDialog::CompleteDialog() {
[email protected]94036902012-08-22 03:15:5674 if (!completed_) {
75 completed_ = true;
76 AppModalDialogQueue::GetInstance()->ShowNextDialog();
77 }
[email protected]12f74a92010-02-05 22:32:1478}
oshima0929be2a2014-11-19 22:21:0379
80} // namespace app_modal