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

Side by Side Diff: chrome/browser/profiles/profile_shortcut_manager_win.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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/profiles/profile_shortcut_manager_win.h" 5 #include "chrome/browser/profiles/profile_shortcut_manager_win.h"
6 6
7 #include <shlobj.h> // For SHChangeNotify(). 7 #include <shlobj.h> // For SHChangeNotify().
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, 279 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory,
280 &system_shortcuts_directory)) { 280 &system_shortcuts_directory)) {
281 return; 281 return;
282 } 282 }
283 283
284 const base::FilePath old_shortcut_path = 284 const base::FilePath old_shortcut_path =
285 user_shortcuts_directory.Append(old_shortcut_filename); 285 user_shortcuts_directory.Append(old_shortcut_filename);
286 const base::FilePath new_shortcut_path = 286 const base::FilePath new_shortcut_path =
287 user_shortcuts_directory.Append(new_shortcut_filename); 287 user_shortcuts_directory.Append(new_shortcut_filename);
288 288
289 if (file_util::PathExists(old_shortcut_path)) { 289 if (base::PathExists(old_shortcut_path)) {
290 // Rename the old shortcut unless a system-level shortcut exists at the 290 // Rename the old shortcut unless a system-level shortcut exists at the
291 // destination, in which case the old shortcut is simply deleted. 291 // destination, in which case the old shortcut is simply deleted.
292 const base::FilePath possible_new_system_shortcut = 292 const base::FilePath possible_new_system_shortcut =
293 system_shortcuts_directory.Append(new_shortcut_filename); 293 system_shortcuts_directory.Append(new_shortcut_filename);
294 if (file_util::PathExists(possible_new_system_shortcut)) 294 if (base::PathExists(possible_new_system_shortcut))
295 base::Delete(old_shortcut_path, false); 295 base::Delete(old_shortcut_path, false);
296 else if (!RenameDesktopShortcut(old_shortcut_path, new_shortcut_path)) 296 else if (!RenameDesktopShortcut(old_shortcut_path, new_shortcut_path))
297 DLOG(ERROR) << "Could not rename Windows profile desktop shortcut."; 297 DLOG(ERROR) << "Could not rename Windows profile desktop shortcut.";
298 } else { 298 } else {
299 // If the shortcut does not exist, it may have been renamed by the user. In 299 // If the shortcut does not exist, it may have been renamed by the user. In
300 // that case, its name should not be changed. 300 // that case, its name should not be changed.
301 // It's also possible that a system-level shortcut exists instead - this 301 // It's also possible that a system-level shortcut exists instead - this
302 // should only be the case for the original Chrome shortcut from an 302 // should only be the case for the original Chrome shortcut from an
303 // installation. If that's the case, copy that one over - it will get its 303 // installation. If that's the case, copy that one over - it will get its
304 // properties updated by |CreateOrUpdateDesktopShortcutsForProfile()|. 304 // properties updated by |CreateOrUpdateDesktopShortcutsForProfile()|.
305 const base::FilePath possible_old_system_shortcut = 305 const base::FilePath possible_old_system_shortcut =
306 system_shortcuts_directory.Append(old_shortcut_filename); 306 system_shortcuts_directory.Append(old_shortcut_filename);
307 if (file_util::PathExists(possible_old_system_shortcut)) 307 if (base::PathExists(possible_old_system_shortcut))
308 base::CopyFile(possible_old_system_shortcut, new_shortcut_path); 308 base::CopyFile(possible_old_system_shortcut, new_shortcut_path);
309 } 309 }
310 } 310 }
311 311
312 // Updates all desktop shortcuts for the given profile to have the specified 312 // Updates all desktop shortcuts for the given profile to have the specified
313 // parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is 313 // parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is
314 // created if no existing ones were found. Whether non-profile shortcuts should 314 // created if no existing ones were found. Whether non-profile shortcuts should
315 // be updated is specified by |action|. Must be called on the FILE thread. 315 // be updated is specified by |action|. Must be called on the FILE thread.
316 void CreateOrUpdateDesktopShortcutsForProfile( 316 void CreateOrUpdateDesktopShortcutsForProfile(
317 const base::FilePath& profile_path, 317 const base::FilePath& profile_path,
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 BrowserThread::PostTask( 696 BrowserThread::PostTask(
697 BrowserThread::FILE, FROM_HERE, 697 BrowserThread::FILE, FROM_HERE,
698 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, 698 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path,
699 old_shortcut_appended_name, new_shortcut_appended_name, 699 old_shortcut_appended_name, new_shortcut_appended_name,
700 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, 700 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode,
701 action)); 701 action));
702 702
703 cache->SetShortcutNameOfProfileAtIndex(profile_index, 703 cache->SetShortcutNameOfProfileAtIndex(profile_index,
704 new_shortcut_appended_name); 704 new_shortcut_appended_name);
705 } 705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698