1// Copyright (c) 2013 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_WELCOME_HANDLER_ANDROID_H_
6#define CHROME_BROWSER_UI_WEBUI_WELCOME_HANDLER_ANDROID_H_
7
8#include "base/scoped_observer.h"
9#include "chrome/browser/sync/profile_sync_service.h"
10#include "chrome/browser/sync/profile_sync_service_observer.h"
11#include "content/public/browser/web_ui_message_handler.h"
12
13namespace base {
14class ListValue;
15}
16
17// Handler class for chrome://welcome page.
18class WelcomeHandler : public content::WebUIMessageHandler,
19                       public ProfileSyncServiceObserver {
20 public:
21  WelcomeHandler();
22  virtual ~WelcomeHandler();
23
24  // content::WebUIMessageHandler implementation.
25  virtual void RegisterMessages() OVERRIDE;
26
27  // Callback for the "updateSyncFooterVisibility" message. This makes the sync
28  // footer in the page visible if sync is enabled.
29  void HandleUpdateSyncFooterVisibility(const base::ListValue* args);
30
31  // Callback for the "showSyncSettings" message. This opens the sync settings
32  // menu fragment.
33  void HandleShowSyncSettings(const base::ListValue* args);
34
35  // Callback for the "showTermsOfService" message. This opens the terms of
36  // service popup.
37  void HandleShowTermsOfService(const base::ListValue* args);
38
39  // ProfileSyncServiceObserver implementation
40  virtual void OnStateChanged() OVERRIDE;
41
42 private:
43  // Update the sync footer visibility. Set |forced| if you want to force to
44  // send an update to the renderer regardless of whether we assume the state
45  // is up to date or not.
46  void UpdateSyncFooterVisibility(bool forced);
47
48  // Cached pointer to the sync service for this profile.
49  ProfileSyncService* sync_service_;
50
51  ScopedObserver<ProfileSyncService, WelcomeHandler> observer_manager_;
52
53  // Whether the sync footer is visible on the page.
54  bool is_sync_footer_visible_;
55
56  DISALLOW_COPY_AND_ASSIGN(WelcomeHandler);
57};
58
59#endif  // CHROME_BROWSER_UI_WEBUI_WELCOME_HANDLER_ANDROID_H_
60