diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 18:11:15 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 18:11:15 +0000 |
commit | 12f520c53db26ec0dc45f263904d8995e809e800 (patch) | |
tree | defcb2b679cc43a1d0ebb85adcda4f606549883d /chrome/browser/shell_integration_win.cc | |
parent | a1ca40db95ac3c0dc8c12c42fe736c800d46c00b (diff) | |
download | chromium_src-12f520c53db26ec0dc45f263904d8995e809e800.zip chromium_src-12f520c53db26ec0dc45f263904d8995e809e800.tar.gz chromium_src-12f520c53db26ec0dc45f263904d8995e809e800.tar.bz2 |
Append profile info to win7 app id per issue 30414
Add profile info to app id for non-default profile so that win7 could
group chrome icons based on profile.
- Add a new chrome/common/win_util.h/cc to hold app id functions that
would include profile info for non-default profiles;
- Add unit test to the new GetChromiumAppId function;
- Browser and JumpList to use the GetChromiumAppId for BrowserWindow
and JumpList;
- UserDataManager to use it for shortcuts it creates;
- Make app id for web apps include profile info as well;
- Change web_app::UpdateShortcuts to just update shortcuts description,
icon and app id;
BUG=30414
TEST=Verify fix for issue 30414.
Review URL: http://codereview.chromium.org/506079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35634 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration_win.cc')
-rw-r--r-- | chrome/browser/shell_integration_win.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index 1042cd4..b35ac18 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc @@ -18,6 +18,8 @@ #include "base/task.h" #include "base/win_util.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_paths_internal.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/create_reg_key_work_item.h" #include "chrome/installer/util/set_reg_value_work_item.h" @@ -26,6 +28,44 @@ #include "chrome/installer/util/work_item.h" #include "chrome/installer/util/work_item_list.h" +namespace { + +// Helper function for ShellIntegration::GetAppId to generates profile id +// from profile path. "profile_id" is composed of sanitized basenames of +// user data dir and profile dir joined by a ".". +std::wstring GetProfileIdFromPath(const FilePath& profile_path) { + // Return empty string if profile_path is empty + if (profile_path.empty()) + return EmptyWString(); + + FilePath default_user_data_dir; + // Return empty string if profile_path is in default user data + // dir and is the default profile. + if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && + profile_path.DirName() == default_user_data_dir && + profile_path.BaseName().value() == chrome::kNotSignedInProfile) + return EmptyWString(); + + // Get joined basenames of user data dir and profile. + std::wstring basenames = profile_path.DirName().BaseName().value() + + L"." + profile_path.BaseName().value(); + + std::wstring profile_id; + profile_id.reserve(basenames.size()); + + // Generate profile_id from sanitized basenames. + for (size_t i = 0; i < basenames.length(); ++i) { + if (IsAsciiAlpha(basenames[i]) || + IsAsciiDigit(basenames[i]) || + basenames[i] == L'.') + profile_id += basenames[i]; + } + + return profile_id; +} + +}; + bool ShellIntegration::SetAsDefaultBrowser() { std::wstring chrome_exe; if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { @@ -148,3 +188,22 @@ bool ShellIntegration::IsFirefoxDefaultBrowser() { } return ff_default; } + +std::wstring ShellIntegration::GetAppId(const wchar_t* app_name, + const FilePath& profile_path) { + std::wstring app_id(app_name); + + std::wstring profile_id(GetProfileIdFromPath(profile_path)); + if (!profile_id.empty()) { + app_id += L"."; + app_id += profile_id; + } + + // App id should be less than 128 chars. + DCHECK(app_id.length() < 128); + return app_id; +} + +std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { + return GetAppId(chrome::kBrowserAppID, profile_path); +} |