| 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_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 6 #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 chrome::startup::IsFirstRun is_first_run); | 49 chrome::startup::IsFirstRun is_first_run); |
| 50 ~StartupBrowserCreatorImpl(); | 50 ~StartupBrowserCreatorImpl(); |
| 51 | 51 |
| 52 // Creates the necessary windows for startup. Returns true on success, | 52 // Creates the necessary windows for startup. Returns true on success, |
| 53 // false on failure. process_startup is true if Chrome is just | 53 // false on failure. process_startup is true if Chrome is just |
| 54 // starting up. If process_startup is false, it indicates Chrome was | 54 // starting up. If process_startup is false, it indicates Chrome was |
| 55 // already running and the user wants to launch another instance. | 55 // already running and the user wants to launch another instance. |
| 56 bool Launch(Profile* profile, | 56 bool Launch(Profile* profile, |
| 57 const std::vector<GURL>& urls_to_open, | 57 const std::vector<GURL>& urls_to_open, |
| 58 bool process_startup, | 58 bool process_startup, |
| 59 chrome::HostDesktopType desktop_type); | 59 ui::HostDesktopType desktop_type); |
| 60 | 60 |
| 61 // Convenience for OpenTabsInBrowser that converts |urls| into a set of | 61 // Convenience for OpenTabsInBrowser that converts |urls| into a set of |
| 62 // Tabs. | 62 // Tabs. |
| 63 Browser* OpenURLsInBrowser(Browser* browser, | 63 Browser* OpenURLsInBrowser(Browser* browser, |
| 64 bool process_startup, | 64 bool process_startup, |
| 65 const std::vector<GURL>& urls, | 65 const std::vector<GURL>& urls, |
| 66 chrome::HostDesktopType desktop_type); | 66 ui::HostDesktopType desktop_type); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); | 69 FRIEND_TEST_ALL_PREFIXES(BrowserTest, RestorePinnedTabs); |
| 70 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); | 70 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); |
| 71 | 71 |
| 72 enum class WelcomeRunType { | 72 enum class WelcomeRunType { |
| 73 NONE, // Do not inject the welcome page for this run. | 73 NONE, // Do not inject the welcome page for this run. |
| 74 FIRST_TAB, // Inject the welcome page as the first tab. | 74 FIRST_TAB, // Inject the welcome page as the first tab. |
| 75 FIRST_RUN_LAST_TAB, // Inject the welcome page as the last first-run tab. | 75 FIRST_RUN_LAST_TAB, // Inject the welcome page as the last first-run tab. |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null | 78 // Creates a tab for each of the Tabs in |tabs|. If browser is non-null |
| 79 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed | 79 // and a tabbed browser, the tabs are added to it. Otherwise a new tabbed |
| 80 // browser is created and the tabs are added to it. The browser the tabs | 80 // browser is created and the tabs are added to it. The browser the tabs |
| 81 // are added to is returned, which is either |browser| or the newly created | 81 // are added to is returned, which is either |browser| or the newly created |
| 82 // browser. | 82 // browser. |
| 83 Browser* OpenTabsInBrowser(Browser* browser, | 83 Browser* OpenTabsInBrowser(Browser* browser, |
| 84 bool process_startup, | 84 bool process_startup, |
| 85 const StartupTabs& tabs, | 85 const StartupTabs& tabs, |
| 86 chrome::HostDesktopType desktop_type); | 86 ui::HostDesktopType desktop_type); |
| 87 | 87 |
| 88 // If the process was launched with the web application command line flags, | 88 // If the process was launched with the web application command line flags, |
| 89 // e.g. --app=http://www.google.com/ or --app_id=... return true. | 89 // e.g. --app=http://www.google.com/ or --app_id=... return true. |
| 90 // In this case |app_url| or |app_id| are populated if they're non-null. | 90 // In this case |app_url| or |app_id| are populated if they're non-null. |
| 91 bool IsAppLaunch(std::string* app_url, std::string* app_id); | 91 bool IsAppLaunch(std::string* app_url, std::string* app_id); |
| 92 | 92 |
| 93 // If IsAppLaunch is true, tries to open an application window. | 93 // If IsAppLaunch is true, tries to open an application window. |
| 94 // If the app is specified to start in a tab, or IsAppLaunch is false, | 94 // If the app is specified to start in a tab, or IsAppLaunch is false, |
| 95 // returns false to specify default processing. | 95 // returns false to specify default processing. |
| 96 bool OpenApplicationWindow(Profile* profile); | 96 bool OpenApplicationWindow(Profile* profile); |
| 97 | 97 |
| 98 // If IsAppLaunch is true and the user set a pref indicating that the app | 98 // If IsAppLaunch is true and the user set a pref indicating that the app |
| 99 // should open in a tab, do so. | 99 // should open in a tab, do so. |
| 100 bool OpenApplicationTab(Profile* profile); | 100 bool OpenApplicationTab(Profile* profile); |
| 101 | 101 |
| 102 // Invoked from Launch to handle processing of urls. This may do any of the | 102 // Invoked from Launch to handle processing of urls. This may do any of the |
| 103 // following: | 103 // following: |
| 104 // . Invoke ProcessStartupURLs if |process_startup| is true. | 104 // . Invoke ProcessStartupURLs if |process_startup| is true. |
| 105 // . If |process_startup| is false, restore the last session if necessary, | 105 // . If |process_startup| is false, restore the last session if necessary, |
| 106 // or invoke ProcessSpecifiedURLs. | 106 // or invoke ProcessSpecifiedURLs. |
| 107 // . Open the urls directly. | 107 // . Open the urls directly. |
| 108 void ProcessLaunchURLs(bool process_startup, | 108 void ProcessLaunchURLs(bool process_startup, |
| 109 const std::vector<GURL>& urls_to_open, | 109 const std::vector<GURL>& urls_to_open, |
| 110 chrome::HostDesktopType desktop_type); | 110 ui::HostDesktopType desktop_type); |
| 111 | 111 |
| 112 // Does the following: | 112 // Does the following: |
| 113 // . If the user's startup pref is to restore the last session (or the | 113 // . If the user's startup pref is to restore the last session (or the |
| 114 // command line flag is present to force using last session), it is | 114 // command line flag is present to force using last session), it is |
| 115 // restored. | 115 // restored. |
| 116 // . Otherwise invoke ProcessSpecifiedURLs | 116 // . Otherwise invoke ProcessSpecifiedURLs |
| 117 // If a browser was created, true is returned. Otherwise returns false and | 117 // If a browser was created, true is returned. Otherwise returns false and |
| 118 // the caller must create a new browser. | 118 // the caller must create a new browser. |
| 119 bool ProcessStartupURLs(const std::vector<GURL>& urls_to_open, | 119 bool ProcessStartupURLs(const std::vector<GURL>& urls_to_open, |
| 120 chrome::HostDesktopType desktop_type); | 120 ui::HostDesktopType desktop_type); |
| 121 | 121 |
| 122 // Invoked from either ProcessLaunchURLs or ProcessStartupURLs to handle | 122 // Invoked from either ProcessLaunchURLs or ProcessStartupURLs to handle |
| 123 // processing of URLs where the behavior is common between process startup | 123 // processing of URLs where the behavior is common between process startup |
| 124 // and launch via an existing process (i.e. those explicitly specified by | 124 // and launch via an existing process (i.e. those explicitly specified by |
| 125 // the user somehow). Does the following: | 125 // the user somehow). Does the following: |
| 126 // . Attempts to restore any pinned tabs from last run of chrome. | 126 // . Attempts to restore any pinned tabs from last run of chrome. |
| 127 // . If urls_to_open is non-empty, they are opened. | 127 // . If urls_to_open is non-empty, they are opened. |
| 128 // . If the user's startup pref is to launch a specific set of URLs they | 128 // . If the user's startup pref is to launch a specific set of URLs they |
| 129 // are opened. | 129 // are opened. |
| 130 // | 130 // |
| 131 // If any tabs were opened, the Browser which was created is returned. | 131 // If any tabs were opened, the Browser which was created is returned. |
| 132 // Otherwise null is returned and the caller must create a new browser. | 132 // Otherwise null is returned and the caller must create a new browser. |
| 133 Browser* ProcessSpecifiedURLs(const std::vector<GURL>& urls_to_open, | 133 Browser* ProcessSpecifiedURLs(const std::vector<GURL>& urls_to_open, |
| 134 chrome::HostDesktopType desktop_type); | 134 ui::HostDesktopType desktop_type); |
| 135 | 135 |
| 136 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist | 136 // Adds a Tab to |tabs| for each url in |urls| that doesn't already exist |
| 137 // in |tabs|. | 137 // in |tabs|. |
| 138 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); | 138 void AddUniqueURLs(const std::vector<GURL>& urls, StartupTabs* tabs); |
| 139 | 139 |
| 140 // Adds any startup infobars to the selected tab of the given browser. | 140 // Adds any startup infobars to the selected tab of the given browser. |
| 141 void AddInfoBarsIfNecessary( | 141 void AddInfoBarsIfNecessary( |
| 142 Browser* browser, | 142 Browser* browser, |
| 143 chrome::startup::IsProcessStartup is_process_startup); | 143 chrome::startup::IsProcessStartup is_process_startup); |
| 144 | 144 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 155 const base::FilePath cur_dir_; | 155 const base::FilePath cur_dir_; |
| 156 const base::CommandLine& command_line_; | 156 const base::CommandLine& command_line_; |
| 157 Profile* profile_; | 157 Profile* profile_; |
| 158 StartupBrowserCreator* browser_creator_; | 158 StartupBrowserCreator* browser_creator_; |
| 159 bool is_first_run_; | 159 bool is_first_run_; |
| 160 WelcomeRunType welcome_run_type_; | 160 WelcomeRunType welcome_run_type_; |
| 161 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); | 161 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorImpl); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ | 164 #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_IMPL_H_ |
| OLD | NEW |