blob: bd1c1b1c4639b0fe61d1fb163acd616c12d1fad9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
#pragma once
#include "chrome/browser/ui/webui/sync_setup_handler.h"
class NotificationSource;
class NotificationDetails;
// The handler for Javascript messages related to the "sync promo" page.
class SyncPromoHandler : public SyncSetupHandler {
public:
explicit SyncPromoHandler(ProfileManager* profile_manager);
virtual ~SyncPromoHandler();
// Called to register our preferences before we use them (so there will be a
// default if not present yet).
static void RegisterUserPrefs(PrefService* prefs);
// WebUIMessageHandler implementation.
virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE;
virtual void RegisterMessages() OVERRIDE;
// SyncSetupFlowHandler implementation.
virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE;
// NotificationObserver implementation.
virtual void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
protected:
virtual void ShowSetupUI() OVERRIDE;
private:
// Javascript callback handler to close the sync promo.
void HandleCloseSyncPromo(const base::ListValue* args);
// Javascript callback handler to initialize the sync promo.
void HandleInitializeSyncPromo(const base::ListValue* args);
// Javascript callback handler to switch the advanced sync settings. |args| is
// the list of arguments passed from JS and should be an empty list.
void HandleShowAdvancedSettings(const base::ListValue* args);
// Javascript callback handler to record user actions on the sync promo.
void HandleUserFlowAction(const base::ListValue* args);
// Return the number of times the user with the current profile has seen the
// sync promo.
int GetViewCount() const;
// Increment the local view count by the specified non-negative integer
// amount. Returns the new total view count.
int IncrementViewCountBy(unsigned int amount);
// Record a user's flow through the promo to our histogram in UMA.
void RecordUserFlowAction(int action);
// Use this to register for certain notifications (currently when tabs or
// windows close).
NotificationRegistrar registrar_;
// Weak reference that's initialized and checked in Attach() (after that
// guaranteed to be non-NULL).
PrefService* prefs_;
// If the user closes the whole window we'll get a close notification from the
// tab as well, so this bool acts as a small mutex to only report the close
// method once.
bool window_already_closed_;
DISALLOW_COPY_AND_ASSIGN(SyncPromoHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_HANDLER_H_
|