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