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 // Implementation of the CommandExecuteImpl class which implements the | 4 // Implementation of the CommandExecuteImpl class which implements the |
5 // IExecuteCommand and related interfaces for handling ShellExecute based | 5 // IExecuteCommand and related interfaces for handling ShellExecute based |
6 // launches of the Chrome browser. | 6 // launches of the Chrome browser. |
7 | 7 |
8 #include "win8/delegate_execute/command_execute_impl.h" | 8 #include "win8/delegate_execute/command_execute_impl.h" |
9 | 9 |
10 #include <shlguid.h> | 10 #include <shlguid.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/installer/util/util_constants.h" | 29 #include "chrome/installer/util/util_constants.h" |
30 #include "ui/base/clipboard/clipboard_util_win.h" | 30 #include "ui/base/clipboard/clipboard_util_win.h" |
31 #include "win8/delegate_execute/chrome_util.h" | 31 #include "win8/delegate_execute/chrome_util.h" |
32 #include "win8/delegate_execute/delegate_execute_util.h" | 32 #include "win8/delegate_execute/delegate_execute_util.h" |
33 #include "win8/viewer/metro_viewer_constants.h" | 33 #include "win8/viewer/metro_viewer_constants.h" |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Helper function to retrieve the url from IShellItem interface passed in. | 37 // Helper function to retrieve the url from IShellItem interface passed in. |
38 // Returns S_OK on success. | 38 // Returns S_OK on success. |
39 HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) { | 39 HRESULT GetUrlFromShellItem(IShellItem* shell_item, base::string16* url) { |
40 DCHECK(shell_item); | 40 DCHECK(shell_item); |
41 DCHECK(url); | 41 DCHECK(url); |
42 // First attempt to get the url from the underlying IDataObject if any. This | 42 // First attempt to get the url from the underlying IDataObject if any. This |
43 // ensures that we get the full url, i.e. including the anchor. | 43 // ensures that we get the full url, i.e. including the anchor. |
44 // If we fail to get the underlying IDataObject we retrieve the url via the | 44 // If we fail to get the underlying IDataObject we retrieve the url via the |
45 // IShellItem::GetDisplayName function. | 45 // IShellItem::GetDisplayName function. |
46 CComPtr<IDataObject> object; | 46 CComPtr<IDataObject> object; |
47 HRESULT hr = shell_item->BindToHandler(NULL, | 47 HRESULT hr = shell_item->BindToHandler(NULL, |
48 BHID_DataObject, | 48 BHID_DataObject, |
49 IID_IDataObject, | 49 IID_IDataObject, |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 CComPtr<IApplicationActivationManager> activation_manager; | 322 CComPtr<IApplicationActivationManager> activation_manager; |
323 hr = activation_manager.CoCreateInstance(CLSID_ApplicationActivationManager); | 323 hr = activation_manager.CoCreateInstance(CLSID_ApplicationActivationManager); |
324 if (!activation_manager) { | 324 if (!activation_manager) { |
325 AtlTrace("Failed to get the activation manager, error 0x%x\n", hr); | 325 AtlTrace("Failed to get the activation manager, error 0x%x\n", hr); |
326 return S_OK; | 326 return S_OK; |
327 } | 327 } |
328 | 328 |
329 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); | 329 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); |
330 bool is_per_user_install = InstallUtil::IsPerUserInstall( | 330 bool is_per_user_install = InstallUtil::IsPerUserInstall( |
331 chrome_exe_.value().c_str()); | 331 chrome_exe_.value().c_str()); |
332 string16 app_id = ShellUtil::GetBrowserModelId( | 332 base::string16 app_id = ShellUtil::GetBrowserModelId( |
333 distribution, is_per_user_install); | 333 distribution, is_per_user_install); |
334 | 334 |
335 DWORD pid = 0; | 335 DWORD pid = 0; |
336 if (launch_scheme_ == INTERNET_SCHEME_FILE && | 336 if (launch_scheme_ == INTERNET_SCHEME_FILE && |
337 display_name_.find(installer::kChromeExe) != string16::npos) { | 337 display_name_.find(installer::kChromeExe) != base::string16::npos) { |
338 AtlTrace("Activating for file\n"); | 338 AtlTrace("Activating for file\n"); |
339 hr = activation_manager->ActivateApplication(app_id.c_str(), | 339 hr = activation_manager->ActivateApplication(app_id.c_str(), |
340 verb_.c_str(), | 340 verb_.c_str(), |
341 AO_NONE, | 341 AO_NONE, |
342 &pid); | 342 &pid); |
343 } else { | 343 } else { |
344 AtlTrace("Activating for protocol\n"); | 344 AtlTrace("Activating for protocol\n"); |
345 hr = activation_manager->ActivateForProtocol(app_id.c_str(), | 345 hr = activation_manager->ActivateForProtocol(app_id.c_str(), |
346 item_array_, | 346 item_array_, |
347 &pid); | 347 &pid); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 AtlTrace("Failed to find chrome exe file\n"); | 408 AtlTrace("Failed to find chrome exe file\n"); |
409 return false; | 409 return false; |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 AtlTrace("Got chrome exe path as %ls\n", chrome_exe->value().c_str()); | 413 AtlTrace("Got chrome exe path as %ls\n", chrome_exe->value().c_str()); |
414 return true; | 414 return true; |
415 } | 415 } |
416 | 416 |
417 bool CommandExecuteImpl::GetLaunchScheme( | 417 bool CommandExecuteImpl::GetLaunchScheme( |
418 string16* display_name, INTERNET_SCHEME* scheme) { | 418 base::string16* display_name, INTERNET_SCHEME* scheme) { |
419 if (!item_array_) | 419 if (!item_array_) |
420 return false; | 420 return false; |
421 | 421 |
422 ATLASSERT(display_name); | 422 ATLASSERT(display_name); |
423 ATLASSERT(scheme); | 423 ATLASSERT(scheme); |
424 | 424 |
425 DWORD count = 0; | 425 DWORD count = 0; |
426 item_array_->GetCount(&count); | 426 item_array_->GetCount(&count); |
427 | 427 |
428 if (count != 1) { | 428 if (count != 1) { |
(...skipping 29 matching lines...) Expand all Loading... |
458 return false; | 458 return false; |
459 } | 459 } |
460 | 460 |
461 AtlTrace("Launch scheme is [%ls] (%d)\n", scheme_name, components.nScheme); | 461 AtlTrace("Launch scheme is [%ls] (%d)\n", scheme_name, components.nScheme); |
462 *scheme = components.nScheme; | 462 *scheme = components.nScheme; |
463 return true; | 463 return true; |
464 } | 464 } |
465 | 465 |
466 HRESULT CommandExecuteImpl::LaunchDesktopChrome() { | 466 HRESULT CommandExecuteImpl::LaunchDesktopChrome() { |
467 AtlTrace("In %hs\n", __FUNCTION__); | 467 AtlTrace("In %hs\n", __FUNCTION__); |
468 string16 display_name = display_name_; | 468 base::string16 display_name = display_name_; |
469 | 469 |
470 switch (launch_scheme_) { | 470 switch (launch_scheme_) { |
471 case INTERNET_SCHEME_FILE: | 471 case INTERNET_SCHEME_FILE: |
472 // If anything other than chrome.exe is passed in the display name we | 472 // If anything other than chrome.exe is passed in the display name we |
473 // should honor it. For e.g. If the user clicks on a html file when | 473 // should honor it. For e.g. If the user clicks on a html file when |
474 // chrome is the default we should treat it as a parameter to be passed | 474 // chrome is the default we should treat it as a parameter to be passed |
475 // to chrome. | 475 // to chrome. |
476 if (display_name.find(installer::kChromeExe) != string16::npos) | 476 if (display_name.find(installer::kChromeExe) != base::string16::npos) |
477 display_name.clear(); | 477 display_name.clear(); |
478 break; | 478 break; |
479 | 479 |
480 default: | 480 default: |
481 break; | 481 break; |
482 } | 482 } |
483 | 483 |
484 CommandLine chrome( | 484 CommandLine chrome( |
485 delegate_execute::MakeChromeCommandLine(chrome_exe_, parameters_, | 485 delegate_execute::MakeChromeCommandLine(chrome_exe_, parameters_, |
486 display_name)); | 486 display_name)); |
487 string16 command_line(chrome.GetCommandLineString()); | 487 base::string16 command_line(chrome.GetCommandLineString()); |
488 | 488 |
489 AtlTrace("Formatted command line is %ls\n", command_line.c_str()); | 489 AtlTrace("Formatted command line is %ls\n", command_line.c_str()); |
490 | 490 |
491 PROCESS_INFORMATION temp_process_info = {}; | 491 PROCESS_INFORMATION temp_process_info = {}; |
492 BOOL ret = CreateProcess(chrome_exe_.value().c_str(), | 492 BOOL ret = CreateProcess(chrome_exe_.value().c_str(), |
493 const_cast<LPWSTR>(command_line.c_str()), | 493 const_cast<LPWSTR>(command_line.c_str()), |
494 NULL, NULL, FALSE, 0, NULL, NULL, &start_info_, | 494 NULL, NULL, FALSE, 0, NULL, NULL, &start_info_, |
495 &temp_process_info); | 495 &temp_process_info); |
496 if (ret) { | 496 if (ret) { |
497 base::win::ScopedProcessInformation proc_info(temp_process_info); | 497 base::win::ScopedProcessInformation proc_info(temp_process_info); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 AtlTrace("Invalid registry launch mode value %u\n", reg_value); | 562 AtlTrace("Invalid registry launch mode value %u\n", reg_value); |
563 launch_mode = ECHUIM_DESKTOP; | 563 launch_mode = ECHUIM_DESKTOP; |
564 } else { | 564 } else { |
565 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); | 565 launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value); |
566 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); | 566 AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]); |
567 } | 567 } |
568 | 568 |
569 launch_mode_determined = true; | 569 launch_mode_determined = true; |
570 return launch_mode; | 570 return launch_mode; |
571 } | 571 } |
OLD | NEW |