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
|
// Copyright (c) 2010 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_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
#pragma once
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
class DOMUI;
class Value;
class PrefService;
// Use for the shown sections bitmask.
// Currently, only the THUMB and APPS sections can be toggled by the user. Other
// sections are shown automatically if they have data, and hidden otherwise.
enum Section {
// If one of these is set, the corresponding section shows large thumbnails,
// else it shows only a small overview list.
THUMB = 1 << 0,
APPS = 1 << 6,
// We use the low 16 bits for sections, the high 16 bits for minimized state.
ALL_SECTIONS_MASK = 0x0000FFFF,
// If one of these is set, then the corresponding section is shown minimized
// at the bottom of the NTP and no data is directly visible on the NTP.
MINIMIZED_THUMB = 1 << (0 + 16),
MINIMIZED_RECENT = 1 << (2 + 16),
MINIMIZED_APPS = 1 << (6 + 16),
};
class ShownSectionsHandler : public DOMMessageHandler,
public NotificationObserver {
public:
explicit ShownSectionsHandler(PrefService* pref_service);
virtual ~ShownSectionsHandler() {}
// Helper to get the current shown sections.
static int GetShownSections(PrefService* pref_service);
// DOMMessageHandler implementation.
virtual void RegisterMessages();
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
// Callback for "getShownSections" message.
void HandleGetShownSections(const ListValue* args);
// Callback for "setShownSections" message.
void HandleSetShownSections(const ListValue* args);
static void RegisterUserPrefs(PrefService* pref_service);
static void MigrateUserPrefs(PrefService* pref_service,
int old_pref_version,
int new_pref_version);
private:
PrefService* pref_service_;
PrefChangeRegistrar pref_registrar_;
NotificationRegistrar notification_registrar_;
DISALLOW_COPY_AND_ASSIGN(ShownSectionsHandler);
};
#endif // CHROME_BROWSER_DOM_UI_SHOWN_SECTIONS_HANDLER_H_
|