• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
6 
7 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
8 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "content/common/notification_service.h"
11 #include "content/common/notification_type.h"
12 
AppModalDialog(TabContents * tab_contents,const std::wstring & title)13 AppModalDialog::AppModalDialog(TabContents* tab_contents,
14                                const std::wstring& title)
15     : skip_this_dialog_(false),
16       tab_contents_(tab_contents),
17       native_dialog_(NULL),
18       title_(title) {
19 }
20 
~AppModalDialog()21 AppModalDialog::~AppModalDialog() {
22 }
23 
ShowModalDialog()24 void AppModalDialog::ShowModalDialog() {
25   if (tab_contents_)
26     tab_contents_->Activate();
27 
28   CreateAndShowDialog();
29 
30   NotificationService::current()->Notify(
31       NotificationType::APP_MODAL_DIALOG_SHOWN,
32       Source<AppModalDialog>(this),
33       NotificationService::NoDetails());
34 }
35 
CreateAndShowDialog()36 void AppModalDialog::CreateAndShowDialog() {
37   native_dialog_ = CreateNativeDialog();
38   native_dialog_->ShowAppModalDialog();
39 }
40 
IsValid()41 bool AppModalDialog::IsValid() {
42   return !skip_this_dialog_;
43 }
44 
ActivateModalDialog()45 void AppModalDialog::ActivateModalDialog() {
46   DCHECK(native_dialog_);
47   native_dialog_->ActivateAppModalDialog();
48 }
49 
CloseModalDialog()50 void AppModalDialog::CloseModalDialog() {
51   DCHECK(native_dialog_);
52   native_dialog_->CloseAppModalDialog();
53 }
54 
CompleteDialog()55 void AppModalDialog::CompleteDialog() {
56   AppModalDialogQueue::GetInstance()->ShowNextDialog();
57 }
58