Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / signin / signin_promo.h
blob87c21de43caebf2b1c5105646b74ab50ad40b7a5
1 // Copyright 2013 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_SIGNIN_SIGNIN_PROMO_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_
8 #include <string>
10 #include "base/basictypes.h"
12 class GURL;
13 class Profile;
15 namespace user_prefs {
16 class PrefRegistrySyncable;
19 // Utility functions for sign in promos.
20 namespace signin {
22 enum Source {
23 SOURCE_START_PAGE = 0, // This must be first.
24 SOURCE_NTP_LINK,
25 SOURCE_MENU,
26 SOURCE_SETTINGS,
27 SOURCE_EXTENSION_INSTALL_BUBBLE,
28 SOURCE_WEBSTORE_INSTALL,
29 SOURCE_APP_LAUNCHER,
30 SOURCE_APPS_PAGE_LINK,
31 SOURCE_BOOKMARK_BUBBLE,
32 SOURCE_AVATAR_BUBBLE_SIGN_IN,
33 SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
34 SOURCE_UNKNOWN, // This must be last.
37 // Returns true if the sign in promo should be visible.
38 // |profile| is the profile of the tab the promo would be shown on.
39 bool ShouldShowPromo(Profile* profile);
41 // Returns true if we should show the sign in promo at startup.
42 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile);
44 // Called when the sign in promo has been shown so that we can keep track
45 // of the number of times we've displayed it.
46 void DidShowPromoAtStartup(Profile* profile);
48 // Registers the fact that the user has skipped the sign in promo.
49 void SetUserSkippedPromo(Profile* profile);
51 // Gets the sign in landing page URL.
52 GURL GetLandingURL(const char* option, int value);
54 // Returns the sign in promo URL wth the given arguments in the query.
55 // |source| identifies from where the sign in promo is being called, and is
56 // used to record sync promo UMA stats in the context of the source.
57 // |auto_close| whether to close the sign in promo automatically when done.
58 // |is_constrained} whether to load the URL in a constrained window, false
59 // by default.
60 GURL GetPromoURL(Source source, bool auto_close);
61 GURL GetPromoURL(Source source, bool auto_close, bool is_constrained);
63 // Gets the next page URL from the query portion of the sign in promo URL.
64 GURL GetNextPageURLForPromoURL(const GURL& url);
66 // Gets the source from the query portion of the sign in promo URL.
67 // The source identifies from where the sign in promo was opened.
68 Source GetSourceForPromoURL(const GURL& url);
70 // Returns true if the auto_close parameter in the given URL is set to true.
71 bool IsAutoCloseEnabledInURL(const GURL& url);
73 // Returns true if the given URL is the standard continue URL used with the
74 // sync promo when the web-based flow is enabled. The query parameters
75 // of the URL are ignored for this comparison.
76 bool IsContinueUrlForWebBasedSigninFlow(const GURL& url);
78 // Forces UseWebBasedSigninFlow() to return true when set; used in tests only.
79 void ForceWebBasedSigninFlowForTesting(bool force);
81 // Registers the preferences the Sign In Promo needs.
82 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
84 } // namespace signin
86 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_PROMO_H_