diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 09:18:50 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 09:18:50 +0000 |
commit | 86b5401aa4c221ea07185bb493bb9557d779be0e (patch) | |
tree | 7692a2c15897b02e99b3ece5a941abae6553c373 /chrome | |
parent | 4ea927b886af2654b5a193278c0bfb6c25b56fc7 (diff) | |
download | chromium_src-86b5401aa4c221ea07185bb493bb9557d779be0e.zip chromium_src-86b5401aa4c221ea07185bb493bb9557d779be0e.tar.gz chromium_src-86b5401aa4c221ea07185bb493bb9557d779be0e.tar.bz2 |
Set prop app id for chromium/application shortcut.
This is a follow up change after andrew's patch for win7 shortcut to
properly set app id for chromium/application shortcut.
- Move PKEY_AppUserModel_ID and code to set it from app/win_util.cc to
base/win_util.cc as SetAppIdForPropertyStore to share with file_util
shortcut code;
- Add an app_id args to file_util's CreateShortcutLink and
UpdateShortcutLink;
- Update code that calls the above two function in installer and
UserDataManager so that the chromium shortcuts are created with proper
app id (except the uninstall shortcut which is not tagged with any app
id).
- Move ComputeApplicationNameFromURL from Browser to web_app namespace
and use it as app id for application shortcut. This makes pinned
shortcut and browser window use the same app id and Win7 correctly
groups them;
- Rename ComputeApplicationNameFromURL to GenerateApplicationNameFromURL
per Ben's comments;
- Add a DCHECK in SetAppIdForPropertyStore to ensure app id is less than
128 chars and contains no space per msdn;
- Change default app id from IDS_PRODUCT_NAME to chrome::kBrowserAppName
BUG=28104
TEST=On Win7, pinned shortcut should no longer be separated from running instance of chrome for both chrome and web application.
Review URL: http://codereview.chromium.org/399045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 16 | ||||
-rw-r--r-- | chrome/browser/browser.h | 4 | ||||
-rw-r--r-- | chrome/browser/user_data_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 11 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.h | 5 | ||||
-rw-r--r-- | chrome/common/chrome_constants.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_constants.h | 3 | ||||
-rw-r--r-- | chrome/installer/setup/install.cc | 3 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.cc | 6 |
9 files changed, 39 insertions, 21 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index c13c6c9..23c6a08 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -50,6 +50,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/window_sizer.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/chrome_constants.h" @@ -234,7 +235,7 @@ void Browser::CreateBrowserWindow() { // Set the app user model id for this application to that of the application // name. See http://crbug.com/7028. win_util::SetAppIdForWindow(type_ & TYPE_APP ? app_name_ : - l10n_util::GetString(IDS_PRODUCT_NAME), + std::wstring(chrome::kBrowserAppID), window()->GetNativeHandle()); #endif @@ -318,7 +319,7 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { // static void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { - std::wstring app_name = ComputeApplicationNameFromURL(url); + std::wstring app_name = web_app::GenerateApplicationNameFromURL(url); RegisterAppPrefs(app_name); Browser* browser = Browser::CreateForApp(app_name, profile, false); @@ -2094,7 +2095,7 @@ bool Browser::IsApplication() const { void Browser::ConvertContentsToApplication(TabContents* contents) { const GURL& url = contents->controller().GetActiveEntry()->url(); - std::wstring app_name = ComputeApplicationNameFromURL(url); + std::wstring app_name = web_app::GenerateApplicationNameFromURL(url); RegisterAppPrefs(app_name); DetachContents(contents); @@ -3027,15 +3028,6 @@ void Browser::CloseFrame() { } // static -std::wstring Browser::ComputeApplicationNameFromURL(const GURL& url) { - std::string t; - t.append(url.host()); - t.append("_"); - t.append(url.path()); - return UTF8ToWide(t); -} - -// static void Browser::RegisterAppPrefs(const std::wstring& app_name) { // A set of apps that we've already started. static std::set<std::wstring>* g_app_names = NULL; diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 3e52a59..4fac987 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -704,10 +704,6 @@ class Browser : public TabStripModelDelegate, // after a return to the message loop. void CloseFrame(); - // Compute a deterministic name based on the URL. We use this pseudo name - // as a key to store window location per application URLs. - static std::wstring ComputeApplicationNameFromURL(const GURL& url); - FRIEND_TEST(BrowserTest, NoTabsInPopups); // Create a preference dictionary for the provided application name. This is diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc index bd2ba88..588f699 100644 --- a/chrome/browser/user_data_manager.cc +++ b/chrome/browser/user_data_manager.cc @@ -257,7 +257,8 @@ bool UserDataManager::CreateDesktopShortcutForProfile( args.c_str(), NULL, exe_path.c_str(), - 0); + 0, + chrome::kBrowserAppID); #else // TODO(port): should probably use freedesktop.org standard for desktop files. NOTIMPLEMENTED(); diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index ebf8387..f15f95d 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -270,7 +270,8 @@ bool CreateShortcutTask::CreateShortcut() { wide_switchs.c_str(), shortcut_info_.description.c_str(), icon_file.value().c_str(), - 0); + 0, + web_app::GenerateApplicationNameFromURL(shortcut_info_.url).c_str()); } if (success && pin_to_taskbar) { @@ -291,6 +292,14 @@ bool CreateShortcutTask::CreateShortcut() { namespace web_app { +std::wstring GenerateApplicationNameFromURL(const GURL& url) { + std::string t; + t.append(url.host()); + t.append("_"); + t.append(url.path()); + return UTF8ToWide(t); +} + void CreateShortcut( const FilePath& data_dir, const ShellIntegration::ShortcutInfo& shortcut_info, diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index f6c9612..9bcfe0f 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -11,6 +11,11 @@ namespace web_app { +// Compute a deterministic name based on the URL. We use this pseudo name +// as a key to store window location per application URLs in Browser and +// as app id for BrowserWindow, shortcut and jump list. +std::wstring GenerateApplicationNameFromURL(const GURL& url); + // Callback after user dismisses CreateShortcutView. "true" indicates // shortcut is created successfully. Otherwise, it is false. typedef Callback1<bool>::Type CreateShortcutCallback; diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index 81d03ea..1a936b5 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -59,6 +59,15 @@ const char kStatsFilename[] = "ChromeStats2"; const wchar_t kBrowserAppName[] = L"Chromium"; const char kStatsFilename[] = "ChromiumStats2"; #endif + +#if defined(OS_WIN) +#if defined(GOOGLE_CHROME_BUILD) +const wchar_t kBrowserAppID[] = L"Chrome"; +#else +const wchar_t kBrowserAppID[] = L"Chromium"; +#endif +#endif // defined(OS_WIN) + const wchar_t kMessageWindowClass[] = L"Chrome_MessageWindow"; const wchar_t kCrashReportLog[] = L"Reported Crashes.txt"; const wchar_t kTestingInterfaceDLL[] = L"testing_interface.dll"; diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index 946767f..4473f32 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -21,6 +21,9 @@ extern const FilePath::CharType kHelperProcessExecutablePath[]; extern const FilePath::CharType kFrameworkName[]; #endif extern const wchar_t kBrowserAppName[]; +#if defined(OS_WIN) +extern const wchar_t kBrowserAppID[]; +#endif // defined(OS_WIN) extern const wchar_t kMessageWindowClass[]; extern const wchar_t kCrashReportLog[]; extern const wchar_t kTestingInterfaceDLL[]; diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 002ccf1..143f5ba 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -279,7 +279,8 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, uninstall_link.value().c_str(), NULL, arguments.c_str(), - NULL, setup_exe.c_str(), 0); + NULL, setup_exe.c_str(), 0, + NULL); } // Update Desktop and Quick Launch shortcuts. If --create-new-shortcuts diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index f8022f0..d4b39cc 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -774,7 +774,8 @@ bool ShellUtil::UpdateChromeShortcut(const std::wstring& chrome_exe, NULL, // arguments description.c_str(), // description chrome_exe.c_str(), // icon file - icon_index); // icon index + icon_index, // icon index + chrome::kBrowserAppID); // app id } else { return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target shortcut.c_str(), // shortcut @@ -782,6 +783,7 @@ bool ShellUtil::UpdateChromeShortcut(const std::wstring& chrome_exe, NULL, // arguments description.c_str(), // description chrome_exe.c_str(), // icon file - 0); // icon index + 0, // icon index + chrome::kBrowserAppID); // app id } } |