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

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

Issue 2005163002: Avoid clobbering the app list pinned taskbar shortcut on startup (for now). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments Created 4 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_win.h" 5 #include "chrome/browser/shell_integration_win.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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 for (size_t i = 0; i < basenames.length(); ++i) { 88 for (size_t i = 0; i < basenames.length(); ++i) {
89 if (base::IsAsciiAlpha(basenames[i]) || 89 if (base::IsAsciiAlpha(basenames[i]) ||
90 base::IsAsciiDigit(basenames[i]) || 90 base::IsAsciiDigit(basenames[i]) ||
91 basenames[i] == L'.') 91 basenames[i] == L'.')
92 profile_id += basenames[i]; 92 profile_id += basenames[i];
93 } 93 }
94 94
95 return profile_id; 95 return profile_id;
96 } 96 }
97 97
98 base::string16 GetAppListAppName() {
99 static const base::char16 kAppListAppNameSuffix[] = L"AppList";
100 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
101 base::string16 app_name(dist->GetBaseAppId());
102 app_name.append(kAppListAppNameSuffix);
103 return app_name;
104 }
105
98 // Gets expected app id for given Chrome (based on |command_line| and 106 // Gets expected app id for given Chrome (based on |command_line| and
99 // |is_per_user_install|). 107 // |is_per_user_install|).
100 base::string16 GetExpectedAppId(const base::CommandLine& command_line, 108 base::string16 GetExpectedAppId(const base::CommandLine& command_line,
101 bool is_per_user_install) { 109 bool is_per_user_install) {
102 base::FilePath user_data_dir; 110 base::FilePath user_data_dir;
103 if (command_line.HasSwitch(switches::kUserDataDir)) 111 if (command_line.HasSwitch(switches::kUserDataDir))
104 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir); 112 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir);
105 else 113 else
106 chrome::GetDefaultUserDataDirectory(&user_data_dir); 114 chrome::GetDefaultUserDataDirectory(&user_data_dir);
107 // Adjust with any policy that overrides any other way to set the path. 115 // Adjust with any policy that overrides any other way to set the path.
(...skipping 12 matching lines...) Expand all
120 128
121 base::FilePath profile_path = user_data_dir.Append(profile_subdir); 129 base::FilePath profile_path = user_data_dir.Append(profile_subdir);
122 base::string16 app_name; 130 base::string16 app_name;
123 if (command_line.HasSwitch(switches::kApp)) { 131 if (command_line.HasSwitch(switches::kApp)) {
124 app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL( 132 app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL(
125 GURL(command_line.GetSwitchValueASCII(switches::kApp)))); 133 GURL(command_line.GetSwitchValueASCII(switches::kApp))));
126 } else if (command_line.HasSwitch(switches::kAppId)) { 134 } else if (command_line.HasSwitch(switches::kAppId)) {
127 app_name = base::UTF8ToUTF16( 135 app_name = base::UTF8ToUTF16(
128 web_app::GenerateApplicationNameFromExtensionId( 136 web_app::GenerateApplicationNameFromExtensionId(
129 command_line.GetSwitchValueASCII(switches::kAppId))); 137 command_line.GetSwitchValueASCII(switches::kAppId)));
138 } else if (command_line.HasSwitch(switches::kShowAppList)) {
139 app_name = GetAppListAppName();
130 } else { 140 } else {
131 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 141 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
132 app_name = ShellUtil::GetBrowserModelId(dist, is_per_user_install); 142 app_name = ShellUtil::GetBrowserModelId(dist, is_per_user_install);
133 } 143 }
134 DCHECK(!app_name.empty()); 144 DCHECK(!app_name.empty());
135 145
136 return win::GetAppModelIdForProfile(app_name, profile_path); 146 return win::GetAppModelIdForProfile(app_name, profile_path);
137 } 147 }
138 148
139 void MigrateTaskbarPinsCallback() { 149 void MigrateTaskbarPinsCallback() {
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 if (base::PathExists(shortcut)) 708 if (base::PathExists(shortcut))
699 return shortcut; 709 return shortcut;
700 } 710 }
701 711
702 return base::FilePath(); 712 return base::FilePath();
703 } 713 }
704 714
705 } // namespace win 715 } // namespace win
706 716
707 } // namespace shell_integration 717 } // namespace shell_integration
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698