Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_browser_creator.cc |
| diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc |
| index cc9a84beee35e5910e4388176ba4a622c49fae66..bedbfcb55411b88d3b47a79eb4ef00c71cac106b 100644 |
| --- a/chrome/browser/ui/startup/startup_browser_creator.cc |
| +++ b/chrome/browser/ui/startup/startup_browser_creator.cc |
| @@ -25,6 +25,7 @@ |
| #include "base/prefs/pref_service.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_split.h" |
| +#include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "chrome/browser/app_mode/app_mode_utils.h" |
| @@ -101,6 +102,10 @@ using content::ChildProcessSecurityPolicy; |
| namespace { |
| +// The URL to the webstore page for a specific app. |
| +const char kWebstoreUrlFormat[] = |
|
tapted
2014/07/24 07:52:50
I don't think this constant belongs here..
jackhou1
2014/07/25 01:47:33
Kept this part in install_chrome_app.
|
| + "https://chrome.google.com/webstore/detail/%s"; |
| + |
| // Keeps track on which profiles have been launched. |
| class ProfileLaunchObserver : public content::NotificationObserver { |
| public: |
| @@ -245,6 +250,10 @@ void DumpBrowserHistograms(const base::FilePath& output_file) { |
| static_cast<int>(output_string.size())); |
| } |
| +GURL GetAppInstallUrl(const std::string& app_id) { |
| + return GURL(base::StringPrintf(kWebstoreUrlFormat, app_id.c_str())); |
| +} |
| + |
| } // namespace |
| StartupBrowserCreator::StartupBrowserCreator() |
| @@ -301,6 +310,7 @@ bool StartupBrowserCreator::LaunchBrowser( |
| StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); |
| const std::vector<GURL> urls_to_launch = |
| GetURLsFromCommandLine(command_line, cur_dir, profile); |
| + |
| chrome::HostDesktopType host_desktop_type = |
| chrome::HOST_DESKTOP_TYPE_NATIVE; |
| @@ -507,6 +517,14 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
| return false; |
| } |
| + std::vector<GURL> extra_urls_to_launch; |
| + if (command_line.HasSwitch(switches::kInstallChromeApp)) { |
| + extensions::StartupHelper helper; |
| + helper.InstallChromeApp(command_line, last_used_profile); |
| + extra_urls_to_launch.push_back(GetAppInstallUrl( |
| + command_line.GetSwitchValueASCII(switches::kInstallChromeApp))); |
| + } |
| + |
| if (command_line.HasSwitch(switches::kValidateCrx)) { |
| if (!process_startup) { |
| LOG(ERROR) << "chrome is already running; you must close all running " |
| @@ -609,6 +627,13 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
| chrome::startup::IS_NOT_PROCESS_STARTUP; |
| chrome::startup::IsFirstRun is_first_run = first_run::IsChromeFirstRun() ? |
| chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| + CommandLine command_line_with_extra_urls(command_line); |
| + for (std::vector<GURL>::const_iterator it = extra_urls_to_launch.begin(); |
| + it != extra_urls_to_launch.end(); |
| + ++it) { |
| + if (it->is_valid()) |
| + command_line_with_extra_urls.AppendArg(it->spec()); |
| + } |
| // |last_opened_profiles| will be empty in the following circumstances: |
| // - This is the first launch. |last_used_profile| is the initial profile. |
| // - The user exited the browser by closing all windows for all |
| @@ -631,7 +656,8 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
| return true; |
| } |
| } |
| - if (!browser_creator->LaunchBrowser(command_line, last_used_profile, |
| + if (!browser_creator->LaunchBrowser(command_line_with_extra_urls, |
| + last_used_profile, |
| cur_dir, is_process_startup, |
| is_first_run, return_code)) { |
| return false; |
| @@ -665,8 +691,8 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
| continue; |
| if (!browser_creator->LaunchBrowser((*it == last_used_profile) ? |
| - command_line : command_line_without_urls, *it, cur_dir, |
| - is_process_startup, is_first_run, return_code)) |
| + command_line_with_extra_urls : command_line_without_urls, *it, |
| + cur_dir, is_process_startup, is_first_run, return_code)) |
| return false; |
| // We've launched at least one browser. |
| is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP; |