Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / app_modal / app_modal_dialog.cc
blob2f7fa9bbe1e47ae2cf06f5a0bccfc2fa335f865b
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;
16 namespace app_modal {
17 namespace {
19 AppModalDialogObserver* app_modal_dialog_observer = NULL;
21 } // namespace
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)
35 : title_(title),
36 completed_(false),
37 valid_(true),
38 native_dialog_(NULL),
39 web_contents_(web_contents) {
42 AppModalDialog::~AppModalDialog() {
43 CompleteDialog();
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() {
59 return valid_;
62 void AppModalDialog::Invalidate() {
63 valid_ = false;
66 bool AppModalDialog::IsJavaScriptModalDialog() {
67 return false;
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() {
81 if (!completed_) {
82 completed_ = true;
83 AppModalDialogQueue::GetInstance()->ShowNextDialog();
87 } // namespace app_modal