15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/infobars/core/confirm_infobar_delegate.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ExtensionService;
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class InfoBarService;
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Profile;
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ThemeService;
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace extensions {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Extension;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When a user installs a theme, we display it immediately, but provide an
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// infobar allowing them to cancel.
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate,
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      public content::NotificationObserver {
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Creates a theme installed infobar and delegate and adds the infobar to the
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // last active tab on |profile|.
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static void Create(const extensions::Extension* new_theme,
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     Profile* profile,
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                     const std::string& previous_theme_id,
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     bool previous_using_system_theme);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  ThemeInstalledInfoBarDelegate(ExtensionService* extension_service,
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                ThemeService* theme_service,
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                const extensions::Extension* new_theme,
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                const std::string& previous_theme_id,
41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                                bool previous_using_system_theme);
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~ThemeInstalledInfoBarDelegate();
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ConfirmInfoBarDelegate:
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual int GetIconID() const OVERRIDE;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual Type GetInfoBarType() const OVERRIDE;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ThemeInstalledInfoBarDelegate*
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      AsThemePreviewInfobarDelegate() OVERRIDE;
49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetMessageText() const OVERRIDE;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetButtons() const OVERRIDE;
51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual bool Cancel() OVERRIDE;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // content::NotificationObserver:
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Observe(int type,
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationSource& source,
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationDetails& details) OVERRIDE;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ExtensionService* extension_service_;
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ThemeService* theme_service_;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Name of theme that's just been installed.
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string name_;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // ID of theme that's just been installed.
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string theme_id_;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Used to undo theme install.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string previous_theme_id_;
70cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  bool previous_using_system_theme_;
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registers and unregisters us for notifications.
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  content::NotificationRegistrar registrar_;
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_EXTENSIONS_THEME_INSTALLED_INFOBAR_DELEGATE_H_
77