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

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

Issue 2321453002: c/browser, c/common, components S-W: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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) 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_linux.h" 5 #include "chrome/browser/shell_integration_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images, 276 std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images,
277 const base::FilePath& shortcut_filename) { 277 const base::FilePath& shortcut_filename) {
278 if (icon_images.empty()) 278 if (icon_images.empty())
279 return std::string(); 279 return std::string();
280 280
281 // TODO(phajdan.jr): Report errors from this function, possibly as infobars. 281 // TODO(phajdan.jr): Report errors from this function, possibly as infobars.
282 base::ScopedTempDir temp_dir; 282 base::ScopedTempDir temp_dir;
283 if (!temp_dir.CreateUniqueTempDir()) 283 if (!temp_dir.CreateUniqueTempDir())
284 return std::string(); 284 return std::string();
285 285
286 base::FilePath temp_file_path = temp_dir.path().Append( 286 base::FilePath temp_file_path =
287 shortcut_filename.ReplaceExtension("png")); 287 temp_dir.GetPath().Append(shortcut_filename.ReplaceExtension("png"));
288 std::string icon_name = temp_file_path.BaseName().RemoveExtension().value(); 288 std::string icon_name = temp_file_path.BaseName().RemoveExtension().value();
289 289
290 for (gfx::ImageFamily::const_iterator it = icon_images.begin(); 290 for (gfx::ImageFamily::const_iterator it = icon_images.begin();
291 it != icon_images.end(); ++it) { 291 it != icon_images.end(); ++it) {
292 int width = it->Width(); 292 int width = it->Width();
293 scoped_refptr<base::RefCountedMemory> png_data = it->As1xPNGBytes(); 293 scoped_refptr<base::RefCountedMemory> png_data = it->As1xPNGBytes();
294 if (png_data->size() == 0) { 294 if (png_data->size() == 0) {
295 // If the bitmap could not be encoded to PNG format, skip it. 295 // If the bitmap could not be encoded to PNG format, skip it.
296 LOG(WARNING) << "Could not encode icon " << icon_name << ".png at size " 296 LOG(WARNING) << "Could not encode icon " << icon_name << ".png at size "
297 << width << "."; 297 << width << ".";
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 bool CreateShortcutInApplicationsMenu(const base::FilePath& shortcut_filename, 379 bool CreateShortcutInApplicationsMenu(const base::FilePath& shortcut_filename,
380 const std::string& contents, 380 const std::string& contents,
381 const base::FilePath& directory_filename, 381 const base::FilePath& directory_filename,
382 const std::string& directory_contents) { 382 const std::string& directory_contents) {
383 base::ScopedTempDir temp_dir; 383 base::ScopedTempDir temp_dir;
384 if (!temp_dir.CreateUniqueTempDir()) 384 if (!temp_dir.CreateUniqueTempDir())
385 return false; 385 return false;
386 386
387 base::FilePath temp_directory_path; 387 base::FilePath temp_directory_path;
388 if (!directory_filename.empty()) { 388 if (!directory_filename.empty()) {
389 temp_directory_path = temp_dir.path().Append(directory_filename); 389 temp_directory_path = temp_dir.GetPath().Append(directory_filename);
390 390
391 int bytes_written = base::WriteFile(temp_directory_path, 391 int bytes_written = base::WriteFile(temp_directory_path,
392 directory_contents.data(), 392 directory_contents.data(),
393 directory_contents.length()); 393 directory_contents.length());
394 394
395 if (bytes_written != static_cast<int>(directory_contents.length())) 395 if (bytes_written != static_cast<int>(directory_contents.length()))
396 return false; 396 return false;
397 } 397 }
398 398
399 base::FilePath temp_file_path = temp_dir.path().Append(shortcut_filename); 399 base::FilePath temp_file_path = temp_dir.GetPath().Append(shortcut_filename);
400 400
401 int bytes_written = base::WriteFile(temp_file_path, contents.data(), 401 int bytes_written = base::WriteFile(temp_file_path, contents.data(),
402 contents.length()); 402 contents.length());
403 403
404 if (bytes_written != static_cast<int>(contents.length())) 404 if (bytes_written != static_cast<int>(contents.length()))
405 return false; 405 return false;
406 406
407 std::vector<std::string> argv; 407 std::vector<std::string> argv;
408 argv.push_back("xdg-desktop-menu"); 408 argv.push_back("xdg-desktop-menu");
409 argv.push_back("install"); 409 argv.push_back("install");
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 base::FilePath applications_menu = GetDataWriteLocation(env.get()); 1106 base::FilePath applications_menu = GetDataWriteLocation(env.get());
1107 applications_menu = applications_menu.AppendASCII("applications"); 1107 applications_menu = applications_menu.AppendASCII("applications");
1108 std::vector<base::FilePath> shortcut_filenames_app_menu = 1108 std::vector<base::FilePath> shortcut_filenames_app_menu =
1109 GetExistingProfileShortcutFilenames(profile_path, applications_menu); 1109 GetExistingProfileShortcutFilenames(profile_path, applications_menu);
1110 for (const auto& menu : shortcut_filenames_app_menu) { 1110 for (const auto& menu : shortcut_filenames_app_menu) {
1111 DeleteShortcutInApplicationsMenu(menu, base::FilePath(kDirectoryFilename)); 1111 DeleteShortcutInApplicationsMenu(menu, base::FilePath(kDirectoryFilename));
1112 } 1112 }
1113 } 1113 }
1114 1114
1115 } // namespace shell_integration_linux 1115 } // namespace shell_integration_linux
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_test_util.cc ('k') | chrome/browser/shell_integration_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698