OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser_init.h" | 5 #include "chrome/browser/browser_init.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 NULL, | 97 NULL, |
98 chrome::kMessageWindowClass, | 98 chrome::kMessageWindowClass, |
99 user_data_dir.c_str()); | 99 user_data_dir.c_str()); |
100 } | 100 } |
101 | 101 |
102 BrowserInit::MessageWindow::~MessageWindow() { | 102 BrowserInit::MessageWindow::~MessageWindow() { |
103 if (window_) | 103 if (window_) |
104 DestroyWindow(window_); | 104 DestroyWindow(window_); |
105 } | 105 } |
106 | 106 |
107 bool BrowserInit::MessageWindow::NotifyOtherProcess(int show_cmd) { | 107 bool BrowserInit::MessageWindow::NotifyOtherProcess() { |
108 if (!remote_window_) | 108 if (!remote_window_) |
109 return false; | 109 return false; |
110 | 110 |
111 // Found another window, send our command line to it | 111 // Found another window, send our command line to it |
112 // format is "START\0<<<current directory>>>\0<<<commandline>>>\0show_cmd". | 112 // format is "START\0<<<current directory>>>\0<<<commandline>>>". |
113 std::wstring to_send(L"START\0", 6); // want the NULL in the string. | 113 std::wstring to_send(L"START\0", 6); // want the NULL in the string. |
114 std::wstring cur_dir; | 114 std::wstring cur_dir; |
115 if (!PathService::Get(base::DIR_CURRENT, &cur_dir)) | 115 if (!PathService::Get(base::DIR_CURRENT, &cur_dir)) |
116 return false; | 116 return false; |
117 to_send.append(cur_dir); | 117 to_send.append(cur_dir); |
118 to_send.append(L"\0", 1); // Null separator. | 118 to_send.append(L"\0", 1); // Null separator. |
119 to_send.append(GetCommandLineW()); | 119 to_send.append(GetCommandLineW()); |
120 to_send.append(L"\0", 1); // Null separator. | 120 to_send.append(L"\0", 1); // Null separator. |
121 | 121 |
122 // Append the windows show_command flags. | |
123 if (show_cmd == SW_SHOWDEFAULT) { | |
124 // SW_SHOWDEFAULT makes no sense to the other process. We need to | |
125 // use the SW_ flag from OUR STARTUPUNFO; | |
126 STARTUPINFO startup_info = {0}; | |
127 startup_info.cb = sizeof(startup_info); | |
128 GetStartupInfo(&startup_info); | |
129 show_cmd = startup_info.wShowWindow; | |
130 // In certain situations the window status above is returned as SW_HIDE. | |
131 // In such cases we need to fall back to a default case of SW_SHOWNORMAL | |
132 // so that user actually get to see the window. | |
133 if (show_cmd != SW_SHOWNORMAL && show_cmd != SW_SHOWMAXIMIZED) | |
134 show_cmd = SW_SHOWNORMAL; | |
135 } | |
136 StringAppendF(&to_send, L"%d", static_cast<uint8>(show_cmd)); | |
137 | |
138 // Allow the current running browser window making itself the foreground | 122 // Allow the current running browser window making itself the foreground |
139 // window (otherwise it will just flash in the taskbar). | 123 // window (otherwise it will just flash in the taskbar). |
140 DWORD process_id = 0; | 124 DWORD process_id = 0; |
141 DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id); | 125 DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id); |
142 DCHECK(process_id); | 126 DCHECK(process_id); |
143 AllowSetForegroundWindow(process_id); | 127 AllowSetForegroundWindow(process_id); |
144 | 128 |
145 // Gives 20 seconds timeout for the current browser process to respond. | 129 // Gives 20 seconds timeout for the current browser process to respond. |
146 const int kTimeout = 20000; | 130 const int kTimeout = 20000; |
147 COPYDATASTRUCT cds; | 131 COPYDATASTRUCT cds; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 if (third_null == std::wstring::npos || | 243 if (third_null == std::wstring::npos || |
260 third_null == msg.length()) { | 244 third_null == msg.length()) { |
261 LOG(WARNING) << "Invalid format for start command, we need a string in 4 " | 245 LOG(WARNING) << "Invalid format for start command, we need a string in 4 " |
262 "parts separated by NULLs"; | 246 "parts separated by NULLs"; |
263 } | 247 } |
264 | 248 |
265 // Get command line. | 249 // Get command line. |
266 const std::wstring cmd_line = | 250 const std::wstring cmd_line = |
267 msg.substr(second_null + 1, third_null - second_null); | 251 msg.substr(second_null + 1, third_null - second_null); |
268 | 252 |
269 // The last component is probably null terminated but we don't require it | |
270 // because everything here is based on counts. | |
271 std::wstring show_cmd_str = msg.substr(third_null + 1); | |
272 if (!show_cmd_str.empty() && | |
273 show_cmd_str[show_cmd_str.length() - 1] == L'\0') | |
274 show_cmd_str.resize(cmd_line.length() - 1); | |
275 | |
276 int show_cmd = _wtoi(show_cmd_str.c_str()); | |
277 | |
278 CommandLine parsed_command_line(cmd_line); | 253 CommandLine parsed_command_line(cmd_line); |
279 PrefService* prefs = g_browser_process->local_state(); | 254 PrefService* prefs = g_browser_process->local_state(); |
280 DCHECK(prefs); | 255 DCHECK(prefs); |
281 | 256 |
282 std::wstring user_data_dir; | 257 std::wstring user_data_dir; |
283 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 258 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
284 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 259 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
285 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | 260 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); |
286 if (!profile) { | 261 if (!profile) { |
287 // We should only be able to get here if the profile already exists and | 262 // We should only be able to get here if the profile already exists and |
288 // has been created. | 263 // has been created. |
289 NOTREACHED(); | 264 NOTREACHED(); |
290 return TRUE; | 265 return TRUE; |
291 } | 266 } |
292 ProcessCommandLine(parsed_command_line, cur_dir, prefs, show_cmd, false, | 267 ProcessCommandLine(parsed_command_line, cur_dir, prefs, false, profile, |
293 profile, NULL); | 268 NULL); |
294 return TRUE; | 269 return TRUE; |
295 } | 270 } |
296 return TRUE; | 271 return TRUE; |
297 } | 272 } |
298 | 273 |
299 LRESULT CALLBACK BrowserInit::MessageWindow::WndProc(HWND hwnd, | 274 LRESULT CALLBACK BrowserInit::MessageWindow::WndProc(HWND hwnd, |
300 UINT message, | 275 UINT message, |
301 WPARAM wparam, | 276 WPARAM wparam, |
302 LPARAM lparam) { | 277 LPARAM lparam) { |
303 switch (message) { | 278 switch (message) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ZombieDetector zombie_detector; | 339 ZombieDetector zombie_detector; |
365 process_util::KillProcesses(L"chrome.exe", | 340 process_util::KillProcesses(L"chrome.exe", |
366 ResultCodes::HUNG, | 341 ResultCodes::HUNG, |
367 &zombie_detector); | 342 &zombie_detector); |
368 } | 343 } |
369 | 344 |
370 | 345 |
371 // LaunchWithProfile ---------------------------------------------------------- | 346 // LaunchWithProfile ---------------------------------------------------------- |
372 | 347 |
373 BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir, | 348 BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir, |
374 const std::wstring& cmd_line, | 349 const std::wstring& cmd_line) |
375 int show_command) | |
376 : command_line_(cmd_line), | 350 : command_line_(cmd_line), |
377 show_command_(show_command), | |
378 cur_dir_(cur_dir) { | 351 cur_dir_(cur_dir) { |
379 } | 352 } |
380 | 353 |
381 bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, | 354 bool BrowserInit::LaunchWithProfile::Launch(Profile* profile, |
382 bool process_startup) { | 355 bool process_startup) { |
383 DCHECK(profile); | 356 DCHECK(profile); |
384 profile_ = profile; | 357 profile_ = profile; |
385 | 358 |
386 CommandLine parsed_command_line(command_line_); | 359 CommandLine parsed_command_line(command_line_); |
387 gfx::Rect start_position; | |
388 | |
389 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode); | |
390 bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode); | |
391 if (record_mode || playback_mode) { | |
392 // In playback/record mode we always fix the size of the browser and | |
393 // move it to (0,0). The reason for this is two reasons: First we want | |
394 // resize/moves in the playback to still work, and Second we want | |
395 // playbacks to work (as much as possible) on machines w/ different | |
396 // screen sizes. | |
397 start_position_.set_height(800); | |
398 start_position_.set_width(600); | |
399 start_position_.set_x(0); | |
400 start_position_.set_y(0); | |
401 } | |
402 | |
403 if (parsed_command_line.HasSwitch(switches::kDnsLogDetails)) | 360 if (parsed_command_line.HasSwitch(switches::kDnsLogDetails)) |
404 chrome_browser_net::EnableDnsDetailedLog(true); | 361 chrome_browser_net::EnableDnsDetailedLog(true); |
405 if (parsed_command_line.HasSwitch(switches::kDnsPrefetchDisable)) | 362 if (parsed_command_line.HasSwitch(switches::kDnsPrefetchDisable)) |
406 chrome_browser_net::EnableDnsPrefetch(false); | 363 chrome_browser_net::EnableDnsPrefetch(false); |
407 | 364 |
408 if (parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { | 365 if (parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { |
409 StatisticsRecorder::set_dump_on_exit(true); | 366 StatisticsRecorder::set_dump_on_exit(true); |
410 } | 367 } |
411 | 368 |
412 if (parsed_command_line.HasSwitch(switches::kRemoteShellPort)) { | 369 if (parsed_command_line.HasSwitch(switches::kRemoteShellPort)) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 425 |
469 // It is possible to end here with a NULL 'browser'. For example if the user | 426 // It is possible to end here with a NULL 'browser'. For example if the user |
470 // has tweaked the startup session restore preferences. | 427 // has tweaked the startup session restore preferences. |
471 | 428 |
472 if (browser) { | 429 if (browser) { |
473 // If we're recording or playing back, startup the EventRecorder now | 430 // If we're recording or playing back, startup the EventRecorder now |
474 // unless otherwise specified. | 431 // unless otherwise specified. |
475 if (!parsed_command_line.HasSwitch(switches::kNoEvents)) { | 432 if (!parsed_command_line.HasSwitch(switches::kNoEvents)) { |
476 std::wstring script_path; | 433 std::wstring script_path; |
477 PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path); | 434 PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path); |
| 435 |
| 436 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode); |
| 437 bool playback_mode = |
| 438 parsed_command_line.HasSwitch(switches::kPlaybackMode); |
| 439 |
478 if (record_mode && chrome::kRecordModeEnabled) | 440 if (record_mode && chrome::kRecordModeEnabled) |
479 base::EventRecorder::current()->StartRecording(script_path); | 441 base::EventRecorder::current()->StartRecording(script_path); |
480 if (playback_mode) | 442 if (playback_mode) |
481 base::EventRecorder::current()->StartPlayback(script_path); | 443 base::EventRecorder::current()->StartPlayback(script_path); |
482 } | 444 } |
483 } | 445 } |
484 return true; | 446 return true; |
485 } | 447 } |
486 | 448 |
487 Browser* BrowserInit::LaunchWithProfile::CreateTabbedBrowser() { | |
488 return new Browser(start_position_, show_command_, profile_, | |
489 BrowserType::TABBED_BROWSER, std::wstring()); | |
490 } | |
491 | |
492 bool BrowserInit::LaunchWithProfile::OpenStartupURLs( | 449 bool BrowserInit::LaunchWithProfile::OpenStartupURLs( |
493 bool is_process_startup, | 450 bool is_process_startup, |
494 const CommandLine& command_line, | 451 const CommandLine& command_line, |
495 const std::vector<GURL>& urls_to_open) { | 452 const std::vector<GURL>& urls_to_open) { |
496 SessionStartupPref pref = GetSessionStartupPref(profile_, command_line); | 453 SessionStartupPref pref = GetSessionStartupPref(profile_, command_line); |
497 switch (pref.type) { | 454 switch (pref.type) { |
498 case SessionStartupPref::LAST: | 455 case SessionStartupPref::LAST: |
499 if (!is_process_startup) | 456 if (!is_process_startup) |
500 return false; | 457 return false; |
501 | 458 |
502 if (!profile_->DidLastSessionExitCleanly() && | 459 if (!profile_->DidLastSessionExitCleanly() && |
503 !command_line.HasSwitch(switches::kRestoreLastSession)) { | 460 !command_line.HasSwitch(switches::kRestoreLastSession)) { |
504 // The last session crashed. It's possible automatically loading the | 461 // The last session crashed. It's possible automatically loading the |
505 // page will trigger another crash, locking the user out of chrome. | 462 // page will trigger another crash, locking the user out of chrome. |
506 // To avoid this, don't restore on startup but instead show the crashed | 463 // To avoid this, don't restore on startup but instead show the crashed |
507 // infobar. | 464 // infobar. |
508 return false; | 465 return false; |
509 } | 466 } |
510 SessionRestore::RestoreSessionSynchronously( | 467 SessionRestore::RestoreSessionSynchronously(profile_, false, |
511 profile_, false, show_command_, urls_to_open); | 468 urls_to_open); |
512 return true; | 469 return true; |
513 | 470 |
514 case SessionStartupPref::URLS: | 471 case SessionStartupPref::URLS: |
515 // When the user launches the app only open the default set of URLs if | 472 // When the user launches the app only open the default set of URLs if |
516 // we aren't going to open any URLs on the command line. | 473 // we aren't going to open any URLs on the command line. |
517 if (urls_to_open.empty()) { | 474 if (urls_to_open.empty()) { |
518 if (pref.urls.empty()) | 475 if (pref.urls.empty()) |
519 return false; // No URLs to open. | 476 return false; // No URLs to open. |
520 OpenURLsInBrowser(NULL, is_process_startup, pref.urls); | 477 OpenURLsInBrowser(NULL, is_process_startup, pref.urls); |
521 return true; | 478 return true; |
522 } | 479 } |
523 return false; | 480 return false; |
524 | 481 |
525 default: | 482 default: |
526 return false; | 483 return false; |
527 } | 484 } |
528 } | 485 } |
529 | 486 |
530 Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( | 487 Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( |
531 Browser* browser, | 488 Browser* browser, |
532 bool process_startup, | 489 bool process_startup, |
533 const std::vector<GURL>& urls) { | 490 const std::vector<GURL>& urls) { |
534 DCHECK(!urls.empty()); | 491 DCHECK(!urls.empty()); |
535 if (!browser || browser->type() != BrowserType::TABBED_BROWSER) | 492 if (!browser || browser->type() != BrowserType::TABBED_BROWSER) |
536 browser = CreateTabbedBrowser(); | 493 browser = Browser::Create(profile_); |
537 | 494 |
538 for (size_t i = 0; i < urls.size(); ++i) { | 495 for (size_t i = 0; i < urls.size(); ++i) { |
539 TabContents* tab = browser->AddTabWithURL( | 496 TabContents* tab = browser->AddTabWithURL( |
540 urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL); | 497 urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL); |
541 if (i == 0 && process_startup) | 498 if (i == 0 && process_startup) |
542 AddCrashedInfoBarIfNecessary(tab); | 499 AddCrashedInfoBarIfNecessary(tab); |
543 } | 500 } |
544 browser->Show(); | 501 browser->window()->Show(); |
545 return browser; | 502 return browser; |
546 } | 503 } |
547 | 504 |
548 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( | 505 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( |
549 TabContents* tab) { | 506 TabContents* tab) { |
550 WebContents* web_contents = tab->AsWebContents(); | 507 WebContents* web_contents = tab->AsWebContents(); |
551 if (!profile_->DidLastSessionExitCleanly() && web_contents) { | 508 if (!profile_->DidLastSessionExitCleanly() && web_contents) { |
552 // The last session didn't exit cleanly. Show an infobar to the user | 509 // The last session didn't exit cleanly. Show an infobar to the user |
553 // so that they can restore if they want. | 510 // so that they can restore if they want. |
554 // TODO(brettw) this should be done more cleanly, by adding a message to | 511 // TODO(brettw) this should be done more cleanly, by adding a message to |
(...skipping 30 matching lines...) Expand all Loading... |
585 } else { | 542 } else { |
586 // This will create a file URL or a regular URL. | 543 // This will create a file URL or a regular URL. |
587 urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value))); | 544 urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value))); |
588 } | 545 } |
589 } | 546 } |
590 } | 547 } |
591 return urls; | 548 return urls; |
592 } | 549 } |
593 | 550 |
594 bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line, | 551 bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line, |
595 const std::wstring& cur_dir, PrefService* prefs, int show_command, | 552 const std::wstring& cur_dir, PrefService* prefs, bool process_startup, |
596 bool process_startup, Profile* profile, int* return_code) { | 553 Profile* profile, int* return_code) { |
597 DCHECK(profile); | 554 DCHECK(profile); |
598 if (process_startup) { | 555 if (process_startup) { |
599 const std::wstring popup_count_string = | 556 const std::wstring popup_count_string = |
600 parsed_command_line.GetSwitchValue(switches::kOmniBoxPopupCount); | 557 parsed_command_line.GetSwitchValue(switches::kOmniBoxPopupCount); |
601 if (!popup_count_string.empty()) { | 558 if (!popup_count_string.empty()) { |
602 const int popup_count = std::max(0, _wtoi(popup_count_string.c_str())); | 559 const int popup_count = std::max(0, _wtoi(popup_count_string.c_str())); |
603 AutocompleteResult::set_max_matches(popup_count); | 560 AutocompleteResult::set_max_matches(popup_count); |
604 AutocompleteProvider::set_max_matches(popup_count / 2); | 561 AutocompleteProvider::set_max_matches(popup_count / 2); |
605 } | 562 } |
606 | 563 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 0); | 605 0); |
649 if (expected_tabs == 0) { | 606 if (expected_tabs == 0) { |
650 silent_launch = true; | 607 silent_launch = true; |
651 } | 608 } |
652 CreateAutomationProvider<AutomationProvider>(automation_channel_id, | 609 CreateAutomationProvider<AutomationProvider>(automation_channel_id, |
653 profile, expected_tabs); | 610 profile, expected_tabs); |
654 } | 611 } |
655 // If we don't want to launch a new browser window or tab (in the case | 612 // If we don't want to launch a new browser window or tab (in the case |
656 // of an automation request), we are done here. | 613 // of an automation request), we are done here. |
657 if (!silent_launch) { | 614 if (!silent_launch) { |
658 return LaunchBrowser(parsed_command_line, profile, show_command, cur_dir, | 615 return LaunchBrowser(parsed_command_line, profile, cur_dir, |
659 process_startup, return_code); | 616 process_startup, return_code); |
660 } | 617 } |
661 return true; | 618 return true; |
662 } | 619 } |
663 | 620 |
664 bool BrowserInit::LaunchBrowser(const CommandLine& parsed_command_line, | 621 bool BrowserInit::LaunchBrowser(const CommandLine& parsed_command_line, |
665 Profile* profile, | 622 Profile* profile, const std::wstring& cur_dir, |
666 int show_command, const std::wstring& cur_dir, | |
667 bool process_startup, int* return_code) { | 623 bool process_startup, int* return_code) { |
668 in_startup = process_startup; | 624 in_startup = process_startup; |
669 bool result = LaunchBrowserImpl(parsed_command_line, profile, show_command, | 625 bool result = LaunchBrowserImpl(parsed_command_line, profile, cur_dir, |
670 cur_dir, process_startup, return_code); | 626 process_startup, return_code); |
671 in_startup = false; | 627 in_startup = false; |
672 return result; | 628 return result; |
673 } | 629 } |
674 | 630 |
675 template <class AutomationProviderClass> | 631 template <class AutomationProviderClass> |
676 void BrowserInit::CreateAutomationProvider(const std::wstring& channel_id, | 632 void BrowserInit::CreateAutomationProvider(const std::wstring& channel_id, |
677 Profile* profile, | 633 Profile* profile, |
678 size_t expected_tabs) { | 634 size_t expected_tabs) { |
679 scoped_refptr<AutomationProviderClass> automation = | 635 scoped_refptr<AutomationProviderClass> automation = |
680 new AutomationProviderClass(profile); | 636 new AutomationProviderClass(profile); |
681 automation->ConnectToChannel(channel_id); | 637 automation->ConnectToChannel(channel_id); |
682 automation->SetExpectedTabCount(expected_tabs); | 638 automation->SetExpectedTabCount(expected_tabs); |
683 | 639 |
684 AutomationProviderList* list = | 640 AutomationProviderList* list = |
685 g_browser_process->InitAutomationProviderList(); | 641 g_browser_process->InitAutomationProviderList(); |
686 DCHECK(list); | 642 DCHECK(list); |
687 list->AddProvider(automation); | 643 list->AddProvider(automation); |
688 } | 644 } |
689 | 645 |
690 bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line, | 646 bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line, |
691 Profile* profile, | 647 Profile* profile, |
692 int show_command, | |
693 const std::wstring& cur_dir, | 648 const std::wstring& cur_dir, |
694 bool process_startup, | 649 bool process_startup, |
695 int* return_code) { | 650 int* return_code) { |
696 DCHECK(profile); | 651 DCHECK(profile); |
697 | 652 |
698 // Continue with the off-the-record profile from here on if --incognito | 653 // Continue with the off-the-record profile from here on if --incognito |
699 if (parsed_command_line.HasSwitch(switches::kIncognito)) | 654 if (parsed_command_line.HasSwitch(switches::kIncognito)) |
700 profile = profile->GetOffTheRecordProfile(); | 655 profile = profile->GetOffTheRecordProfile(); |
701 | 656 |
702 // Are we starting an application? | 657 // Are we starting an application? |
703 std::wstring app_url = parsed_command_line.GetSwitchValue(switches::kApp); | 658 std::wstring app_url = parsed_command_line.GetSwitchValue(switches::kApp); |
704 if (!app_url.empty()) { | 659 if (!app_url.empty()) { |
705 GURL url(app_url); | 660 GURL url(app_url); |
706 // If the application is started for a mailto:url, this machine has some | 661 // If the application is started for a mailto:url, this machine has some |
707 // old configuration that we should ignore. This hack saves us from some | 662 // old configuration that we should ignore. This hack saves us from some |
708 // infinite loops where we keep forwarding mailto: to the system, resulting | 663 // infinite loops where we keep forwarding mailto: to the system, resulting |
709 // in the system asking us to open the mailto app. | 664 // in the system asking us to open the mailto app. |
710 if (url.SchemeIs("mailto")) | 665 if (url.SchemeIs("mailto")) |
711 url = GURL("about:blank"); | 666 url = GURL("about:blank"); |
712 | 667 |
713 WebAppLauncher::Launch(profile, url, show_command); | 668 WebAppLauncher::Launch(profile, url); |
714 return true; | 669 return true; |
715 } | 670 } |
716 | 671 |
717 LaunchWithProfile lwp(cur_dir, parsed_command_line.command_line_string(), | 672 LaunchWithProfile lwp(cur_dir, parsed_command_line.command_line_string()); |
718 show_command); | |
719 bool launched = lwp.Launch(profile, process_startup); | 673 bool launched = lwp.Launch(profile, process_startup); |
720 if (!launched) { | 674 if (!launched) { |
721 LOG(ERROR) << "launch error"; | 675 LOG(ERROR) << "launch error"; |
722 if (return_code != NULL) { | 676 if (return_code != NULL) { |
723 *return_code = ResultCodes::INVALID_CMDLINE_URL; | 677 *return_code = ResultCodes::INVALID_CMDLINE_URL; |
724 } | 678 } |
725 return false; | 679 return false; |
726 } | 680 } |
727 | 681 |
728 return true; | 682 return true; |
729 } | 683 } |
OLD | NEW |