Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: chrome/browser/ui/startup/startup_tab_provider.h

Issue 2164033002: Refactoring startup logic for upcoming FRE changes (non-Win 10). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempting submission Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_
6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_
7
8 #include <vector>
9
10 #include "base/gtest_prod_util.h"
11 #include "chrome/browser/first_run/first_run.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/startup/startup_browser_creator.h"
14 #include "chrome/browser/ui/startup/startup_tab.h"
15 #include "url/gurl.h"
16
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
19 // be shown for first run/onboarding?" Provided as a virtual interface to allow
20 // faking in unit tests.
21 class StartupTabProvider {
22 public:
23 // Gathers relevant system state and returns any tabs which should be
24 // shown according to onboarding/first run policy.
25 virtual StartupTabs GetOnboardingTabs() const = 0;
26
27 // Gathers URLs from a Master Preferences file indicating first run logic
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
30 // BrowserCreator.
31 virtual StartupTabs GetDistributionFirstRunTabs(
32 StartupBrowserCreator* browser_creator) const = 0;
33
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.
36 virtual StartupTabs GetResetTriggerTabs(Profile* profile) const = 0;
37
38 // Returns the user's pinned tabs.
39 virtual StartupTabs GetPinnedTabs() const = 0;
40
41 // Returns tabs, if any, specified in the user's preferences as the default
42 // content for a new window.
43 virtual StartupTabs GetPreferencesTabs() const = 0;
44 };
45
46 class StartupTabProviderImpl : public StartupTabProvider {
47 public:
48 StartupTabProviderImpl() = default;
49
50 // The static Check*TabPolicy methods below enforce the policies relevant to
51 // the respective Get*Tabs methods, but do not gather or interact with any
52 // system state relating to making those policy decisions.
53
54 // Determines which tabs which should be shown according to onboarding/first
55 // run policy.
56 static StartupTabs CheckStandardOnboardingTabPolicy(bool is_first_run);
57
58 // Processes first run URLs specified in Master Preferences file, replacing
59 // any "magic word" URL hosts with appropriate URLs.
60 static StartupTabs CheckMasterPrefsTabPolicy(
61 bool is_first_run,
62 const std::vector<GURL>& first_run_tabs);
63
64 // Determines which tabs should be shown as a result of the presence/absence
65 // of a Reset Trigger on this profile.
66 static StartupTabs CheckResetTriggerTabPolicy(bool profile_has_trigger);
67
68 // Gets the URL for the "Welcome to Chrome" page.
69 static GURL GetWelcomePageUrl();
70
71 // Gets the URL for the page which offers to reset the user's profile
72 // settings.
73 static GURL GetTriggeredResetSettingsUrl();
74
75 // StartupTabProvider:
76 StartupTabs GetOnboardingTabs() const override;
77 StartupTabs GetDistributionFirstRunTabs(
78 StartupBrowserCreator* browser_creator) const override;
79 StartupTabs GetResetTriggerTabs(Profile* profile) const override;
80 StartupTabs GetPinnedTabs() const override;
81 StartupTabs GetPreferencesTabs() const override;
82
83 private:
84 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl);
85 };
86
87 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698