Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: chrome/browser/ui/webui/ntp/shown_sections_handler.h

Issue 8438028: ntp: remove ShownSectionHandler and all references to it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more functional test updates Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_NTP_SHOWN_SECTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SHOWN_SECTIONS_HANDLER_H_
7 #pragma once
8
9 #include "chrome/browser/prefs/pref_change_registrar.h"
10 #include "content/browser/webui/web_ui.h"
11 #include "content/public/browser/notification_observer.h"
12
13 class Extension;
14 class PrefService;
15
16 namespace base {
17 class Value;
18 }
19
20 // Use for the shown sections bitmask.
21 // Currently, only the THUMB and APPS sections can be toggled by the user. Other
22 // sections are shown automatically if they have data, and hidden otherwise.
23 enum Section {
24 // If one of these is set, the corresponding section shows large thumbnails,
25 // else it shows only a small overview list.
26 THUMB = 1 << 0,
27 APPS = 1 << 6,
28
29 // We use the low 16 bits for sections, the high 16 bits for menu mode.
30 ALL_SECTIONS_MASK = 0x0000FFFF,
31
32 // If one of these is set, then the corresponding section is shown in a menu
33 // at the bottom of the NTP and no data is directly visible on the NTP.
34 MENU_THUMB = 1 << (0 + 16),
35 MENU_RECENT = 1 << (2 + 16),
36 MENU_APPS = 1 << (6 + 16),
37 };
38
39 class ShownSectionsHandler : public WebUIMessageHandler,
40 public content::NotificationObserver {
41 public:
42 explicit ShownSectionsHandler(PrefService* pref_service);
43 virtual ~ShownSectionsHandler() {}
44
45 // Helper to get the current shown sections.
46 static int GetShownSections(PrefService* pref_service);
47
48 // Expands |section|, collapsing any previously expanded section. This is the
49 // same thing that happens if a user clicks on |section|.
50 static void SetShownSection(PrefService* prefs, Section section);
51
52 // WebUIMessageHandler implementation.
53 virtual void RegisterMessages() OVERRIDE;
54
55 // content::NotificationObserver implementation.
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 // Callback for "setShownSections" message.
61 void HandleSetShownSections(const base::ListValue* args);
62
63 static void RegisterUserPrefs(PrefService* pref_service);
64
65 static void MigrateUserPrefs(PrefService* pref_service,
66 int old_pref_version,
67 int new_pref_version);
68
69 static void OnExtensionInstalled(PrefService* prefs,
70 const Extension* extension);
71
72 private:
73 PrefService* pref_service_;
74 PrefChangeRegistrar pref_registrar_;
75
76 DISALLOW_COPY_AND_ASSIGN(ShownSectionsHandler);
77 };
78
79 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SHOWN_SECTIONS_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.cc ('k') | chrome/browser/ui/webui/ntp/shown_sections_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698