Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: chrome/browser/shell_integration_win.cc

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/shell_integration.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlwapi.h> 8 #include <shlwapi.h>
9 #include <shobjidl.h> 9 #include <shobjidl.h>
10 #include <propkey.h> // Needs to come after shobjidl.h. 10 #include <propkey.h> // Needs to come after shobjidl.h.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 base::string16 GetAppListAppName() { 85 base::string16 GetAppListAppName() {
86 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 86 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
87 base::string16 app_name(dist->GetBaseAppId()); 87 base::string16 app_name(dist->GetBaseAppId());
88 app_name.append(kAppListAppNameSuffix); 88 app_name.append(kAppListAppNameSuffix);
89 return app_name; 89 return app_name;
90 } 90 }
91 91
92 // Gets expected app id for given Chrome (based on |command_line| and 92 // Gets expected app id for given Chrome (based on |command_line| and
93 // |is_per_user_install|). 93 // |is_per_user_install|).
94 base::string16 GetExpectedAppId(const CommandLine& command_line, 94 base::string16 GetExpectedAppId(const base::CommandLine& command_line,
95 bool is_per_user_install) { 95 bool is_per_user_install) {
96 base::FilePath user_data_dir; 96 base::FilePath user_data_dir;
97 if (command_line.HasSwitch(switches::kUserDataDir)) 97 if (command_line.HasSwitch(switches::kUserDataDir))
98 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir); 98 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir);
99 else 99 else
100 chrome::GetDefaultUserDataDirectory(&user_data_dir); 100 chrome::GetDefaultUserDataDirectory(&user_data_dir);
101 // Adjust with any policy that overrides any other way to set the path. 101 // Adjust with any policy that overrides any other way to set the path.
102 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); 102 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir);
103 DCHECK(!user_data_dir.empty()); 103 DCHECK(!user_data_dir.empty());
104 104
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 base::string16 arguments; 454 base::string16 arguments;
455 base::win::ScopedPropVariant propvariant; 455 base::win::ScopedPropVariant propvariant;
456 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); 456 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
457 shortcut = shortcuts_enum.Next()) { 457 shortcut = shortcuts_enum.Next()) {
458 // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once 458 // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once
459 // it is fixed to work with FilePaths with spaces. 459 // it is fixed to work with FilePaths with spaces.
460 if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || 460 if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) ||
461 chrome_exe != target_path) { 461 chrome_exe != target_path) {
462 continue; 462 continue;
463 } 463 }
464 CommandLine command_line(CommandLine::FromString(base::StringPrintf( 464 base::CommandLine command_line(
465 L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str()))); 465 base::CommandLine::FromString(base::StringPrintf(
466 L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str())));
466 467
467 // Get the expected AppId for this Chrome shortcut. 468 // Get the expected AppId for this Chrome shortcut.
468 base::string16 expected_app_id( 469 base::string16 expected_app_id(
469 GetExpectedAppId(command_line, is_per_user_install)); 470 GetExpectedAppId(command_line, is_per_user_install));
470 if (expected_app_id.empty()) 471 if (expected_app_id.empty())
471 continue; 472 continue;
472 473
473 // Load the shortcut. 474 // Load the shortcut.
474 base::win::ScopedComPtr<IShellLink> shell_link; 475 base::win::ScopedComPtr<IShellLink> shell_link;
475 base::win::ScopedComPtr<IPersistFile> persist_file; 476 base::win::ScopedComPtr<IPersistFile> persist_file;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 576 }
576 577
577 shortcut = shortcut.Append(shortcut_name).Append(shortcut_name + 578 shortcut = shortcut.Append(shortcut_name).Append(shortcut_name +
578 installer::kLnkExt); 579 installer::kLnkExt);
579 if (base::PathExists(shortcut)) 580 if (base::PathExists(shortcut))
580 return shortcut; 581 return shortcut;
581 } 582 }
582 583
583 return base::FilePath(); 584 return base::FilePath();
584 } 585 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/signin/account_reconcilor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698