summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 00:37:02 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 00:37:02 +0000
commitfe8fa4c54238b86c22940e7fd672b4b44846083c (patch)
tree37f2df5c2ba2338de01c830c2d688f372ef858de
parent8934a3b023fe473245c46edf3e7671552bf61188 (diff)
downloadchromium_src-fe8fa4c54238b86c22940e7fd672b4b44846083c.zip
chromium_src-fe8fa4c54238b86c22940e7fd672b4b44846083c.tar.gz
chromium_src-fe8fa4c54238b86c22940e7fd672b4b44846083c.tar.bz2
Fix issue 32106
Issue 32106 happens when user creates a browser window without creating desktop shortcut. In this case, Windows does not have sufficient relaunching info to support pinning the browser window. The fix is to create a shortcut in "User Pinned" folder which Win7 watches and would get relaunch info from it. Also fix a minor bug in win_util::SetAppIdForWindow that would make the function only work for Win7 but not above. BUG=32106 TEST=Verify fix for 32106. See comemnts #1 and #5 for repro steps. Review URL: http://codereview.chromium.org/660038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39963 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/win_util.cc2
-rw-r--r--chrome/browser/user_data_manager.cc24
-rw-r--r--chrome/browser/user_data_manager.h6
-rw-r--r--chrome/browser/views/new_profile_dialog.cc27
4 files changed, 51 insertions, 8 deletions
diff --git a/app/win_util.cc b/app/win_util.cc
index 4ad8b27..3e00b95 100644
--- a/app/win_util.cc
+++ b/app/win_util.cc
@@ -837,7 +837,7 @@ gfx::Font GetWindowTitleFont() {
void SetAppIdForWindow(const std::wstring& app_id, HWND hwnd) {
// This functionality is only available on Win7+.
- if (win_util::GetWinVersion() != win_util::WINVERSION_WIN7)
+ if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7)
return;
// Load Shell32.dll into memory.
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc
index fc31290..7694c88 100644
--- a/chrome/browser/user_data_manager.cc
+++ b/chrome/browser/user_data_manager.cc
@@ -264,13 +264,12 @@ void UserDataManager::GetProfiles(std::vector<std::wstring>* profiles) const {
}
}
-bool UserDataManager::CreateDesktopShortcutForProfile(
+bool UserDataManager::CreateShortcutForProfileInFolder(
+ const FilePath& folder,
const std::wstring& profile_name) const {
#if defined(OS_WIN)
std::wstring exe_path;
- std::wstring shortcut_path;
- if (!PathService::Get(base::FILE_EXE, &exe_path) ||
- !ShellUtil::GetDesktopPath(false, &shortcut_path))
+ if (!PathService::Get(base::FILE_EXE, &exe_path))
return false;
// Working directory.
@@ -290,7 +289,8 @@ bool UserDataManager::CreateDesktopShortcutForProfile(
IDS_START_IN_PROFILE_SHORTCUT_NAME,
profile_name);
shortcut_name.append(L".lnk");
- file_util::AppendToPath(&shortcut_path, shortcut_name);
+
+ std::wstring shortcut_path = folder.Append(shortcut_name).ToWStringHack();
// Profile path from user_data_dir.
FilePath profile_path = FilePath(user_data_dir).Append(
@@ -306,6 +306,20 @@ bool UserDataManager::CreateDesktopShortcutForProfile(
0,
ShellIntegration::GetChromiumAppId(profile_path).c_str());
#else
+ NOTIMPLEMENTED();
+ return false;
+#endif
+}
+
+bool UserDataManager::CreateDesktopShortcutForProfile(
+ const std::wstring& profile_name) const {
+#if defined(OS_WIN)
+ std::wstring desktop_path;
+ if (!ShellUtil::GetDesktopPath(false, &desktop_path))
+ return false;
+
+ return CreateShortcutForProfileInFolder(FilePath(desktop_path), profile_name);
+#else
// TODO(port): should probably use freedesktop.org standard for desktop files.
NOTIMPLEMENTED();
return false;
diff --git a/chrome/browser/user_data_manager.h b/chrome/browser/user_data_manager.h
index f7dfe17..edd63e9 100644
--- a/chrome/browser/user_data_manager.h
+++ b/chrome/browser/user_data_manager.h
@@ -14,6 +14,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+class FilePath;
class MessageLoop;
// Provides an abstraction of profiles on top of the user data directory
@@ -51,6 +52,11 @@ class UserDataManager {
// This function should be called on the file thread.
void GetProfiles(std::vector<std::wstring>* profiles) const;
+ // Creates a shortcut for the given profile name in |folder|.
+ // Returns false if the shortcut creation fails; true otherwise.
+ bool CreateShortcutForProfileInFolder(const FilePath& folder,
+ const std::wstring& profile_name) const;
+
// Creates a desktop shortcut for the given profile name.
// Returns false if the shortcut creation fails; true otherwise.
bool CreateDesktopShortcutForProfile(const std::wstring& profile_name) const;
diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc
index f580bb0..9672a7a 100644
--- a/chrome/browser/views/new_profile_dialog.cc
+++ b/chrome/browser/views/new_profile_dialog.cc
@@ -8,8 +8,10 @@
#include "app/l10n_util.h"
#include "app/message_box_flags.h"
-#include "base/logging.h"
+#include "base/file_util.h"
#include "base/i18n/file_util_icu.h"
+#include "base/logging.h"
+#include "base/path_service.h"
#include "chrome/browser/user_data_manager.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -19,6 +21,10 @@
#include "views/view.h"
#include "views/window/window.h"
+#if defined(OS_WIN)
+#include "base/win_util.h"
+#endif // defined(OS_WIN)
+
namespace browser {
// Declared in browser_dialogs.h so others don't have to depend on our header.
@@ -99,9 +105,26 @@ bool NewProfileDialog::Accept() {
return true;
}
// Create a desktop shortcut if the corresponding checkbox is checked.
- if (message_box_view_->IsCheckBoxSelected())
+ if (message_box_view_->IsCheckBoxSelected()) {
UserDataManager::Get()->CreateDesktopShortcutForProfile(
profile_name);
+ } else {
+#if defined(OS_WIN)
+ if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) {
+ // For Win7, we need to have a shortcut in a place that Windows would
+ // index to provide correct relaunch info.
+ // See http://crbug.com/32106
+ FilePath temp_path;
+ if (PathService::Get(base::DIR_APP_DATA, &temp_path)) {
+ temp_path = temp_path.Append(
+ L"Microsoft\\Internet Explorer\\Quick Launch\\User Pinned");
+ UserDataManager::Get()->CreateShortcutForProfileInFolder(
+ temp_path,
+ profile_name);
+ }
+ }
+#endif // defined(OS_WIN)
+ }
UserDataManager::Get()->LaunchChromeForProfile(profile_name);
UserDataManager::Get()->RefreshUserDataDirProfiles();