| 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 17 matching lines...) Expand all Loading... |
| 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. |
| 63 static StartupTabs CheckStandardOnboardingTabPolicy(bool is_first_run); | 63 static StartupTabs CheckStandardOnboardingTabPolicy( |
| 64 bool is_first_run, |
| 65 bool has_seen_welcome_page, |
| 66 bool is_signed_in); |
| 64 | 67 |
| 65 // Processes first run URLs specified in Master Preferences file, replacing | 68 // Processes first run URLs specified in Master Preferences file, replacing |
| 66 // any "magic word" URL hosts with appropriate URLs. | 69 // any "magic word" URL hosts with appropriate URLs. |
| 67 static StartupTabs CheckMasterPrefsTabPolicy( | 70 static StartupTabs CheckMasterPrefsTabPolicy( |
| 68 bool is_first_run, | 71 bool is_first_run, |
| 69 const std::vector<GURL>& first_run_tabs); | 72 const std::vector<GURL>& first_run_tabs); |
| 70 | 73 |
| 71 // Determines which tabs should be shown as a result of the presence/absence | 74 // Determines which tabs should be shown as a result of the presence/absence |
| 72 // of a Reset Trigger on this profile. | 75 // of a Reset Trigger on this profile. |
| 73 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); | 76 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); |
| 74 | 77 |
| 75 // Determines whether the startup preference requires the contents of | 78 // Determines whether the startup preference requires the contents of |
| 76 // |pinned_tabs| to be shown. This is needed to avoid duplicates, as the | 79 // |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. | 80 // session restore logic will also resurface pinned tabs on its own. |
| 78 static StartupTabs CheckPinnedTabPolicy(const SessionStartupPref& pref, | 81 static StartupTabs CheckPinnedTabPolicy(const SessionStartupPref& pref, |
| 79 const StartupTabs& pinned_tabs); | 82 const StartupTabs& pinned_tabs); |
| 80 | 83 |
| 81 // Determines whether preferences indicate that user-specified tabs should be | 84 // Determines whether preferences indicate that user-specified tabs should be |
| 82 // shown as the default new window content, and returns the specified tabs if | 85 // shown as the default new window content, and returns the specified tabs if |
| 83 // so. | 86 // so. |
| 84 static StartupTabs CheckPreferencesTabPolicy(const SessionStartupPref& pref); | 87 static StartupTabs CheckPreferencesTabPolicy(const SessionStartupPref& pref); |
| 85 | 88 |
| 86 // Determines whether startup preferences require the New Tab Page to be | 89 // Determines whether startup preferences require the New Tab Page to be |
| 87 // explicitly specified. Session Restore does not expect the NTP to be passed. | 90 // explicitly specified. Session Restore does not expect the NTP to be passed. |
| 88 static StartupTabs CheckNewTabPageTabPolicy(const SessionStartupPref& pref); | 91 static StartupTabs CheckNewTabPageTabPolicy(const SessionStartupPref& pref); |
| 89 | 92 |
| 90 // Gets the URL for the "Welcome to Chrome" page. | 93 // Gets the URL for the Welcome page. If |use_later_run_variant| is true, a |
| 91 static GURL GetWelcomePageUrl(); | 94 // URL parameter will be appended so as to access the variant page used when |
| 95 // onboarding occurs after the first Chrome execution (e.g., when creating an |
| 96 // additional profile). |
| 97 static GURL GetWelcomePageUrl(bool use_later_run_variant); |
| 92 | 98 |
| 93 // Gets the URL for the page which offers to reset the user's profile | 99 // Gets the URL for the page which offers to reset the user's profile |
| 94 // settings. | 100 // settings. |
| 95 static GURL GetTriggeredResetSettingsUrl(); | 101 static GURL GetTriggeredResetSettingsUrl(); |
| 96 | 102 |
| 97 // StartupTabProvider: | 103 // StartupTabProvider: |
| 98 StartupTabs GetOnboardingTabs() const override; | 104 StartupTabs GetOnboardingTabs(Profile* profile) const override; |
| 99 StartupTabs GetDistributionFirstRunTabs( | 105 StartupTabs GetDistributionFirstRunTabs( |
| 100 StartupBrowserCreator* browser_creator) const override; | 106 StartupBrowserCreator* browser_creator) const override; |
| 101 StartupTabs GetResetTriggerTabs(Profile* profile) const override; | 107 StartupTabs GetResetTriggerTabs(Profile* profile) const override; |
| 102 StartupTabs GetPinnedTabs(const base::CommandLine& command_line, | 108 StartupTabs GetPinnedTabs(const base::CommandLine& command_line, |
| 103 Profile* profile) const override; | 109 Profile* profile) const override; |
| 104 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, | 110 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, |
| 105 Profile* profile) const override; | 111 Profile* profile) const override; |
| 106 StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, | 112 StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, |
| 107 Profile* profile) const override; | 113 Profile* profile) const override; |
| 108 | 114 |
| 109 private: | 115 private: |
| 110 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); | 116 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); |
| 111 }; | 117 }; |
| 112 | 118 |
| 113 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | 119 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
| OLD | NEW |