| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 void set_show_main_browser_window(bool show_main_browser_window) { | 94 void set_show_main_browser_window(bool show_main_browser_window) { |
| 95 show_main_browser_window_ = show_main_browser_window; | 95 show_main_browser_window_ = show_main_browser_window; |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool show_main_browser_window() const { | 98 bool show_main_browser_window() const { |
| 99 return show_main_browser_window_; | 99 return show_main_browser_window_; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool show_desktop_search_redirection_infobar() const { |
| 103 return show_desktop_search_redirection_infobar_; |
| 104 } |
| 105 |
| 102 // For faking that no profiles have been launched yet. | 106 // For faking that no profiles have been launched yet. |
| 103 static void ClearLaunchedProfilesForTesting(); | 107 static void ClearLaunchedProfilesForTesting(); |
| 104 | 108 |
| 105 static void RegisterLocalStatePrefs(PrefRegistrySimple* registry); | 109 static void RegisterLocalStatePrefs(PrefRegistrySimple* registry); |
| 106 | 110 |
| 107 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
| 108 // Setting Chrome as the default browser in Windows 10+ requires a specific | 112 // Setting Chrome as the default browser in Windows 10+ requires a specific |
| 109 // url to be opened through openwith.exe. This url is intercepted in | 113 // url to be opened through openwith.exe. This url is intercepted in |
| 110 // ProcessCmdLineImpl when the callback is set. See DefaultBrowserWorker in | 114 // ProcessCmdLineImpl when the callback is set. See DefaultBrowserWorker in |
| 111 // shell_integration.h for more details. Only call this on the UI | 115 // shell_integration.h for more details. Only call this on the UI |
| (...skipping 14 matching lines...) Expand all Loading... |
| 126 private: | 130 private: |
| 127 friend class CloudPrintProxyPolicyTest; | 131 friend class CloudPrintProxyPolicyTest; |
| 128 friend class CloudPrintProxyPolicyStartupTest; | 132 friend class CloudPrintProxyPolicyStartupTest; |
| 129 friend class StartupBrowserCreatorImpl; | 133 friend class StartupBrowserCreatorImpl; |
| 130 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, | 134 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, |
| 131 ReadingWasRestartedAfterNormalStart); | 135 ReadingWasRestartedAfterNormalStart); |
| 132 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, | 136 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, |
| 133 ReadingWasRestartedAfterRestart); | 137 ReadingWasRestartedAfterRestart); |
| 134 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, UpdateWithTwoProfiles); | 138 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, UpdateWithTwoProfiles); |
| 135 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, LastUsedProfileActivated); | 139 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorTest, LastUsedProfileActivated); |
| 136 FRIEND_TEST_ALL_PREFIXES(StartupBrowserCreatorWinTest, | |
| 137 GetURLsFromCommandLineWithDesktopSearchURL); | |
| 138 | 140 |
| 139 bool ProcessCmdLineImpl(const base::CommandLine& command_line, | 141 bool ProcessCmdLineImpl(const base::CommandLine& command_line, |
| 140 const base::FilePath& cur_dir, | 142 const base::FilePath& cur_dir, |
| 141 bool process_startup, | 143 bool process_startup, |
| 142 Profile* last_used_profile, | 144 Profile* last_used_profile, |
| 143 const Profiles& last_opened_profiles); | 145 const Profiles& last_opened_profiles); |
| 144 | 146 |
| 145 // Returns the list of URLs to open from the command line. The returned | 147 // Returns the list of URLs to open from the command line. The returned vector |
| 146 // vector is empty if the user didn't specify any URLs on the command line. | 148 // is empty if the user didn't specify any URLs on the command line. |
| 149 // |show_search_redirection_infobar| is set to true if an infobar should be |
| 150 // shown to inform the user that a desktop search has been redirected to the |
| 151 // default search engine. |
| 147 static std::vector<GURL> GetURLsFromCommandLine( | 152 static std::vector<GURL> GetURLsFromCommandLine( |
| 148 const base::CommandLine& command_line, | 153 const base::CommandLine& command_line, |
| 149 const base::FilePath& cur_dir, | 154 const base::FilePath& cur_dir, |
| 150 Profile* profile); | 155 Profile* profile, |
| 156 bool* show_desktop_search_redirection_infobar); |
| 151 | 157 |
| 152 // This function performs command-line handling and is invoked only after | 158 // This function performs command-line handling and is invoked only after |
| 153 // start up (for example when we get a start request for another process). | 159 // start up (for example when we get a start request for another process). |
| 154 // |command_line| holds the command line being processed. | 160 // |command_line| holds the command line being processed. |
| 155 // |cur_dir| is the current working directory that the original process was | 161 // |cur_dir| is the current working directory that the original process was |
| 156 // invoked from. | 162 // invoked from. |
| 157 // |profile| is the profile the apps will be launched in. | 163 // |profile| is the profile the apps will be launched in. |
| 158 static bool ProcessLoadApps(const base::CommandLine& command_line, | 164 static bool ProcessLoadApps(const base::CommandLine& command_line, |
| 159 const base::FilePath& cur_dir, | 165 const base::FilePath& cur_dir, |
| 160 Profile* profile); | 166 Profile* profile); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 | 181 |
| 176 // True if the set-as-default dialog has been explicitly suppressed. | 182 // True if the set-as-default dialog has been explicitly suppressed. |
| 177 // This information is used to allow the default browser prompt to show on | 183 // This information is used to allow the default browser prompt to show on |
| 178 // first-run when the dialog has been suppressed. | 184 // first-run when the dialog has been suppressed. |
| 179 bool is_default_browser_dialog_suppressed_; | 185 bool is_default_browser_dialog_suppressed_; |
| 180 | 186 |
| 181 // Whether the browser window should be shown immediately after it has been | 187 // Whether the browser window should be shown immediately after it has been |
| 182 // created. Default is true. | 188 // created. Default is true. |
| 183 bool show_main_browser_window_; | 189 bool show_main_browser_window_; |
| 184 | 190 |
| 191 // Whether an infobar should be shown to inform the user that a desktop search |
| 192 // has been redirected to the default search engine. |
| 193 bool show_desktop_search_redirection_infobar_; |
| 194 |
| 185 // True if we have already read and reset the preference kWasRestarted. (A | 195 // True if we have already read and reset the preference kWasRestarted. (A |
| 186 // member variable instead of a static variable inside WasRestarted because | 196 // member variable instead of a static variable inside WasRestarted because |
| 187 // of testing.) | 197 // of testing.) |
| 188 static bool was_restarted_read_; | 198 static bool was_restarted_read_; |
| 189 | 199 |
| 190 static bool in_synchronous_profile_launch_; | 200 static bool in_synchronous_profile_launch_; |
| 191 | 201 |
| 192 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreator); | 202 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreator); |
| 193 }; | 203 }; |
| 194 | 204 |
| 195 // Returns true if |profile| has exited uncleanly and has not been launched | 205 // Returns true if |profile| has exited uncleanly and has not been launched |
| 196 // after the unclean exit. | 206 // after the unclean exit. |
| 197 bool HasPendingUncleanExit(Profile* profile); | 207 bool HasPendingUncleanExit(Profile* profile); |
| 198 | 208 |
| 199 // Returns the path that contains the profile that should be loaded on process | 209 // Returns the path that contains the profile that should be loaded on process |
| 200 // startup. | 210 // startup. |
| 201 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, | 211 base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, |
| 202 const base::CommandLine& command_line); | 212 const base::CommandLine& command_line); |
| 203 | 213 |
| 204 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ | 214 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ |
| OLD | NEW |