Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / app_modal / app_modal_dialog.cc
blob8689b7fc03a199bdde4a33b8cb146113ec0c88a1
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;
14 namespace app_modal {
15 namespace {
17 AppModalDialogObserver* app_modal_dialog_observer = NULL;
19 } // namespace
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)
33 : title_(title),
34 completed_(false),
35 valid_(true),
36 native_dialog_(NULL),
37 web_contents_(web_contents) {
40 AppModalDialog::~AppModalDialog() {
41 CompleteDialog();
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() {
52 return valid_;
55 void AppModalDialog::Invalidate() {
56 valid_ = false;
59 bool AppModalDialog::IsJavaScriptModalDialog() {
60 return false;
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() {
74 if (!completed_) {
75 completed_ = true;
76 AppModalDialogQueue::GetInstance()->ShowNextDialog();
80 } // namespace app_modal