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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ 7 #pragma once 8 9 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 10 #include "content/common/notification_registrar.h" 11 12 class ThemeService; 13 class Extension; 14 class SkBitmap; 15 class TabContents; 16 17 // When a user installs a theme, we display it immediately, but provide an 18 // infobar allowing them to cancel. 19 class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, 20 public NotificationObserver { 21 public: 22 ThemeInstalledInfoBarDelegate(TabContents* tab_contents, 23 const Extension* new_theme, 24 const std::string& previous_theme_id); 25 26 // Returns true if the given theme is the same as the one associated with this 27 // info bar. 28 bool MatchesTheme(const Extension* theme) const; 29 30 protected: 31 virtual ~ThemeInstalledInfoBarDelegate(); 32 theme_service()33 ThemeService* theme_service() { return theme_service_; } 34 35 // ConfirmInfoBarDelegate: 36 virtual bool Cancel(); 37 38 private: 39 // ConfirmInfoBarDelegate: 40 virtual void InfoBarClosed(); 41 virtual SkBitmap* GetIcon() const; 42 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); 43 virtual string16 GetMessageText() const; 44 virtual int GetButtons() const; 45 virtual string16 GetButtonLabel(InfoBarButton button) const; 46 47 // NotificationObserver: 48 virtual void Observe(NotificationType type, 49 const NotificationSource& source, 50 const NotificationDetails& details); 51 52 Profile* profile_; 53 ThemeService* theme_service_; 54 55 // Name of theme that's just been installed. 56 std::string name_; 57 58 // ID of theme that's just been installed. 59 std::string theme_id_; 60 61 // Used to undo theme install. 62 std::string previous_theme_id_; 63 64 // Tab to which this info bar is associated. 65 TabContents* tab_contents_; 66 67 // Registers and unregisters us for notifications. 68 NotificationRegistrar registrar_; 69 }; 70 71 #endif // CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_ 72