1 // Copyright 2013 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/apps/directory_access_confirmation_dialog.h"
7 #include "base/callback.h"
8 #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
9 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
10 #include "content/public/browser/web_contents.h"
11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h"
16 class DirectoryAccessConfirmationDialog
: public TabModalConfirmDialogDelegate
{
18 DirectoryAccessConfirmationDialog(bool writable
,
19 const base::string16
& app_name
,
20 content::WebContents
* web_contents
,
21 const base::Closure
& on_accept
,
22 const base::Closure
& on_cancel
);
24 virtual base::string16
GetTitle() OVERRIDE
;
25 virtual base::string16
GetMessage() OVERRIDE
;
26 virtual base::string16
GetAcceptButtonTitle() OVERRIDE
;
27 virtual base::string16
GetCancelButtonTitle() OVERRIDE
;
30 virtual void OnAccepted() OVERRIDE
;
31 virtual void OnCanceled() OVERRIDE
;
32 virtual void OnClosed() OVERRIDE
;
34 const base::Closure on_accept_
;
35 const base::Closure on_cancel_
;
37 const base::string16 app_name_
;
40 DirectoryAccessConfirmationDialog::DirectoryAccessConfirmationDialog(
42 const base::string16
& app_name
,
43 content::WebContents
* web_contents
,
44 const base::Closure
& on_accept
,
45 const base::Closure
& on_cancel
)
46 : TabModalConfirmDialogDelegate(web_contents
),
47 on_accept_(on_accept
),
48 on_cancel_(on_cancel
),
50 app_name_(app_name
) {}
52 base::string16
DirectoryAccessConfirmationDialog::GetTitle() {
53 return l10n_util::GetStringUTF16(
54 IDS_EXTENSIONS_DIRECTORY_CONFIRMATION_DIALOG_TITLE
);
57 base::string16
DirectoryAccessConfirmationDialog::GetMessage() {
59 return l10n_util::GetStringFUTF16(
60 IDS_EXTENSIONS_DIRECTORY_CONFIRMATION_DIALOG_MESSAGE_WRITABLE
,
63 return l10n_util::GetStringFUTF16(
64 IDS_EXTENSIONS_DIRECTORY_CONFIRMATION_DIALOG_MESSAGE_READ_ONLY
,
69 base::string16
DirectoryAccessConfirmationDialog::GetAcceptButtonTitle() {
70 return l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL
);
72 base::string16
DirectoryAccessConfirmationDialog::GetCancelButtonTitle() {
73 return l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL
);
76 void DirectoryAccessConfirmationDialog::OnAccepted() {
80 void DirectoryAccessConfirmationDialog::OnCanceled() {
84 void DirectoryAccessConfirmationDialog::OnClosed() {
90 void CreateDirectoryAccessConfirmationDialog(bool writable
,
91 const base::string16
& app_name
,
92 content::WebContents
* web_contents
,
93 const base::Closure
& on_accept
,
94 const base::Closure
& on_cancel
) {
95 TabModalConfirmDialog::Create(
96 new DirectoryAccessConfirmationDialog(
97 writable
, app_name
, web_contents
, on_accept
, on_cancel
),