Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / apps / directory_access_confirmation_dialog.cc
blobd5299d6efbb5741bab5fc5a19ab9c9444ed969b5
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 "chrome/grit/generated_resources.h"
11 #include "content/public/browser/web_contents.h"
12 #include "ui/base/l10n/l10n_util.h"
14 namespace {
16 class DirectoryAccessConfirmationDialog : public TabModalConfirmDialogDelegate {
17 public:
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 base::string16 GetTitle() override;
25 base::string16 GetDialogMessage() override;
26 base::string16 GetAcceptButtonTitle() override;
27 base::string16 GetCancelButtonTitle() override;
29 private:
30 void OnAccepted() override;
31 void OnCanceled() override;
32 void OnClosed() override;
34 const base::Closure on_accept_;
35 const base::Closure on_cancel_;
36 const bool writable_;
37 const base::string16 app_name_;
40 DirectoryAccessConfirmationDialog::DirectoryAccessConfirmationDialog(
41 bool writable,
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),
49 writable_(writable),
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::GetDialogMessage() {
58 if (writable_) {
59 return l10n_util::GetStringFUTF16(
60 IDS_EXTENSIONS_DIRECTORY_CONFIRMATION_DIALOG_MESSAGE_WRITABLE,
61 app_name_);
62 } else {
63 return l10n_util::GetStringFUTF16(
64 IDS_EXTENSIONS_DIRECTORY_CONFIRMATION_DIALOG_MESSAGE_READ_ONLY,
65 app_name_);
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() {
77 on_accept_.Run();
80 void DirectoryAccessConfirmationDialog::OnCanceled() {
81 on_cancel_.Run();
84 void DirectoryAccessConfirmationDialog::OnClosed() {
85 on_cancel_.Run();
88 } // namespace
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),
98 web_contents);