1 // Copyright (c) 2012 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/extensions/extension_error_ui_default.h"
7 #include "base/logging.h"
8 #include "base/strings/string_util.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/chrome_pages.h"
14 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h"
16 namespace extensions
{
18 ExtensionErrorUIDefault::ExtensionErrorUIDefault(
19 ExtensionErrorUI::Delegate
* delegate
)
20 : ExtensionErrorUI(delegate
),
21 profile_(Profile::FromBrowserContext(delegate
->GetContext())),
23 global_error_(new ExtensionGlobalError(this)) {
26 ExtensionErrorUIDefault::~ExtensionErrorUIDefault() {
29 bool ExtensionErrorUIDefault::ShowErrorInBubbleView() {
31 chrome::FindLastActiveWithProfile(profile_
, chrome::GetActiveDesktop());
36 global_error_
->ShowBubbleView(browser
);
40 void ExtensionErrorUIDefault::ShowExtensions() {
42 chrome::ShowExtensions(browser_
, std::string());
45 void ExtensionErrorUIDefault::Close() {
46 if (global_error_
->HasShownBubbleView()) {
47 // Will end up calling into |global_error_|->OnBubbleViewDidClose,
48 // possibly synchronously.
49 global_error_
->GetBubbleView()->CloseBubbleView();
53 ExtensionErrorUIDefault::ExtensionGlobalError::ExtensionGlobalError(
54 ExtensionErrorUIDefault
* error_ui
)
55 : error_ui_(error_ui
) {
58 bool ExtensionErrorUIDefault::ExtensionGlobalError::HasMenuItem() {
62 int ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemCommandID() {
67 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemLabel() {
72 void ExtensionErrorUIDefault::ExtensionGlobalError::ExecuteMenuItem(
78 ExtensionErrorUIDefault::ExtensionGlobalError::GetBubbleViewTitle() {
79 return error_ui_
->GetBubbleViewTitle();
82 std::vector
<base::string16
>
83 ExtensionErrorUIDefault::ExtensionGlobalError::GetBubbleViewMessages() {
84 return error_ui_
->GetBubbleViewMessages();
87 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::
88 GetBubbleViewAcceptButtonLabel() {
89 return error_ui_
->GetBubbleViewAcceptButtonLabel();
92 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::
93 GetBubbleViewCancelButtonLabel() {
94 return error_ui_
->GetBubbleViewCancelButtonLabel();
97 void ExtensionErrorUIDefault::ExtensionGlobalError::OnBubbleViewDidClose(
99 error_ui_
->BubbleViewDidClose();
102 void ExtensionErrorUIDefault::ExtensionGlobalError::
103 BubbleViewAcceptButtonPressed(Browser
* browser
) {
104 error_ui_
->BubbleViewAcceptButtonPressed();
107 void ExtensionErrorUIDefault::ExtensionGlobalError::
108 BubbleViewCancelButtonPressed(Browser
* browser
) {
109 error_ui_
->BubbleViewCancelButtonPressed();
113 ExtensionErrorUI
* ExtensionErrorUI::Create(
114 ExtensionErrorUI::Delegate
* delegate
) {
115 return new ExtensionErrorUIDefault(delegate
);
118 } // namespace extensions