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 "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/chrome_pages.h"
12 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h"
14 ExtensionErrorUIDefault::ExtensionErrorUIDefault(
15 ExtensionService
* extension_service
)
16 : ExtensionErrorUI(extension_service
),
18 global_error_(new ExtensionGlobalError(this)) {
21 ExtensionErrorUIDefault::~ExtensionErrorUIDefault() {
24 bool ExtensionErrorUIDefault::ShowErrorInBubbleView() {
26 chrome::FindLastActiveWithProfile(extension_service()->profile(),
27 chrome::GetActiveDesktop());
32 global_error_
->ShowBubbleView(browser
);
36 void ExtensionErrorUIDefault::ShowExtensions() {
38 chrome::ShowExtensions(browser_
, std::string());
41 void ExtensionErrorUIDefault::Close() {
42 if (global_error_
->HasShownBubbleView()) {
43 // Will end up calling into |global_error_|->OnBubbleViewDidClose,
44 // possibly synchronously.
45 global_error_
->GetBubbleView()->CloseBubbleView();
49 ExtensionErrorUIDefault::ExtensionGlobalError::ExtensionGlobalError(
50 ExtensionErrorUIDefault
* error_ui
)
51 : error_ui_(error_ui
) {
54 bool ExtensionErrorUIDefault::ExtensionGlobalError::HasMenuItem() {
58 int ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemCommandID() {
63 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemLabel() {
68 void ExtensionErrorUIDefault::ExtensionGlobalError::ExecuteMenuItem(
74 ExtensionErrorUIDefault::ExtensionGlobalError::GetBubbleViewTitle() {
75 return error_ui_
->GetBubbleViewTitle();
78 std::vector
<base::string16
>
79 ExtensionErrorUIDefault::ExtensionGlobalError::GetBubbleViewMessages() {
80 return error_ui_
->GetBubbleViewMessages();
83 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::
84 GetBubbleViewAcceptButtonLabel() {
85 return error_ui_
->GetBubbleViewAcceptButtonLabel();
88 base::string16
ExtensionErrorUIDefault::ExtensionGlobalError::
89 GetBubbleViewCancelButtonLabel() {
90 return error_ui_
->GetBubbleViewCancelButtonLabel();
93 void ExtensionErrorUIDefault::ExtensionGlobalError::
94 OnBubbleViewDidClose(Browser
* browser
) {
95 // Calling BubbleViewDidClose on |error_ui_| will delete it. It owns us, so
96 // |this| will be deleted too.
97 error_ui_
->BubbleViewDidClose();
100 void ExtensionErrorUIDefault::ExtensionGlobalError::
101 BubbleViewAcceptButtonPressed(Browser
* browser
) {
102 error_ui_
->BubbleViewAcceptButtonPressed();
105 void ExtensionErrorUIDefault::ExtensionGlobalError::
106 BubbleViewCancelButtonPressed(Browser
* browser
) {
107 error_ui_
->BubbleViewCancelButtonPressed();
111 ExtensionErrorUI
* ExtensionErrorUI::Create(
112 ExtensionService
* extension_service
) {
113 return new ExtensionErrorUIDefault(extension_service
);