1 // Copyright (c) 2012 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_TABS_PINNED_TAB_CODEC_H_
6 #define CHROME_BROWSER_UI_TABS_PINNED_TAB_CODEC_H_
7 
8 #include <vector>
9 
10 #include "base/macros.h"
11 #include "chrome/browser/ui/startup/startup_tab.h"
12 #include "url/gurl.h"
13 
14 class Profile;
15 
16 namespace base {
17 class Value;
18 }
19 
20 namespace user_prefs {
21 class PrefRegistrySyncable;
22 }
23 
24 // PinnedTabCodec is used to read and write the set of pinned tabs to
25 // preferences. When Chrome exits the sets of pinned tabs are written to prefs.
26 // On startup if the user has not chosen to restore the last session the set of
27 // pinned tabs is opened.
28 //
29 // The entries are stored in preferences as a list of dictionaries, with each
30 // dictionary describing the entry.
31 class PinnedTabCodec {
32  public:
33   // Registers the preference used by this class.
34   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
35 
36   // Resets the preferences state.
37   static void WritePinnedTabs(Profile* profile);
38 
39   // Sets the preferences state from the specified tab list.
40   static void WritePinnedTabs(Profile* profile, const StartupTabs& tabs);
41 
42   // Reads and returns the set of pinned tabs to restore from preferences.
43   static StartupTabs ReadPinnedTabs(Profile* profile);
44   static StartupTabs ReadPinnedTabs(const base::Value* value);
45 
46  private:
47   PinnedTabCodec();
48   ~PinnedTabCodec();
49 
50   DISALLOW_COPY_AND_ASSIGN(PinnedTabCodec);
51 };
52 
53 #endif  // CHROME_BROWSER_UI_TABS_PINNED_TAB_CODEC_H_
54