Unwind the URL-based experiment IDs.
[chromium-blink-merge.git] / chrome / browser / prefs / session_startup_pref.h
blob1ac4e548ec038846c95aa703b5a6677ef9abf089
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.
5 #ifndef CHROME_BROWSER_PREFS_SESSION_STARTUP_PREF_H__
6 #define CHROME_BROWSER_PREFS_SESSION_STARTUP_PREF_H__
8 #include <vector>
10 #include "url/gurl.h"
12 class PrefService;
13 class Profile;
15 namespace user_prefs {
16 class PrefRegistrySyncable;
19 // StartupPref specifies what should happen at startup for a specified profile.
20 // StartupPref is stored in the preferences for a particular profile.
21 struct SessionStartupPref {
22 enum Type {
23 // Indicates the user wants to open the New Tab page.
24 DEFAULT,
26 // Deprecated. See comment in session_startup_pref.cc
27 HOMEPAGE,
29 // Indicates the user wants to restore the last session.
30 LAST,
32 // Indicates the user wants to restore a specific set of URLs. The URLs
33 // are contained in urls.
34 URLS,
36 // Number of values in this enum.
37 TYPE_COUNT
40 // For historical reasons the enum and value registered in the prefs don't
41 // line up. These are the values registered in prefs.
42 // The values are also recorded in Settings.StartupPageLoadSettings histogram,
43 // so make sure to update histograms.xml if you change these.
44 static const int kPrefValueHomePage = 0; // Deprecated
45 static const int kPrefValueLast = 1;
46 static const int kPrefValueURLs = 4;
47 static const int kPrefValueNewTab = 5;
48 static const int kPrefValueMax = 6;
50 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
52 // Returns the default value for |type|.
53 static Type GetDefaultStartupType();
55 // What should happen on startup for the specified profile.
56 static void SetStartupPref(Profile* profile, const SessionStartupPref& pref);
57 static void SetStartupPref(PrefService* prefs,
58 const SessionStartupPref& pref);
59 static SessionStartupPref GetStartupPref(Profile* profile);
60 static SessionStartupPref GetStartupPref(PrefService* prefs);
62 // If the user had the "restore on startup" property set to the deprecated
63 // "Open the home page" value, this migrates them to a value that will have
64 // the same effect.
65 static void MigrateIfNecessary(PrefService* prefs);
67 // The default startup pref for Mac used to be LAST, now it's DEFAULT. This
68 // migrates old users by writing out the preference explicitly.
69 static void MigrateMacDefaultPrefIfNecessary(PrefService* prefs);
71 // Whether the startup type and URLs are managed via policy.
72 static bool TypeIsManaged(PrefService* prefs);
73 static bool URLsAreManaged(PrefService* prefs);
75 // Whether the startup type has not been overridden from its default.
76 static bool TypeIsDefault(PrefService* prefs);
78 // Converts an integer pref value to a SessionStartupPref::Type.
79 static SessionStartupPref::Type PrefValueToType(int pref_value);
81 explicit SessionStartupPref(Type type);
83 ~SessionStartupPref();
85 // What to do on startup.
86 Type type;
88 // The URLs to restore. Only used if type == URLS.
89 std::vector<GURL> urls;
92 #endif // CHROME_BROWSER_PREFS_SESSION_STARTUP_PREF_H__