OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 "athena/extensions/chrome/athena_extension_install_ui.h" |
| 6 |
| 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/crx_installer_error.h" |
| 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 11 #include "chrome/grit/chromium_strings.h" |
| 12 #include "extensions/common/extension.h" |
| 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/views/widget/widget.h" |
| 15 #include "ui/views/window/dialog_delegate.h" |
| 16 |
| 17 namespace athena { |
| 18 |
| 19 namespace { |
| 20 |
| 21 // Dialog delegate which displays a message and an 'OK' button. |
| 22 class MessageDialogDelegate : public views::DialogDelegateView { |
| 23 public: |
| 24 explicit MessageDialogDelegate(const base::string16& message) |
| 25 : message_(message) {} |
| 26 |
| 27 virtual ~MessageDialogDelegate() { |
| 28 } |
| 29 |
| 30 // views::DialogDelegateView: |
| 31 virtual base::string16 GetWindowTitle() const override { |
| 32 return message_; |
| 33 } |
| 34 |
| 35 virtual int GetDialogButtons() const override { |
| 36 return ui::DIALOG_BUTTON_OK; |
| 37 } |
| 38 |
| 39 private: |
| 40 base::string16 message_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(MessageDialogDelegate); |
| 43 }; |
| 44 |
| 45 } // namespace |
| 46 |
| 47 AthenaExtensionInstallUI::AthenaExtensionInstallUI(Profile* profile) |
| 48 : ExtensionInstallUI(profile) { |
| 49 } |
| 50 |
| 51 AthenaExtensionInstallUI::~AthenaExtensionInstallUI() { |
| 52 } |
| 53 |
| 54 void AthenaExtensionInstallUI::OnInstallSuccess( |
| 55 const extensions::Extension* extension, |
| 56 const SkBitmap* icon) { |
| 57 base::string16 extension_name = base::UTF8ToUTF16(extension->name()); |
| 58 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
| 59 base::string16 message = l10n_util::GetStringFUTF16( |
| 60 IDS_EXTENSION_INSTALLED_HEADING, extension_name); |
| 61 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
| 62 new MessageDialogDelegate(message), NULL, NULL); |
| 63 widget->Show(); |
| 64 } |
| 65 |
| 66 void AthenaExtensionInstallUI::OnInstallFailure( |
| 67 const extensions::CrxInstallerError& error) { |
| 68 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
| 69 new MessageDialogDelegate(error.message()), NULL, NULL); |
| 70 widget->Show(); |
| 71 } |
| 72 |
| 73 void AthenaExtensionInstallUI::SetUseAppInstalledBubble(bool use_bubble) { |
| 74 } |
| 75 |
| 76 void AthenaExtensionInstallUI::OpenAppInstalledUI(const std::string& app_id) { |
| 77 NOTREACHED(); |
| 78 } |
| 79 |
| 80 ExtensionInstallPrompt* AthenaExtensionInstallUI::CreateInstallPrompt() { |
| 81 return new ExtensionInstallPrompt(profile(), NULL, NULL); |
| 82 } |
| 83 |
| 84 ExtensionInstallUI* CreateExtensionInstallUI(Profile* profile) { |
| 85 return new AthenaExtensionInstallUI(profile); |
| 86 } |
| 87 |
| 88 } // namespace athena |
OLD | NEW |