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

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

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | 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/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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/files/file_enumerator.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "base/win/shortcut.h" 21 #include "base/win/shortcut.h"
21 #include "chrome/browser/app_icon_win.h" 22 #include "chrome/browser/app_icon_win.h"
22 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/profiles/profile_info_cache_observer.h" 24 #include "chrome/browser/profiles/profile_info_cache_observer.h"
24 #include "chrome/browser/profiles/profile_info_util.h" 25 #include "chrome/browser/profiles/profile_info_util.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // the specified |command_line|. If |include_empty_command_lines| is true, 227 // the specified |command_line|. If |include_empty_command_lines| is true,
227 // Chrome desktop shortcuts with empty command lines will also be included. 228 // Chrome desktop shortcuts with empty command lines will also be included.
228 void ListDesktopShortcutsWithCommandLine(const base::FilePath& chrome_exe, 229 void ListDesktopShortcutsWithCommandLine(const base::FilePath& chrome_exe,
229 const string16& command_line, 230 const string16& command_line,
230 bool include_empty_command_lines, 231 bool include_empty_command_lines,
231 std::vector<base::FilePath>* paths) { 232 std::vector<base::FilePath>* paths) {
232 base::FilePath user_shortcuts_directory; 233 base::FilePath user_shortcuts_directory;
233 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL)) 234 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL))
234 return; 235 return;
235 236
236 file_util::FileEnumerator enumerator(user_shortcuts_directory, false, 237 base::FileEnumerator enumerator(user_shortcuts_directory, false,
237 file_util::FileEnumerator::FILES); 238 base::FileEnumerator::FILES);
238 for (base::FilePath path = enumerator.Next(); !path.empty(); 239 for (base::FilePath path = enumerator.Next(); !path.empty();
239 path = enumerator.Next()) { 240 path = enumerator.Next()) {
240 string16 shortcut_command_line; 241 string16 shortcut_command_line;
241 if (!IsChromeShortcut(path, chrome_exe, &shortcut_command_line)) 242 if (!IsChromeShortcut(path, chrome_exe, &shortcut_command_line))
242 continue; 243 continue;
243 244
244 // TODO(asvitkine): Change this to build a CommandLine object and ensure all 245 // TODO(asvitkine): Change this to build a CommandLine object and ensure all
245 // args from |command_line| are present in the shortcut's CommandLine. This 246 // args from |command_line| are present in the shortcut's CommandLine. This
246 // will be more robust when |command_line| contains multiple args. 247 // will be more robust when |command_line| contains multiple args.
247 if ((shortcut_command_line.empty() && include_empty_command_lines) || 248 if ((shortcut_command_line.empty() && include_empty_command_lines) ||
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 397 }
397 } 398 }
398 399
399 // Returns true if any desktop shortcuts exist with target |chrome_exe|, 400 // Returns true if any desktop shortcuts exist with target |chrome_exe|,
400 // regardless of their command line arguments. 401 // regardless of their command line arguments.
401 bool ChromeDesktopShortcutsExist(const base::FilePath& chrome_exe) { 402 bool ChromeDesktopShortcutsExist(const base::FilePath& chrome_exe) {
402 base::FilePath user_shortcuts_directory; 403 base::FilePath user_shortcuts_directory;
403 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL)) 404 if (!GetDesktopShortcutsDirectories(&user_shortcuts_directory, NULL))
404 return false; 405 return false;
405 406
406 file_util::FileEnumerator enumerator(user_shortcuts_directory, false, 407 base::FileEnumerator enumerator(user_shortcuts_directory, false,
407 file_util::FileEnumerator::FILES); 408 base::FileEnumerator::FILES);
408 for (base::FilePath path = enumerator.Next(); !path.empty(); 409 for (base::FilePath path = enumerator.Next(); !path.empty();
409 path = enumerator.Next()) { 410 path = enumerator.Next()) {
410 if (IsChromeShortcut(path, chrome_exe, NULL)) 411 if (IsChromeShortcut(path, chrome_exe, NULL))
411 return true; 412 return true;
412 } 413 }
413 414
414 return false; 415 return false;
415 } 416 }
416 417
417 // Deletes all desktop shortcuts for the specified profile and also removes the 418 // Deletes all desktop shortcuts for the specified profile and also removes the
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 BrowserThread::PostTask( 701 BrowserThread::PostTask(
701 BrowserThread::FILE, FROM_HERE, 702 BrowserThread::FILE, FROM_HERE,
702 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, 703 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path,
703 old_shortcut_appended_name, new_shortcut_appended_name, 704 old_shortcut_appended_name, new_shortcut_appended_name,
704 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, 705 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode,
705 action)); 706 action));
706 707
707 cache->SetShortcutNameOfProfileAtIndex(profile_index, 708 cache->SetShortcutNameOfProfileAtIndex(profile_index,
708 new_shortcut_appended_name); 709 new_shortcut_appended_name);
709 } 710 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698