OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_CREATOR_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ |
6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ |
7 | 7 |
8 #include <map> | |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "chrome/browser/prefs/session_startup_pref.h" | 15 #include "chrome/browser/prefs/session_startup_pref.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/startup/startup_tab.h" | 17 #include "chrome/browser/ui/startup/startup_tab.h" |
17 #include "chrome/browser/ui/startup/startup_types.h" | 18 #include "chrome/browser/ui/startup/startup_types.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 class Browser; | 21 class Browser; |
21 class GURL; | 22 class GURL; |
22 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
23 class PrefService; | 24 class PrefService; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class CommandLine; | 27 class CommandLine; |
27 } | 28 } |
28 | 29 |
29 // class containing helpers for BrowserMain to spin up a new instance and | 30 // class containing helpers for BrowserMain to spin up a new instance and |
30 // initialize the profile. | 31 // initialize the profile. |
31 class StartupBrowserCreator { | 32 class StartupBrowserCreator { |
32 public: | 33 public: |
33 typedef std::vector<Profile*> Profiles; | 34 typedef std::vector<Profile*> Profiles; |
35 typedef std::map<GURL, base::Callback<void(void)>> UrlFilters; | |
grt (UTC plus 2)
2015/09/22 18:21:48
base::Callback<void(void)> -> base::Closure
| |
34 | 36 |
35 StartupBrowserCreator(); | 37 StartupBrowserCreator(); |
36 ~StartupBrowserCreator(); | 38 ~StartupBrowserCreator(); |
37 | 39 |
38 // Adds a url to be opened during first run. This overrides the standard | 40 // Adds a url to be opened during first run. This overrides the standard |
39 // tabs shown at first run. | 41 // tabs shown at first run. |
40 void AddFirstRunTab(const GURL& url); | 42 void AddFirstRunTab(const GURL& url); |
41 | 43 |
42 // This function is equivalent to ProcessCommandLine but should only be | 44 // This function is equivalent to ProcessCommandLine but should only be |
43 // called during actual process startup. | 45 // called during actual process startup. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 98 |
97 bool show_main_browser_window() const { | 99 bool show_main_browser_window() const { |
98 return show_main_browser_window_; | 100 return show_main_browser_window_; |
99 } | 101 } |
100 | 102 |
101 // For faking that no profiles have been launched yet. | 103 // For faking that no profiles have been launched yet. |
102 static void ClearLaunchedProfilesForTesting(); | 104 static void ClearLaunchedProfilesForTesting(); |
103 | 105 |
104 static void RegisterLocalStatePrefs(PrefRegistrySimple* registry); | 106 static void RegisterLocalStatePrefs(PrefRegistrySimple* registry); |
105 | 107 |
108 // All the filters functions should be called on the UI thread. | |
grt (UTC plus 2)
2015/09/22 18:21:48
comment suggestion:
// Adds a filter that will e
| |
109 // Adds a new filter that will execute the |callback| when the |url| is opened | |
110 // through the command line. | |
111 static void AddUrlFilter(const GURL& url, | |
112 const base::Callback<void(void)>& callback); | |
grt (UTC plus 2)
2015/09/22 18:21:48
base::Callback<void(void)> -> base::Closure
| |
113 | |
114 // Removes the filter associated the the |url|. | |
115 static void RemoveUrlFilter(const GURL& url); | |
116 | |
117 // Returns true if at least one url filter exists. | |
grt (UTC plus 2)
2015/09/22 18:21:48
this doesn't look like it needs to be part of the
| |
118 static bool HasUrlFilters(); | |
119 | |
120 // Executes the callback associated to the |url| filter. Returns false if the | |
121 // |url| isn't associated to any filters. | |
122 static bool ExecuteFilterCallback(const GURL& url); | |
grt (UTC plus 2)
2015/09/22 18:21:48
does this need to be public?
| |
123 | |
124 // Returns true if a filter is associated to the |url|. | |
125 static bool UrlFilterExists(const GURL& url); | |
126 | |
106 private: | 127 private: |
107 friend class CloudPrintProxyPolicyTest; | 128 friend class CloudPrintProxyPolicyTest; |
108 friend class CloudPrintProxyPolicyStartupTest; | 129 friend class CloudPrintProxyPolicyStartupTest; |
109 friend class StartupBrowserCreatorImpl; | 130 friend class StartupBrowserCreatorImpl; |
110 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, | 131 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, |
111 ReadingWasRestartedAfterNormalStart); | 132 ReadingWasRestartedAfterNormalStart); |
112 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, | 133 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, |
113 ReadingWasRestartedAfterRestart); | 134 ReadingWasRestartedAfterRestart); |
114 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, UpdateWithTwoProfiles); | 135 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, UpdateWithTwoProfiles); |
115 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, LastUsedProfileActivated); | 136 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, LastUsedProfileActivated); |
(...skipping 26 matching lines...) Expand all Loading... | |
142 static void ProcessCommandLineOnProfileCreated( | 163 static void ProcessCommandLineOnProfileCreated( |
143 const base::CommandLine& command_line, | 164 const base::CommandLine& command_line, |
144 const base::FilePath& cur_dir, | 165 const base::FilePath& cur_dir, |
145 Profile* profile, | 166 Profile* profile, |
146 Profile::CreateStatus status); | 167 Profile::CreateStatus status); |
147 | 168 |
148 // Returns true once a profile was activated. Used by the | 169 // Returns true once a profile was activated. Used by the |
149 // StartupBrowserCreatorTest.LastUsedProfileActivated test. | 170 // StartupBrowserCreatorTest.LastUsedProfileActivated test. |
150 static bool ActivatedProfile(); | 171 static bool ActivatedProfile(); |
151 | 172 |
173 // Returns the map of all the url filters. This will creatE the filter if it | |
grt (UTC plus 2)
2015/09/22 18:21:47
creatE -> create
| |
174 // doesn't exist. | |
175 static UrlFilters* GetUrlFilters(); | |
176 | |
152 // Additional tabs to open during first run. | 177 // Additional tabs to open during first run. |
153 std::vector<GURL> first_run_tabs_; | 178 std::vector<GURL> first_run_tabs_; |
154 | 179 |
155 // True if the set-as-default dialog has been explicitly suppressed. | 180 // True if the set-as-default dialog has been explicitly suppressed. |
156 // This information is used to allow the default browser prompt to show on | 181 // This information is used to allow the default browser prompt to show on |
157 // first-run when the dialog has been suppressed. | 182 // first-run when the dialog has been suppressed. |
158 bool is_default_browser_dialog_suppressed_; | 183 bool is_default_browser_dialog_suppressed_; |
159 | 184 |
160 // Whether the browser window should be shown immediately after it has been | 185 // Whether the browser window should be shown immediately after it has been |
161 // created. Default is true. | 186 // created. Default is true. |
(...skipping 12 matching lines...) Expand all Loading... | |
174 // Returns true if |profile| has exited uncleanly and has not been launched | 199 // Returns true if |profile| has exited uncleanly and has not been launched |
175 // after the unclean exit. | 200 // after the unclean exit. |
176 bool HasPendingUncleanExit(Profile* profile); | 201 bool HasPendingUncleanExit(Profile* profile); |
177 | 202 |
178 // Returns the path that contains the profile that should be loaded on process | 203 // Returns the path that contains the profile that should be loaded on process |
179 // startup. | 204 // startup. |
180 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, | 205 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, |
181 const base::CommandLine& command_line); | 206 const base::CommandLine& command_line); |
182 | 207 |
183 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ | 208 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ |
OLD | NEW |