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

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

Issue 2457653003: Completing refactor of startup_browser_creator_impl (Closed)
Patch Set: Addressing pkasting comments Created 4 years, 1 month 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
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 #include "chrome/browser/ui/startup/startup_tab_provider.h" 5 #include "chrome/browser/ui/startup/startup_tab_provider.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/first_run/first_run.h" 8 #include "chrome/browser/first_run/first_run.h"
9 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" 9 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h"
10 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" 10 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 StartupTabs StartupTabProviderImpl::GetResetTriggerTabs( 47 StartupTabs StartupTabProviderImpl::GetResetTriggerTabs(
48 Profile* profile) const { 48 Profile* profile) const {
49 auto* triggered_profile_resetter = 49 auto* triggered_profile_resetter =
50 TriggeredProfileResetterFactory::GetForBrowserContext(profile); 50 TriggeredProfileResetterFactory::GetForBrowserContext(profile);
51 bool has_reset_trigger = triggered_profile_resetter && 51 bool has_reset_trigger = triggered_profile_resetter &&
52 triggered_profile_resetter->HasResetTrigger(); 52 triggered_profile_resetter->HasResetTrigger();
53 return CheckResetTriggerTabPolicy(has_reset_trigger); 53 return CheckResetTriggerTabPolicy(has_reset_trigger);
54 } 54 }
55 55
56 StartupTabs StartupTabProviderImpl::GetPinnedTabs(Profile* profile) const { 56 StartupTabs StartupTabProviderImpl::GetPinnedTabs(
57 return PinnedTabCodec::ReadPinnedTabs(profile); 57 const base::CommandLine& command_line,
58 Profile* profile) const {
59 return CheckPinnedTabPolicy(
60 StartupBrowserCreator::GetSessionStartupPref(command_line, profile),
61 PinnedTabCodec::ReadPinnedTabs(profile));
58 } 62 }
59 63
60 StartupTabs StartupTabProviderImpl::GetPreferencesTabs( 64 StartupTabs StartupTabProviderImpl::GetPreferencesTabs(
61 const base::CommandLine& command_line, 65 const base::CommandLine& command_line,
62 Profile* profile) const { 66 Profile* profile) const {
63 return CheckPreferencesTabPolicy( 67 return CheckPreferencesTabPolicy(
64 StartupBrowserCreator::GetSessionStartupPref(command_line, profile)); 68 StartupBrowserCreator::GetSessionStartupPref(command_line, profile));
65 } 69 }
66 70
71 StartupTabs StartupTabProviderImpl::GetNewTabPageTabs(
72 const base::CommandLine& command_line,
73 Profile* profile) const {
74 return CheckNewTabPageTabPolicy(
75 StartupBrowserCreator::GetSessionStartupPref(command_line, profile));
76 }
77
67 // static 78 // static
68 StartupTabs StartupTabProviderImpl::CheckStandardOnboardingTabPolicy( 79 StartupTabs StartupTabProviderImpl::CheckStandardOnboardingTabPolicy(
69 bool is_first_run) { 80 bool is_first_run) {
70 StartupTabs tabs; 81 StartupTabs tabs;
71 if (is_first_run) 82 if (is_first_run)
72 tabs.emplace_back(GetWelcomePageUrl(), false); 83 tabs.emplace_back(GetWelcomePageUrl(), false);
73 return tabs; 84 return tabs;
74 } 85 }
75 86
76 // static 87 // static
(...skipping 22 matching lines...) Expand all
99 // static 110 // static
100 StartupTabs StartupTabProviderImpl::CheckResetTriggerTabPolicy( 111 StartupTabs StartupTabProviderImpl::CheckResetTriggerTabPolicy(
101 bool profile_has_trigger) { 112 bool profile_has_trigger) {
102 StartupTabs tabs; 113 StartupTabs tabs;
103 if (profile_has_trigger) 114 if (profile_has_trigger)
104 tabs.emplace_back(GetTriggeredResetSettingsUrl(), false); 115 tabs.emplace_back(GetTriggeredResetSettingsUrl(), false);
105 return tabs; 116 return tabs;
106 } 117 }
107 118
108 // static 119 // static
120 StartupTabs StartupTabProviderImpl::CheckPinnedTabPolicy(
121 const SessionStartupPref& pref,
122 const StartupTabs& pinned_tabs) {
123 return (pref.type == SessionStartupPref::Type::LAST) ? StartupTabs()
124 : pinned_tabs;
125 }
126
127 // static
109 StartupTabs StartupTabProviderImpl::CheckPreferencesTabPolicy( 128 StartupTabs StartupTabProviderImpl::CheckPreferencesTabPolicy(
110 SessionStartupPref pref) { 129 const SessionStartupPref& pref) {
111 StartupTabs tabs; 130 StartupTabs tabs;
112 if (pref.type == SessionStartupPref::Type::URLS && !pref.urls.empty()) { 131 if (pref.type == SessionStartupPref::Type::URLS && !pref.urls.empty()) {
113 for (auto& url : pref.urls) 132 for (const auto& url : pref.urls)
114 tabs.push_back(StartupTab(url, false)); 133 tabs.push_back(StartupTab(url, false));
115 } 134 }
116 return tabs; 135 return tabs;
117 } 136 }
118 137
119 // static 138 // static
139 StartupTabs StartupTabProviderImpl::CheckNewTabPageTabPolicy(
140 const SessionStartupPref& pref) {
141 StartupTabs tabs;
142 if (pref.type != SessionStartupPref::Type::LAST)
143 tabs.emplace_back(GURL(chrome::kChromeUINewTabURL), false);
144 return tabs;
145 }
146
147 // static
120 GURL StartupTabProviderImpl::GetWelcomePageUrl() { 148 GURL StartupTabProviderImpl::GetWelcomePageUrl() {
121 return GURL(chrome::kChromeUIWelcomeURL); 149 return GURL(chrome::kChromeUIWelcomeURL);
122 } 150 }
123 151
124 // static 152 // static
125 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { 153 GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() {
126 return GURL( 154 return GURL(
127 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage)); 155 chrome::GetSettingsUrl(chrome::kTriggeredResetProfileSettingsSubPage));
128 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_tab_provider.h ('k') | chrome/browser/ui/startup/startup_tab_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698