Chromium Code Reviews| OLD | NEW |
|---|---|
| (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?" | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: May want to note why this class is pure virtu
| |
| 20 class StartupTabProvider { | |
| 21 public: | |
| 22 StartupTabProvider() = default; | |
| 23 virtual ~StartupTabProvider() = default; | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Not sure if we have a policy on how to handle
| |
| 24 | |
| 25 // Determines which tabs which should be shown according to onboarding/first | |
| 26 // run policy, and appends them to |tabs|. Returns true iff any tabs were | |
| 27 // added. | |
| 28 virtual bool AddOnboardingTabs(StartupTabs* tabs) const = 0; | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: I feel like this class' API might be clearer
tmartino
2016/09/30 20:55:02
I actually had implemented it that way several rev
Peter Kasting
2016/09/30 21:50:03
IMO, this is a non-issue. You're not working with
tmartino
2016/10/03 23:26:06
OK, switched back to the Getter pattern. I think I
| |
| 29 | |
| 30 // Gathers tabs from a Master Preferences file indicating first run logic | |
| 31 // specific to this distribution, and appends them to |tabs|. Also clears | |
| 32 // the value of first_run_urls_ in the provided BrowserCreator. Returns true | |
|
Peter Kasting
2016/09/29 07:23:35
Hmm, should clearing the |browser_creator|'s membe
tmartino
2016/09/30 20:55:02
I was torn on this one as well, but in the end the
Peter Kasting
2016/09/30 21:50:03
I kinda think clearing the first run URLs shouldn'
tmartino
2016/10/03 23:26:06
Do you have a good suggestion for the "something s
Peter Kasting
2016/10/06 05:49:08
I do not -- not very familiar with startup.
I thi
tmartino
2016/10/06 18:27:28
crbug.com/653590
| |
| 33 // iff any tabs were added. | |
| 34 virtual bool AddDistributionFirstRunTabs( | |
| 35 StartupBrowserCreator* browser_creator, | |
| 36 StartupTabs* tabs) const = 0; | |
| 37 | |
| 38 // Determines which tabs should be shown as a result of a Reset Trigger | |
| 39 // present on this profile, and appends them to |tabs|. Returns true iff any | |
| 40 // tabs were added. | |
| 41 virtual bool AddResetTriggerTabs(Profile* profile, | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Can |profile| be const?
tmartino
2016/09/30 20:55:02
Nope. TriggeredProfileResetterFactory::GetForBrows
| |
| 42 StartupTabs* tabs) const = 0; | |
| 43 | |
| 44 // Reads tabs from the user's pinned tabs, and appends them to |tabs|. | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Second place you've talked about "reading fro
| |
| 45 // Returns true iff any tabs were added. | |
| 46 virtual bool AddPinnedTabs(StartupTabs* tabs) const = 0; | |
| 47 | |
| 48 // Reads tabs specified for new windows from the user's preferences, and | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: What is a "tab specified for [a] new window"?
tmartino
2016/09/30 20:55:02
Done. In this case I've retained the "reads" phras
| |
| 49 // appends them to |tabs|. Returns true iff any tabs were added. | |
| 50 virtual bool AddPreferencesTabs(StartupTabs* tabs) const = 0; | |
| 51 }; | |
| 52 | |
| 53 class StartupTabProviderImpl : public StartupTabProvider { | |
| 54 public: | |
| 55 StartupTabProviderImpl() = default; | |
| 56 bool AddOnboardingTabs(StartupTabs* tabs) const override; | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Common practice is to do something like:
S
| |
| 57 bool AddDistributionFirstRunTabs(StartupBrowserCreator* browser_creator, | |
| 58 StartupTabs* tabs) const override; | |
| 59 bool AddResetTriggerTabs(Profile* profile, StartupTabs* tabs) const override; | |
| 60 bool AddPinnedTabs(StartupTabs* tabs) const override; | |
| 61 bool AddPreferencesTabs(StartupTabs* tabs) const override; | |
| 62 | |
| 63 static bool CheckStandardOnboardingTabPolicy(bool is_first_run, | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: What do these functions do? Add comments.
| |
| 64 StartupTabs* tabs); | |
| 65 static bool CheckMasterPrefsTabPolicy(bool is_first_run, | |
| 66 const std::vector<GURL>& first_run_tabs, | |
| 67 StartupTabs* tabs); | |
| 68 static bool CheckResetTriggerTabPolicy(bool profile_has_trigger, | |
| 69 StartupTabs* tabs); | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Technically, now that this uses =delete, it i
| |
| 72 }; | |
| 73 | |
| 74 // Gets the URL for the "Welcome to Chrome" dialog. | |
| 75 // TODO(tmartino): Update to return new Welcome page when complete. | |
| 76 GURL GetWelcomePageUrl(); | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Never been a big fan of globals. Would it ma
| |
| 77 GURL GetTriggeredResetSettingsUrl(); | |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Blank line + comment above this? I don't kno
| |
| 78 | |
| 79 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ | |
| OLD | NEW |