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

Side by Side Diff: chrome/browser/web_applications/web_app.cc

Issue 2110021: Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: fix win Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/web_applications/web_app.h" 5 #include "chrome/browser/web_applications/web_app.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ShellAPI.h> 8 #include <ShellAPI.h>
9 #endif // defined(OS_WIN) 9 #endif // defined(OS_WIN)
10 10
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 FilePath file_name = GetSanitizedFileName(shortcut_info_.title); 348 FilePath file_name = GetSanitizedFileName(shortcut_info_.title);
349 349
350 // Creates an ico file to use with shortcut. 350 // Creates an ico file to use with shortcut.
351 FilePath icon_file = web_app_path_.Append(file_name).ReplaceExtension( 351 FilePath icon_file = web_app_path_.Append(file_name).ReplaceExtension(
352 FILE_PATH_LITERAL(".ico")); 352 FILE_PATH_LITERAL(".ico"));
353 if (!CheckAndSaveIcon(icon_file, shortcut_info_.favicon)) { 353 if (!CheckAndSaveIcon(icon_file, shortcut_info_.favicon)) {
354 NOTREACHED(); 354 NOTREACHED();
355 return false; 355 return false;
356 } 356 }
357 357
358 std::wstring chrome_exe; 358 FilePath chrome_exe;
359 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { 359 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
360 NOTREACHED(); 360 NOTREACHED();
361 return false; 361 return false;
362 } 362 }
363 363
364 // Working directory. 364 // Working directory.
365 std::wstring chrome_folder = file_util::GetDirectoryFromPath(chrome_exe); 365 FilePath chrome_folder = chrome_exe.DirName();
366 366
367 std::string switches = 367 std::string switches =
368 ShellIntegration::GetCommandLineArgumentsCommon(shortcut_info_.url, 368 ShellIntegration::GetCommandLineArgumentsCommon(shortcut_info_.url,
369 shortcut_info_.extension_id); 369 shortcut_info_.extension_id);
370 std::wstring wide_switchs(UTF8ToWide(switches)); 370 std::wstring wide_switchs(UTF8ToWide(switches));
371 371
372 // Sanitize description 372 // Sanitize description
373 if (shortcut_info_.description.length() >= MAX_PATH) 373 if (shortcut_info_.description.length() >= MAX_PATH)
374 shortcut_info_.description.resize(MAX_PATH - 1); 374 shortcut_info_.description.resize(MAX_PATH - 1);
375 375
(...skipping 10 matching lines...) Expand all
386 ReplaceExtension(FILE_PATH_LITERAL(".lnk")); 386 ReplaceExtension(FILE_PATH_LITERAL(".lnk"));
387 387
388 int unique_number = download_util::GetUniquePathNumber(shortcut_file); 388 int unique_number = download_util::GetUniquePathNumber(shortcut_file);
389 if (unique_number == -1) { 389 if (unique_number == -1) {
390 success = false; 390 success = false;
391 continue; 391 continue;
392 } else if (unique_number > 0) { 392 } else if (unique_number > 0) {
393 download_util::AppendNumberToPath(&shortcut_file, unique_number); 393 download_util::AppendNumberToPath(&shortcut_file, unique_number);
394 } 394 }
395 395
396 success &= file_util::CreateShortcutLink(chrome_exe.c_str(), 396 success &= file_util::CreateShortcutLink(chrome_exe.value().c_str(),
397 shortcut_file.value().c_str(), 397 shortcut_file.value().c_str(),
398 chrome_folder.c_str(), 398 chrome_folder.value().c_str(),
399 wide_switchs.c_str(), 399 wide_switchs.c_str(),
400 shortcut_info_.description.c_str(), 400 shortcut_info_.description.c_str(),
401 icon_file.value().c_str(), 401 icon_file.value().c_str(),
402 0, 402 0,
403 app_id.c_str()); 403 app_id.c_str());
404 404
405 // Any shortcut would work for the pinning. We use the first one. 405 // Any shortcut would work for the pinning. We use the first one.
406 if (success && pin_to_taskbar && shortcut_to_pin.empty()) 406 if (success && pin_to_taskbar && shortcut_to_pin.empty())
407 shortcut_to_pin = shortcut_file; 407 shortcut_to_pin = shortcut_file;
408 } 408 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 757
758 void UpdateShortcutForTabContents(TabContents* tab_contents) { 758 void UpdateShortcutForTabContents(TabContents* tab_contents) {
759 #if defined(OS_WIN) 759 #if defined(OS_WIN)
760 // UpdateShortcutWorker will delete itself when it's done. 760 // UpdateShortcutWorker will delete itself when it's done.
761 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); 761 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents);
762 worker->Run(); 762 worker->Run();
763 #endif // defined(OS_WIN) 763 #endif // defined(OS_WIN)
764 } 764 }
765 765
766 }; // namespace web_app 766 }; // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698