Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / app_modal_dialogs / app_modal_dialog.cc
blobedd94572dd7e4cb87150d0d69fcf67383d021962
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)
19 : title_(title),
20 completed_(false),
21 valid_(true),
22 native_dialog_(NULL),
23 web_contents_(web_contents) {
26 AppModalDialog::~AppModalDialog() {
27 CompleteDialog();
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() {
46 return valid_;
49 void AppModalDialog::Invalidate() {
50 valid_ = false;
53 bool AppModalDialog::IsJavaScriptModalDialog() {
54 return false;
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() {
68 if (!completed_) {
69 completed_ = true;
70 AppModalDialogQueue::GetInstance()->ShowNextDialog();