Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_tab_provider.h |
| diff --git a/chrome/browser/ui/startup/startup_tab_provider.h b/chrome/browser/ui/startup/startup_tab_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..594e0d9fb783feaabf6b8c82e91c88bec000ed61 |
| --- /dev/null |
| +++ b/chrome/browser/ui/startup/startup_tab_provider.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
| +#define CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "chrome/browser/first_run/first_run.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/startup/startup_browser_creator.h" |
| +#include "chrome/browser/ui/startup/startup_tab.h" |
| +#include "url/gurl.h" |
| + |
| +// Provides the sets of tabs to be shown at startup for given sets of policy. |
| +// For instance, this class answers the question, "which tabs, if any, need to |
| +// 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
|
| +class StartupTabProvider { |
| + public: |
| + StartupTabProvider() = default; |
| + virtual ~StartupTabProvider() = default; |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Not sure if we have a policy on how to handle
|
| + |
| + // Determines which tabs which should be shown according to onboarding/first |
| + // run policy, and appends them to |tabs|. Returns true iff any tabs were |
| + // added. |
| + 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
|
| + |
| + // Gathers tabs from a Master Preferences file indicating first run logic |
| + // specific to this distribution, and appends them to |tabs|. Also clears |
| + // 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
|
| + // iff any tabs were added. |
| + virtual bool AddDistributionFirstRunTabs( |
| + StartupBrowserCreator* browser_creator, |
| + StartupTabs* tabs) const = 0; |
| + |
| + // Determines which tabs should be shown as a result of a Reset Trigger |
| + // present on this profile, and appends them to |tabs|. Returns true iff any |
| + // tabs were added. |
| + 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
|
| + StartupTabs* tabs) const = 0; |
| + |
| + // 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
|
| + // Returns true iff any tabs were added. |
| + virtual bool AddPinnedTabs(StartupTabs* tabs) const = 0; |
| + |
| + // 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
|
| + // appends them to |tabs|. Returns true iff any tabs were added. |
| + virtual bool AddPreferencesTabs(StartupTabs* tabs) const = 0; |
| +}; |
| + |
| +class StartupTabProviderImpl : public StartupTabProvider { |
| + public: |
| + StartupTabProviderImpl() = default; |
| + bool AddOnboardingTabs(StartupTabs* tabs) const override; |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Common practice is to do something like:
S
|
| + bool AddDistributionFirstRunTabs(StartupBrowserCreator* browser_creator, |
| + StartupTabs* tabs) const override; |
| + bool AddResetTriggerTabs(Profile* profile, StartupTabs* tabs) const override; |
| + bool AddPinnedTabs(StartupTabs* tabs) const override; |
| + bool AddPreferencesTabs(StartupTabs* tabs) const override; |
| + |
| + static bool CheckStandardOnboardingTabPolicy(bool is_first_run, |
|
Peter Kasting
2016/09/29 07:23:35
Nit: What do these functions do? Add comments.
|
| + StartupTabs* tabs); |
| + static bool CheckMasterPrefsTabPolicy(bool is_first_run, |
| + const std::vector<GURL>& first_run_tabs, |
| + StartupTabs* tabs); |
| + static bool CheckResetTriggerTabPolicy(bool profile_has_trigger, |
| + StartupTabs* tabs); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(StartupTabProviderImpl); |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Technically, now that this uses =delete, it i
|
| +}; |
| + |
| +// Gets the URL for the "Welcome to Chrome" dialog. |
| +// TODO(tmartino): Update to return new Welcome page when complete. |
| +GURL GetWelcomePageUrl(); |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Never been a big fan of globals. Would it ma
|
| +GURL GetTriggeredResetSettingsUrl(); |
|
Peter Kasting
2016/09/29 07:23:35
Nit: Blank line + comment above this? I don't kno
|
| + |
| +#endif // CHROME_BROWSER_UI_STARTUP_STARTUP_TAB_PROVIDER_H_ |