OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "chrome/browser/first_run/first_run.h" | 11 #include "chrome/browser/first_run/first_run.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 13 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
14 #include "chrome/browser/ui/startup/startup_tab.h" | 14 #include "chrome/browser/ui/startup/startup_tab.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 // Provides the sets of tabs to be shown at startup for given sets of policy. | 17 // Provides the sets of tabs to be shown at startup for given sets of policy. |
18 // For instance, this class answers the question, "which tabs, if any, need to | 18 // For instance, this class answers the question, "which tabs, if any, need to |
19 // be shown for first run/onboarding?" Provided as a virtual interface to allow | 19 // be shown for first run/onboarding?" Provided as a virtual interface to allow |
20 // faking in unit tests. | 20 // faking in unit tests. |
21 class StartupTabProvider { | 21 class StartupTabProvider { |
22 public: | 22 public: |
23 // Gathers relevant system state and returns any tabs which should be | 23 // Gathers relevant system state and returns any tabs which should be |
24 // shown according to onboarding/first run policy. | 24 // shown according to onboarding/first run policy. |
25 virtual StartupTabs GetOnboardingTabs() const = 0; | 25 virtual StartupTabs GetOnboardingTabs(Profile* profile) const = 0; |
26 | 26 |
27 // Gathers URLs from a Master Preferences file indicating first run logic | 27 // Gathers URLs from a Master Preferences file indicating first run logic |
28 // specific to this distribution. Transforms any such URLs per policy and | 28 // specific to this distribution. Transforms any such URLs per policy and |
29 // returns them. Also clears the value of first_run_urls_ in the provided | 29 // returns them. Also clears the value of first_run_urls_ in the provided |
30 // BrowserCreator. | 30 // BrowserCreator. |
31 virtual StartupTabs GetDistributionFirstRunTabs( | 31 virtual StartupTabs GetDistributionFirstRunTabs( |
32 StartupBrowserCreator* browser_creator) const = 0; | 32 StartupBrowserCreator* browser_creator) const = 0; |
33 | 33 |
34 // Checks for the presence of a trigger indicating the need to offer a Profile | 34 // Checks for the presence of a trigger indicating the need to offer a Profile |
35 // Reset on this profile. Returns any tabs which should be shown accordingly. | 35 // Reset on this profile. Returns any tabs which should be shown accordingly. |
(...skipping 16 matching lines...) Expand all Loading... | |
52 | 52 |
53 class StartupTabProviderImpl : public StartupTabProvider { | 53 class StartupTabProviderImpl : public StartupTabProvider { |
54 public: | 54 public: |
55 StartupTabProviderImpl() = default; | 55 StartupTabProviderImpl() = default; |
56 | 56 |
57 // The static Check*TabPolicy methods below enforce the policies relevant to | 57 // The static Check*TabPolicy methods below enforce the policies relevant to |
58 // the respective Get*Tabs methods, but do not gather or interact with any | 58 // the respective Get*Tabs methods, but do not gather or interact with any |
59 // system state relating to making those policy decisions. | 59 // system state relating to making those policy decisions. |
60 | 60 |
61 // Determines which tabs which should be shown according to onboarding/first | 61 // Determines which tabs which should be shown according to onboarding/first |
62 // run policy. | 62 // run policy. |
Peter Kasting
2016/11/10 05:26:43
Nit: Improve documentation of parameters; in parti
tmartino
2016/11/15 00:16:30
This will be obsolete pending changes from the oth
| |
63 static StartupTabs CheckStandardOnboardingTabPolicy(bool is_first_run); | 63 static StartupTabs CheckStandardOnboardingTabPolicy( |
64 bool is_first_run, | |
65 bool has_seen_welcome, | |
66 bool is_signed_in, | |
67 bool created_after_welcome_ui); | |
64 | 68 |
65 // Processes first run URLs specified in Master Preferences file, replacing | 69 // Processes first run URLs specified in Master Preferences file, replacing |
66 // any "magic word" URL hosts with appropriate URLs. | 70 // any "magic word" URL hosts with appropriate URLs. |
67 static StartupTabs CheckMasterPrefsTabPolicy( | 71 static StartupTabs CheckMasterPrefsTabPolicy( |
68 bool is_first_run, | 72 bool is_first_run, |
69 const std::vector<GURL>& first_run_tabs); | 73 const std::vector<GURL>& first_run_tabs); |
70 | 74 |
71 // Determines which tabs should be shown as a result of the presence/absence | 75 // Determines which tabs should be shown as a result of the presence/absence |
72 // of a Reset Trigger on this profile. | 76 // of a Reset Trigger on this profile. |
73 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); | 77 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); |
74 | 78 |
75 // Determines whether the startup preference requires the contents of | 79 // Determines whether the startup preference requires the contents of |
76 // |pinned_tabs| to be shown. This is needed to avoid duplicates, as the | 80 // |pinned_tabs| to be shown. This is needed to avoid duplicates, as the |
77 // session restore logic will also resurface pinned tabs on its own. | 81 // session restore logic will also resurface pinned tabs on its own. |
78 static StartupTabs CheckPinnedTabPolicy(const SessionStartupPref& pref, | 82 static StartupTabs CheckPinnedTabPolicy(const SessionStartupPref& pref, |
79 const StartupTabs& pinned_tabs); | 83 const StartupTabs& pinned_tabs); |
80 | 84 |
81 // Determines whether preferences indicate that user-specified tabs should be | 85 // Determines whether preferences indicate that user-specified tabs should be |
82 // shown as the default new window content, and returns the specified tabs if | 86 // shown as the default new window content, and returns the specified tabs if |
83 // so. | 87 // so. |
84 static StartupTabs CheckPreferencesTabPolicy(const SessionStartupPref& pref); | 88 static StartupTabs CheckPreferencesTabPolicy(const SessionStartupPref& pref); |
85 | 89 |
86 // Determines whether startup preferences require the New Tab Page to be | 90 // Determines whether startup preferences require the New Tab Page to be |
87 // explicitly specified. Session Restore does not expect the NTP to be passed. | 91 // explicitly specified. Session Restore does not expect the NTP to be passed. |
88 static StartupTabs CheckNewTabPageTabPolicy(const SessionStartupPref& pref); | 92 static StartupTabs CheckNewTabPageTabPolicy(const SessionStartupPref& pref); |
89 | 93 |
90 // Gets the URL for the "Welcome to Chrome" page. | 94 // Gets the URL for the "Welcome to Chrome" page. |
Peter Kasting
2016/11/10 05:26:43
Nit: Update to document the meaning of the paramet
tmartino
2016/11/15 00:16:30
Done.
| |
91 static GURL GetWelcomePageUrl(); | 95 static GURL GetWelcomePageUrl(bool use_later_run_variant); |
92 | 96 |
93 // Gets the URL for the page which offers to reset the user's profile | 97 // Gets the URL for the page which offers to reset the user's profile |
94 // settings. | 98 // settings. |
95 static GURL GetTriggeredResetSettingsUrl(); | 99 static GURL GetTriggeredResetSettingsUrl(); |
96 | 100 |
97 // StartupTabProvider: | 101 // StartupTabProvider: |
98 StartupTabs GetOnboardingTabs() const override; | 102 StartupTabs GetOnboardingTabs(Profile* profile) const override; |
99 StartupTabs GetDistributionFirstRunTabs( | 103 StartupTabs GetDistributionFirstRunTabs( |
100 StartupBrowserCreator* browser_creator) const override; | 104 StartupBrowserCreator* browser_creator) const override; |
101 StartupTabs GetResetTriggerTabs(Profile* profile) const override; | 105 StartupTabs GetResetTriggerTabs(Profile* profile) const override; |
102 StartupTabs GetPinnedTabs(const base::CommandLine& command_line, | 106 StartupTabs GetPinnedTabs(const base::CommandLine& command_line, |
103 Profile* profile) const override; | 107 Profile* profile) const override; |
104 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, | 108 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, |
105 Profile* profile) const override; | 109 Profile* profile) const override; |
106 StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, | 110 StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, |
107 Profile* profile) const override; | 111 Profile* profile) const override; |
108 | 112 |
109 private: | 113 private: |
110 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); | 114 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); |
111 }; | 115 }; |
112 | 116 |
113 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | 117 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
OLD | NEW |