| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_THEME_INSTALLED_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 | 14 |
| 15 class ExtensionService; | 15 class ExtensionService; |
| 16 class InfoBarService; | 16 class InfoBarService; |
| 17 class Profile; |
| 17 class ThemeService; | 18 class ThemeService; |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 class Extension; | 21 class Extension; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // When a user installs a theme, we display it immediately, but provide an | 24 // When a user installs a theme, we display it immediately, but provide an |
| 24 // infobar allowing them to cancel. | 25 // infobar allowing them to cancel. |
| 25 class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, | 26 class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, |
| 26 public content::NotificationObserver { | 27 public content::NotificationObserver { |
| 27 public: | 28 public: |
| 29 // Creates a theme installed delegate and adds it to the last active tab on |
| 30 // |profile|. |
| 31 static void Create(const extensions::Extension* new_theme, |
| 32 Profile* profile, |
| 33 const std::string& previous_theme_id, |
| 34 bool previous_using_native_theme); |
| 35 |
| 36 protected: |
| 37 ThemeService* theme_service() { return theme_service_; } |
| 38 |
| 39 // ConfirmInfoBarDelegate: |
| 40 virtual bool Cancel() OVERRIDE; |
| 41 |
| 42 private: |
| 28 ThemeInstalledInfoBarDelegate(InfoBarService* infobar_service, | 43 ThemeInstalledInfoBarDelegate(InfoBarService* infobar_service, |
| 29 ExtensionService* extension_service, | 44 ExtensionService* extension_service, |
| 30 ThemeService* theme_service, | 45 ThemeService* theme_service, |
| 31 const extensions::Extension* new_theme, | 46 const extensions::Extension* new_theme, |
| 32 const std::string& previous_theme_id, | 47 const std::string& previous_theme_id, |
| 33 bool previous_using_native_theme); | 48 bool previous_using_native_theme); |
| 34 | |
| 35 // Returns true if the given theme is the same as the one associated with this | |
| 36 // info bar. | |
| 37 bool MatchesTheme(const extensions::Extension* theme) const; | |
| 38 | |
| 39 protected: | |
| 40 virtual ~ThemeInstalledInfoBarDelegate(); | 49 virtual ~ThemeInstalledInfoBarDelegate(); |
| 41 | 50 |
| 42 ThemeService* theme_service() { return theme_service_; } | |
| 43 | |
| 44 // ConfirmInfoBarDelegate: | |
| 45 virtual bool Cancel() OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 // ConfirmInfoBarDelegate: | 51 // ConfirmInfoBarDelegate: |
| 49 virtual gfx::Image* GetIcon() const OVERRIDE; | 52 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 50 virtual Type GetInfoBarType() const OVERRIDE; | 53 virtual Type GetInfoBarType() const OVERRIDE; |
| 51 virtual ThemeInstalledInfoBarDelegate* | 54 virtual ThemeInstalledInfoBarDelegate* |
| 52 AsThemePreviewInfobarDelegate() OVERRIDE; | 55 AsThemePreviewInfobarDelegate() OVERRIDE; |
| 53 virtual string16 GetMessageText() const OVERRIDE; | 56 virtual string16 GetMessageText() const OVERRIDE; |
| 54 virtual int GetButtons() const OVERRIDE; | 57 virtual int GetButtons() const OVERRIDE; |
| 55 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 58 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 56 | 59 |
| 57 // content::NotificationObserver: | 60 // content::NotificationObserver: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 70 | 73 |
| 71 // Used to undo theme install. | 74 // Used to undo theme install. |
| 72 std::string previous_theme_id_; | 75 std::string previous_theme_id_; |
| 73 bool previous_using_native_theme_; | 76 bool previous_using_native_theme_; |
| 74 | 77 |
| 75 // Registers and unregisters us for notifications. | 78 // Registers and unregisters us for notifications. |
| 76 content::NotificationRegistrar registrar_; | 79 content::NotificationRegistrar registrar_; |
| 77 }; | 80 }; |
| 78 | 81 |
| 79 #endif // CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ | 82 #endif // CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ |
| OLD | NEW |