NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / extensions / extension_error_ui_default.cc
blob160a77b391ae1144193d38f3d44ced6df6a69f6e
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),
17 browser_(NULL),
18 global_error_(new ExtensionGlobalError(this)) {
21 ExtensionErrorUIDefault::~ExtensionErrorUIDefault() {
24 bool ExtensionErrorUIDefault::ShowErrorInBubbleView() {
25 Browser* browser =
26 chrome::FindLastActiveWithProfile(extension_service()->profile(),
27 chrome::GetActiveDesktop());
28 if (!browser)
29 return false;
31 browser_ = browser;
32 global_error_->ShowBubbleView(browser);
33 return true;
36 void ExtensionErrorUIDefault::ShowExtensions() {
37 DCHECK(browser_);
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() {
55 return false;
58 int ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemCommandID() {
59 NOTREACHED();
60 return 0;
63 base::string16 ExtensionErrorUIDefault::ExtensionGlobalError::MenuItemLabel() {
64 NOTREACHED();
65 return NULL;
68 void ExtensionErrorUIDefault::ExtensionGlobalError::ExecuteMenuItem(
69 Browser* browser) {
70 NOTREACHED();
73 base::string16
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();
110 // static
111 ExtensionErrorUI* ExtensionErrorUI::Create(
112 ExtensionService* extension_service) {
113 return new ExtensionErrorUIDefault(extension_service);