Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1243)

Side by Side Diff: athena/extensions/chrome/athena_extension_install_ui.cc

Issue 634313004: Display dialog when app install succeeds / fails on Athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/extension_install_prompt.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/grit/chromium_strings.h"
12 #include "extensions/browser/install/crx_installer_error.h"
13 #include "extensions/common/extension.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/widget/widget.h"
16 #include "ui/views/window/dialog_delegate.h"
17
18 namespace athena {
19
20 namespace {
21
22 // Dialog delegate which displays a message and an 'OK' button.
23 class MessageDialogDelegate : public views::DialogDelegateView {
24 public:
25 explicit MessageDialogDelegate(const base::string16& message)
26 : message_(message) {}
27
28 virtual ~MessageDialogDelegate() {
29 }
30
31 // views::DialogDelegateView:
32 virtual base::string16 GetWindowTitle() const override {
33 return message_;
34 }
35
36 virtual int GetDialogButtons() const override {
37 return ui::DIALOG_BUTTON_OK;
38 }
39
40 private:
41 base::string16 message_;
42
43 DISALLOW_COPY_AND_ASSIGN(MessageDialogDelegate);
44 };
45
46 } // namespace
47
48 AthenaExtensionInstallUI::AthenaExtensionInstallUI()
49 : skip_post_install_ui_(false) {
50 }
51
52 AthenaExtensionInstallUI::~AthenaExtensionInstallUI() {
53 }
54
55 void AthenaExtensionInstallUI::OnInstallSuccess(
56 const extensions::Extension* extension,
57 const SkBitmap* icon) {
58 if (skip_post_install_ui_)
59 return;
60
61 base::string16 extension_name = base::UTF8ToUTF16(extension->name());
62 base::i18n::AdjustStringForLocaleDirection(&extension_name);
63 base::string16 message = l10n_util::GetStringFUTF16(
64 IDS_EXTENSION_INSTALLED_HEADING, extension_name);
65 views::Widget* widget = views::DialogDelegate::CreateDialogWidget(
66 new MessageDialogDelegate(message), NULL, NULL);
67 widget->Show();
68 }
69
70 void AthenaExtensionInstallUI::OnInstallFailure(
71 const extensions::CrxInstallerError& error) {
72 if (skip_post_install_ui_)
73 return;
74
75 views::Widget* widget = views::DialogDelegate::CreateDialogWidget(
76 new MessageDialogDelegate(error.message()), NULL, NULL);
77 widget->Show();
78 }
79
80 void AthenaExtensionInstallUI::SetUseAppInstalledBubble(bool use_bubble) {
81 }
82
83 void AthenaExtensionInstallUI::OpenAppInstalledUI(const std::string& app_id) {
84 NOTREACHED();
85 }
86
87 void AthenaExtensionInstallUI::SetSkipPostInstallUI(bool skip_ui) {
88 skip_post_install_ui_ = skip_ui;
89 }
90
91 gfx::NativeWindow AthenaExtensionInstallUI::GetDefaultInstallDialogParent() {
92 return NULL;
93 }
94
95 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698