| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_disabled_ui.h" | 5 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/global_error_service.h" | 24 #include "chrome/browser/ui/global_error_service.h" |
| 25 #include "chrome/browser/ui/global_error_service_factory.h" | 25 #include "chrome/browser/ui/global_error_service_factory.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 28 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
| 29 #include "content/public/browser/notification_observer.h" | 29 #include "content/public/browser/notification_observer.h" |
| 30 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
| 31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 32 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 34 #include "grit/theme_resources.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 static base::LazyInstance< | 39 static base::LazyInstance< |
| 39 std::bitset<IDC_EXTENSION_DISABLED_LAST - | 40 std::bitset<IDC_EXTENSION_DISABLED_LAST - |
| 40 IDC_EXTENSION_DISABLED_FIRST + 1> > | 41 IDC_EXTENSION_DISABLED_FIRST + 1> > |
| 41 menu_command_ids = LAZY_INSTANCE_INITIALIZER; | 42 menu_command_ids = LAZY_INSTANCE_INITIALIZER; |
| 42 | 43 |
| 43 // Get an available menu ID. | 44 // Get an available menu ID. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 class ExtensionDisabledGlobalError : public GlobalError, | 125 class ExtensionDisabledGlobalError : public GlobalError, |
| 125 public content::NotificationObserver, | 126 public content::NotificationObserver, |
| 126 public ExtensionUninstallDialog::Delegate { | 127 public ExtensionUninstallDialog::Delegate { |
| 127 public: | 128 public: |
| 128 ExtensionDisabledGlobalError(ExtensionService* service, | 129 ExtensionDisabledGlobalError(ExtensionService* service, |
| 129 const Extension* extension); | 130 const Extension* extension); |
| 130 virtual ~ExtensionDisabledGlobalError(); | 131 virtual ~ExtensionDisabledGlobalError(); |
| 131 | 132 |
| 132 // GlobalError implementation. | 133 // GlobalError implementation. |
| 133 virtual bool HasBadge() OVERRIDE; | 134 virtual bool HasBadge() OVERRIDE; |
| 135 virtual int GetBadgeResourceID() OVERRIDE; |
| 134 virtual bool HasMenuItem() OVERRIDE; | 136 virtual bool HasMenuItem() OVERRIDE; |
| 135 virtual int MenuItemCommandID() OVERRIDE; | 137 virtual int MenuItemCommandID() OVERRIDE; |
| 136 virtual string16 MenuItemLabel() OVERRIDE; | 138 virtual string16 MenuItemLabel() OVERRIDE; |
| 139 virtual int MenuItemIconResourceID() OVERRIDE; |
| 137 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 140 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
| 138 virtual bool HasBubbleView() OVERRIDE; | 141 virtual bool HasBubbleView() OVERRIDE; |
| 139 virtual string16 GetBubbleViewTitle() OVERRIDE; | 142 virtual string16 GetBubbleViewTitle() OVERRIDE; |
| 140 virtual string16 GetBubbleViewMessage() OVERRIDE; | 143 virtual string16 GetBubbleViewMessage() OVERRIDE; |
| 141 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 144 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
| 142 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 145 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; |
| 143 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | 146 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; |
| 144 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | 147 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; |
| 145 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | 148 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; |
| 146 | 149 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { | 194 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { |
| 192 ReleaseMenuCommandID(menu_command_id_); | 195 ReleaseMenuCommandID(menu_command_id_); |
| 193 HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", | 196 HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", |
| 194 user_response_, EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); | 197 user_response_, EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); |
| 195 } | 198 } |
| 196 | 199 |
| 197 bool ExtensionDisabledGlobalError::HasBadge() { | 200 bool ExtensionDisabledGlobalError::HasBadge() { |
| 198 return true; | 201 return true; |
| 199 } | 202 } |
| 200 | 203 |
| 204 int ExtensionDisabledGlobalError::GetBadgeResourceID() { |
| 205 return IDR_UPDATE_BADGE; |
| 206 } |
| 207 |
| 201 bool ExtensionDisabledGlobalError::HasMenuItem() { | 208 bool ExtensionDisabledGlobalError::HasMenuItem() { |
| 202 return true; | 209 return true; |
| 203 } | 210 } |
| 204 | 211 |
| 205 int ExtensionDisabledGlobalError::MenuItemCommandID() { | 212 int ExtensionDisabledGlobalError::MenuItemCommandID() { |
| 206 return menu_command_id_; | 213 return menu_command_id_; |
| 207 } | 214 } |
| 208 | 215 |
| 216 int ExtensionDisabledGlobalError::MenuItemIconResourceID() { |
| 217 return IDR_UPDATE_MENU; |
| 218 } |
| 219 |
| 209 string16 ExtensionDisabledGlobalError::MenuItemLabel() { | 220 string16 ExtensionDisabledGlobalError::MenuItemLabel() { |
| 210 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, | 221 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, |
| 211 UTF8ToUTF16(extension_->name())); | 222 UTF8ToUTF16(extension_->name())); |
| 212 } | 223 } |
| 213 | 224 |
| 214 void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) { | 225 void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) { |
| 215 ShowBubbleView(browser); | 226 ShowBubbleView(browser); |
| 216 } | 227 } |
| 217 | 228 |
| 218 bool ExtensionDisabledGlobalError::HasBubbleView() { | 229 bool ExtensionDisabledGlobalError::HasBubbleView() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); | 322 AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); |
| 312 } | 323 } |
| 313 | 324 |
| 314 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, | 325 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, |
| 315 const Extension* extension) { | 326 const Extension* extension) { |
| 316 // This object manages its own lifetime. | 327 // This object manages its own lifetime. |
| 317 new ExtensionDisabledDialogDelegate(profile, service, extension); | 328 new ExtensionDisabledDialogDelegate(profile, service, extension); |
| 318 } | 329 } |
| 319 | 330 |
| 320 } // namespace extensions | 331 } // namespace extensions |
| OLD | NEW |