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_UI_WEBUI_OPTIONS_PERSONAL_OPTIONS_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_PERSONAL_OPTIONS_HANDLER_H_
7#pragma once
8
9#include "base/basictypes.h"
10#include "chrome/browser/browser_signin.h"
11#include "chrome/browser/sync/profile_sync_service.h"
12#include "chrome/browser/ui/webui/options/options_ui.h"
13#if defined(OS_CHROMEOS)
14#include "content/common/notification_registrar.h"
15#endif
16
17class OptionsManagedBannerHandler;
18
19// Chrome personal options page UI handler.
20class PersonalOptionsHandler : public OptionsPageUIHandler,
21                               public ProfileSyncServiceObserver,
22                               public BrowserSignin::SigninDelegate {
23 public:
24  PersonalOptionsHandler();
25  virtual ~PersonalOptionsHandler();
26
27  // OptionsPageUIHandler implementation.
28  virtual void GetLocalizedValues(DictionaryValue* localized_strings);
29  virtual void Initialize();
30
31  // WebUIMessageHandler implementation.
32  virtual void RegisterMessages();
33
34  // NotificationObserver implementation.
35  virtual void Observe(NotificationType type,
36                       const NotificationSource& source,
37                       const NotificationDetails& details);
38
39  // ProfileSyncServiceObserver implementation.
40  virtual void OnStateChanged();
41
42  // BrowserSignin::SigninDelegate implementation.
43  virtual void OnLoginSuccess();
44  virtual void OnLoginFailure(const GoogleServiceAuthError& error);
45
46 private:
47  void ObserveThemeChanged();
48  void ShowSyncActionDialog(const ListValue* args);
49  void ShowSyncLoginDialog(const ListValue* args);
50  void ShowCustomizeSyncDialog(const ListValue* args);
51  void ThemesReset(const ListValue* args);
52#if defined(TOOLKIT_GTK)
53  void ThemesSetGTK(const ListValue* args);
54#endif
55
56  // Called when the user updates the set of enabled data types to sync. |args|
57  // is ignored.
58  void OnPreferredDataTypesUpdated(const ListValue* args);
59
60#if defined(OS_CHROMEOS)
61  void LoadAccountPicture(const ListValue* args);
62  NotificationRegistrar registrar_;
63#endif
64
65  scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
66
67  // True if the multiprofiles switch is enabled.
68  bool multiprofile_;
69
70  DISALLOW_COPY_AND_ASSIGN(PersonalOptionsHandler);
71};
72
73#endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_PERSONAL_OPTIONS_HANDLER_H_
74