Chromium Code Reviews| 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" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 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. |
| 36 virtual StartupTabs GetResetTriggerTabs(Profile* profile) const = 0; | 36 virtual StartupTabs GetResetTriggerTabs(Profile* profile) const = 0; |
| 37 | 37 |
| 38 // Returns the user's pinned tabs. | 38 // Returns the user's pinned tabs, if they should be shown. |
| 39 virtual StartupTabs GetPinnedTabs(Profile* profile) const = 0; | 39 virtual StartupTabs GetPinnedTabs(const base::CommandLine& command_line, |
| 40 Profile* profile) const = 0; | |
| 40 | 41 |
| 41 // Returns tabs, if any, specified in the user's preferences as the default | 42 // Returns tabs, if any, specified in the user's preferences as the default |
| 42 // content for a new window. | 43 // content for a new window. |
| 43 virtual StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, | 44 virtual StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, |
| 44 Profile* profile) const = 0; | 45 Profile* profile) const = 0; |
| 46 | |
| 47 // Possibly returns the New Tab Page, if the user's preferences indicate a | |
|
Peter Kasting
2016/10/31 19:24:06
Nit: No need for "Possibly"
tmartino
2016/11/02 16:34:00
Done
| |
| 48 // configuration where it must be passed explicitly. | |
| 49 virtual StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, | |
| 50 Profile* profile) const = 0; | |
| 45 }; | 51 }; |
| 46 | 52 |
| 47 class StartupTabProviderImpl : public StartupTabProvider { | 53 class StartupTabProviderImpl : public StartupTabProvider { |
| 48 public: | 54 public: |
| 49 StartupTabProviderImpl() = default; | 55 StartupTabProviderImpl() = default; |
| 50 | 56 |
| 51 // The static Check*TabPolicy methods below enforce the policies relevant to | 57 // The static Check*TabPolicy methods below enforce the policies relevant to |
| 52 // 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 |
| 53 // system state relating to making those policy decisions. | 59 // system state relating to making those policy decisions. |
| 54 | 60 |
| 55 // Determines which tabs which should be shown according to onboarding/first | 61 // Determines which tabs which should be shown according to onboarding/first |
| 56 // run policy. | 62 // run policy. |
| 57 static StartupTabs CheckStandardOnboardingTabPolicy(bool is_first_run); | 63 static StartupTabs CheckStandardOnboardingTabPolicy(bool is_first_run); |
| 58 | 64 |
| 59 // Processes first run URLs specified in Master Preferences file, replacing | 65 // Processes first run URLs specified in Master Preferences file, replacing |
| 60 // any "magic word" URL hosts with appropriate URLs. | 66 // any "magic word" URL hosts with appropriate URLs. |
| 61 static StartupTabs CheckMasterPrefsTabPolicy( | 67 static StartupTabs CheckMasterPrefsTabPolicy( |
| 62 bool is_first_run, | 68 bool is_first_run, |
| 63 const std::vector<GURL>& first_run_tabs); | 69 const std::vector<GURL>& first_run_tabs); |
| 64 | 70 |
| 65 // Determines which tabs should be shown as a result of the presence/absence | 71 // Determines which tabs should be shown as a result of the presence/absence |
| 66 // of a Reset Trigger on this profile. | 72 // of a Reset Trigger on this profile. |
| 67 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); | 73 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger); |
| 68 | 74 |
| 75 // Determines whether the startup preference requires the contents of | |
| 76 // |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. | |
| 78 static StartupTabs CheckPinnedTabPolicy(const SessionStartupPref& pref, | |
| 79 const StartupTabs& pinned_tabs); | |
| 80 | |
| 69 // Determines whether preferences indicate that user-specified tabs should be | 81 // Determines whether preferences indicate that user-specified tabs should be |
| 70 // shown as the default new window content, and returns the specified tabs if | 82 // shown as the default new window content, and returns the specified tabs if |
| 71 // so. | 83 // so. |
| 72 static StartupTabs CheckPreferencesTabPolicy(SessionStartupPref pref); | 84 static StartupTabs CheckPreferencesTabPolicy(const SessionStartupPref& pref); |
| 85 | |
| 86 // Determines whether startup preferences require the New Tab Page to be | |
| 87 // explicitly specified. Session Restore does not expect the NTP to be passed. | |
| 88 static StartupTabs CheckNewTabPageTabPolicy(const SessionStartupPref& pref); | |
| 73 | 89 |
| 74 // Gets the URL for the "Welcome to Chrome" page. | 90 // Gets the URL for the "Welcome to Chrome" page. |
| 75 static GURL GetWelcomePageUrl(); | 91 static GURL GetWelcomePageUrl(); |
| 76 | 92 |
| 77 // Gets the URL for the page which offers to reset the user's profile | 93 // Gets the URL for the page which offers to reset the user's profile |
| 78 // settings. | 94 // settings. |
| 79 static GURL GetTriggeredResetSettingsUrl(); | 95 static GURL GetTriggeredResetSettingsUrl(); |
| 80 | 96 |
| 81 // StartupTabProvider: | 97 // StartupTabProvider: |
| 82 StartupTabs GetOnboardingTabs() const override; | 98 StartupTabs GetOnboardingTabs() const override; |
| 83 StartupTabs GetDistributionFirstRunTabs( | 99 StartupTabs GetDistributionFirstRunTabs( |
| 84 StartupBrowserCreator* browser_creator) const override; | 100 StartupBrowserCreator* browser_creator) const override; |
| 85 StartupTabs GetResetTriggerTabs(Profile* profile) const override; | 101 StartupTabs GetResetTriggerTabs(Profile* profile) const override; |
| 86 StartupTabs GetPinnedTabs(Profile* profile) const override; | 102 StartupTabs GetPinnedTabs(const base::CommandLine& command_line, |
| 103 Profile* profile) const override; | |
| 87 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, | 104 StartupTabs GetPreferencesTabs(const base::CommandLine& command_line, |
| 88 Profile* profile) const override; | 105 Profile* profile) const override; |
| 106 StartupTabs GetNewTabPageTabs(const base::CommandLine& command_line, | |
| 107 Profile* profile) const override; | |
| 89 | 108 |
| 90 private: | 109 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); | 110 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); |
| 92 }; | 111 }; |
| 93 | 112 |
| 94 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | 113 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
| OLD | NEW |