| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
| 10 | 10 |
| 11 #include "app/win_util.h" | 11 #include "app/win_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 29 #include "chrome/installer/util/work_item_list.h" | 29 #include "chrome/installer/util/work_item_list.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // Helper function for ShellIntegration::GetAppId to generates profile id | 33 // Helper function for ShellIntegration::GetAppId to generates profile id |
| 34 // from profile path. "profile_id" is composed of sanitized basenames of | 34 // from profile path. "profile_id" is composed of sanitized basenames of |
| 35 // user data dir and profile dir joined by a ".". | 35 // user data dir and profile dir joined by a ".". |
| 36 std::wstring GetProfileIdFromPath(const FilePath& profile_path) { | 36 std::wstring GetProfileIdFromPath(const FilePath& profile_path) { |
| 37 // Return empty string if profile_path is empty | 37 // Return empty string if profile_path is empty |
| 38 if (profile_path.empty()) | 38 if (profile_path.empty()) |
| 39 return EmptyWString(); | 39 return std::wstring(); |
| 40 | 40 |
| 41 FilePath default_user_data_dir; | 41 FilePath default_user_data_dir; |
| 42 // Return empty string if profile_path is in default user data | 42 // Return empty string if profile_path is in default user data |
| 43 // dir and is the default profile. | 43 // dir and is the default profile. |
| 44 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && | 44 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && |
| 45 profile_path.DirName() == default_user_data_dir && | 45 profile_path.DirName() == default_user_data_dir && |
| 46 profile_path.BaseName().value() == chrome::kNotSignedInProfile) | 46 profile_path.BaseName().value() == chrome::kNotSignedInProfile) |
| 47 return EmptyWString(); | 47 return std::wstring(); |
| 48 | 48 |
| 49 // Get joined basenames of user data dir and profile. | 49 // Get joined basenames of user data dir and profile. |
| 50 std::wstring basenames = profile_path.DirName().BaseName().value() + | 50 std::wstring basenames = profile_path.DirName().BaseName().value() + |
| 51 L"." + profile_path.BaseName().value(); | 51 L"." + profile_path.BaseName().value(); |
| 52 | 52 |
| 53 std::wstring profile_id; | 53 std::wstring profile_id; |
| 54 profile_id.reserve(basenames.size()); | 54 profile_id.reserve(basenames.size()); |
| 55 | 55 |
| 56 // Generate profile_id from sanitized basenames. | 56 // Generate profile_id from sanitized basenames. |
| 57 for (size_t i = 0; i < basenames.length(); ++i) { | 57 for (size_t i = 0; i < basenames.length(); ++i) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 | 201 |
| 202 // App id should be less than 128 chars. | 202 // App id should be less than 128 chars. |
| 203 DCHECK(app_id.length() < 128); | 203 DCHECK(app_id.length() < 128); |
| 204 return app_id; | 204 return app_id; |
| 205 } | 205 } |
| 206 | 206 |
| 207 std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { | 207 std::wstring ShellIntegration::GetChromiumAppId(const FilePath& profile_path) { |
| 208 return GetAppId(chrome::kBrowserAppID, profile_path); | 208 return GetAppId(chrome::kBrowserAppID, profile_path); |
| 209 } | 209 } |
| OLD | NEW |