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

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: 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "chrome/installer/util/work_item_list.h" 52 #include "chrome/installer/util/work_item_list.h"
53 #include "components/variations/variations_associated_data.h" 53 #include "components/variations/variations_associated_data.h"
54 #include "content/public/browser/browser_thread.h" 54 #include "content/public/browser/browser_thread.h"
55 55
56 using content::BrowserThread; 56 using content::BrowserThread;
57 57
58 namespace shell_integration { 58 namespace shell_integration {
59 59
60 namespace { 60 namespace {
61 61
62 const wchar_t kAppListAppNameSuffix[] = L"AppList";
gab 2016/05/24 16:01:24 Inline as a "static base::char16[]" in GetAppListA
gab 2016/05/24 16:01:25 s/wchar_t/base::char16/ (identical on Windows but
tapted 2016/05/25 00:32:41 Done.
tapted 2016/05/25 00:32:41 Done.
63
62 // Helper function for GetAppId to generates profile id 64 // Helper function for GetAppId to generates profile id
63 // from profile path. "profile_id" is composed of sanitized basenames of 65 // from profile path. "profile_id" is composed of sanitized basenames of
64 // user data dir and profile dir joined by a ".". 66 // user data dir and profile dir joined by a ".".
65 base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) { 67 base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) {
66 // Return empty string if profile_path is empty 68 // Return empty string if profile_path is empty
67 if (profile_path.empty()) 69 if (profile_path.empty())
68 return base::string16(); 70 return base::string16();
69 71
70 base::FilePath default_user_data_dir; 72 base::FilePath default_user_data_dir;
71 // Return empty string if profile_path is in default user data 73 // Return empty string if profile_path is in default user data
(...skipping 16 matching lines...) Expand all
88 for (size_t i = 0; i < basenames.length(); ++i) { 90 for (size_t i = 0; i < basenames.length(); ++i) {
89 if (base::IsAsciiAlpha(basenames[i]) || 91 if (base::IsAsciiAlpha(basenames[i]) ||
90 base::IsAsciiDigit(basenames[i]) || 92 base::IsAsciiDigit(basenames[i]) ||
91 basenames[i] == L'.') 93 basenames[i] == L'.')
92 profile_id += basenames[i]; 94 profile_id += basenames[i];
93 } 95 }
94 96
95 return profile_id; 97 return profile_id;
96 } 98 }
97 99
100 base::string16 GetAppListAppName() {
101 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
102 base::string16 app_name(dist->GetBaseAppId());
103 app_name.append(kAppListAppNameSuffix);
104 return app_name;
105 }
106
98 // Gets expected app id for given Chrome (based on |command_line| and 107 // Gets expected app id for given Chrome (based on |command_line| and
99 // |is_per_user_install|). 108 // |is_per_user_install|).
100 base::string16 GetExpectedAppId(const base::CommandLine& command_line, 109 base::string16 GetExpectedAppId(const base::CommandLine& command_line,
101 bool is_per_user_install) { 110 bool is_per_user_install) {
102 base::FilePath user_data_dir; 111 base::FilePath user_data_dir;
103 if (command_line.HasSwitch(switches::kUserDataDir)) 112 if (command_line.HasSwitch(switches::kUserDataDir))
104 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir); 113 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir);
105 else 114 else
106 chrome::GetDefaultUserDataDirectory(&user_data_dir); 115 chrome::GetDefaultUserDataDirectory(&user_data_dir);
107 // Adjust with any policy that overrides any other way to set the path. 116 // Adjust with any policy that overrides any other way to set the path.
(...skipping 12 matching lines...) Expand all
120 129
121 base::FilePath profile_path = user_data_dir.Append(profile_subdir); 130 base::FilePath profile_path = user_data_dir.Append(profile_subdir);
122 base::string16 app_name; 131 base::string16 app_name;
123 if (command_line.HasSwitch(switches::kApp)) { 132 if (command_line.HasSwitch(switches::kApp)) {
124 app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL( 133 app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL(
125 GURL(command_line.GetSwitchValueASCII(switches::kApp)))); 134 GURL(command_line.GetSwitchValueASCII(switches::kApp))));
126 } else if (command_line.HasSwitch(switches::kAppId)) { 135 } else if (command_line.HasSwitch(switches::kAppId)) {
127 app_name = base::UTF8ToUTF16( 136 app_name = base::UTF8ToUTF16(
128 web_app::GenerateApplicationNameFromExtensionId( 137 web_app::GenerateApplicationNameFromExtensionId(
129 command_line.GetSwitchValueASCII(switches::kAppId))); 138 command_line.GetSwitchValueASCII(switches::kAppId)));
139 } else if (command_line.HasSwitch(switches::kShowAppList)) {
140 app_name = GetAppListAppName();
130 } else { 141 } else {
131 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 142 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
132 app_name = ShellUtil::GetBrowserModelId(dist, is_per_user_install); 143 app_name = ShellUtil::GetBrowserModelId(dist, is_per_user_install);
133 } 144 }
134 DCHECK(!app_name.empty()); 145 DCHECK(!app_name.empty());
135 146
136 return win::GetAppModelIdForProfile(app_name, profile_path); 147 return win::GetAppModelIdForProfile(app_name, profile_path);
137 } 148 }
138 149
139 void MigrateTaskbarPinsCallback() { 150 void MigrateTaskbarPinsCallback() {
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 if (base::PathExists(shortcut)) 709 if (base::PathExists(shortcut))
699 return shortcut; 710 return shortcut;
700 } 711 }
701 712
702 return base::FilePath(); 713 return base::FilePath();
703 } 714 }
704 715
705 } // namespace win 716 } // namespace win
706 717
707 } // namespace shell_integration 718 } // 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