| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GLOBAL_ERROR_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_GLOBAL_ERROR_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/ui/global_error/global_error.h" | 10 #include "chrome/browser/ui/global_error/global_error.h" |
| 11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
| 12 | 12 |
| 13 class Browser; | 13 class Browser; |
| 14 class ExtensionService; | 14 class ExtensionService; |
| 15 | 15 |
| 16 // This class encapsulates the UI we want to show users when certain events | 16 // This class encapsulates the UI we want to show users when certain events |
| 17 // occur related to installed extensions. | 17 // occur related to installed extensions. |
| 18 class ExtensionGlobalError : public GlobalError { | 18 class ExtensionErrorUI { |
| 19 public: | 19 public: |
| 20 explicit ExtensionGlobalError(ExtensionService* extension_service); | 20 static ExtensionErrorUI* Create(ExtensionService* extension_service); |
| 21 virtual ~ExtensionGlobalError(); | 21 |
| 22 virtual ~ExtensionErrorUI(); |
| 22 | 23 |
| 23 // Inform us that a given extension is of a certain type that the user | 24 // Inform us that a given extension is of a certain type that the user |
| 24 // hasn't yet acknowledged. | 25 // hasn't yet acknowledged. |
| 25 void AddExternalExtension(const std::string& id); | 26 void AddExternalExtension(const std::string& id); |
| 26 void AddBlacklistedExtension(const std::string& id); | 27 void AddBlacklistedExtension(const std::string& id); |
| 27 void AddOrphanedExtension(const std::string& id); | 28 void AddOrphanedExtension(const std::string& id); |
| 28 | 29 |
| 29 // Returns sets replaying the IDs that have been added with the | 30 // Returns sets replaying the IDs that have been added with the |
| 30 // Add[...]Extension methods. | 31 // Add[...]Extension methods. |
| 31 const extensions::ExtensionIdSet* get_external_extension_ids() const { | 32 const extensions::ExtensionIdSet* get_external_extension_ids() const { |
| 32 return external_extension_ids_.get(); | 33 return external_extension_ids_.get(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 const extensions::ExtensionIdSet* get_blacklisted_extension_ids() const { | 36 const extensions::ExtensionIdSet* get_blacklisted_extension_ids() const { |
| 36 return blacklisted_extension_ids_.get(); | 37 return blacklisted_extension_ids_.get(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 const extensions::ExtensionIdSet* get_orphaned_extension_ids() const { | 40 const extensions::ExtensionIdSet* get_orphaned_extension_ids() const { |
| 40 return orphaned_extension_ids_.get(); | 41 return orphaned_extension_ids_.get(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // GlobalError methods. | 44 // Shows the installation error in a bubble view. Should return true if a |
| 44 virtual bool HasBadge() OVERRIDE; | 45 // bubble is shown, false if one could not be shown. |
| 45 virtual bool HasMenuItem() OVERRIDE; | 46 virtual bool ShowErrorInBubbleView() = 0; |
| 46 virtual int MenuItemCommandID() OVERRIDE; | 47 |
| 47 virtual string16 MenuItemLabel() OVERRIDE; | 48 // Shows the extension page. Called as a result of the user clicking more |
| 48 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 49 // info and should be only called from the context of a callback |
| 49 virtual bool HasBubbleView() OVERRIDE; | 50 // (BubbleViewDidClose or BubbleViewAccept/CancelButtonPressed). |
| 50 virtual string16 GetBubbleViewTitle() OVERRIDE; | 51 // It should use the same browser as where the bubble was shown. |
| 51 virtual string16 GetBubbleViewMessage() OVERRIDE; | 52 virtual void ShowExtensions() = 0; |
| 52 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 53 |
| 53 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 54 protected: |
| 54 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | 55 explicit ExtensionErrorUI(ExtensionService* extension_service); |
| 55 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | 56 |
| 56 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | 57 ExtensionService* extension_service() const { return extension_service_; } |
| 58 |
| 59 // Model methods for the bubble view. |
| 60 string16 GetBubbleViewTitle(); |
| 61 string16 GetBubbleViewMessage(); |
| 62 string16 GetBubbleViewAcceptButtonLabel(); |
| 63 string16 GetBubbleViewCancelButtonLabel(); |
| 64 |
| 65 // Sub-classes should call this methods based on the actions taken by the user |
| 66 // in the error bubble. |
| 67 void BubbleViewDidClose(); |
| 68 void BubbleViewAcceptButtonPressed(); |
| 69 void BubbleViewCancelButtonPressed(); |
| 57 | 70 |
| 58 private: | 71 private: |
| 59 bool should_delete_self_on_close_; | 72 bool should_delete_self_on_close_; |
| 60 ExtensionService* extension_service_; | 73 ExtensionService* extension_service_; |
| 61 scoped_ptr<extensions::ExtensionIdSet> external_extension_ids_; | 74 scoped_ptr<extensions::ExtensionIdSet> external_extension_ids_; |
| 62 scoped_ptr<extensions::ExtensionIdSet> blacklisted_extension_ids_; | 75 scoped_ptr<extensions::ExtensionIdSet> blacklisted_extension_ids_; |
| 63 scoped_ptr<extensions::ExtensionIdSet> orphaned_extension_ids_; | 76 scoped_ptr<extensions::ExtensionIdSet> orphaned_extension_ids_; |
| 64 string16 message_; // Displayed in the body of the alert. | 77 string16 message_; // Displayed in the body of the alert. |
| 65 | 78 |
| 66 // For a given set of extension IDs, generates appropriate text | 79 // For a given set of extension IDs, generates appropriate text |
| 67 // describing what the user needs to know about them. | 80 // describing what the user needs to know about them. |
| 68 string16 GenerateMessageSection(const extensions::ExtensionIdSet* extensions, | 81 string16 GenerateMessageSection(const extensions::ExtensionIdSet* extensions, |
| 69 int template_message_id); | 82 int template_message_id); |
| 70 | 83 |
| 71 // Generates the message displayed in the body of the alert. | 84 // Generates the message displayed in the body of the alert. |
| 72 string16 GenerateMessage(); | 85 string16 GenerateMessage(); |
| 73 | 86 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionGlobalError); | 87 DISALLOW_COPY_AND_ASSIGN(ExtensionErrorUI); |
| 75 }; | 88 }; |
| 76 | 89 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GLOBAL_ERROR_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_ |
| OLD | NEW |