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

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

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/eintr_wrapper.h" 17 #include "base/eintr_wrapper.h"
18 #include "base/environment.h" 18 #include "base/environment.h"
19 #include "base/file_path.h" 19 #include "base/file_path.h"
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/i18n/file_util_icu.h" 21 #include "base/i18n/file_util_icu.h"
22 #include "base/memory/scoped_temp_dir.h" 22 #include "base/memory/scoped_temp_dir.h"
23 #include "base/message_loop.h" 23 #include "base/message_loop.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "base/process_util.h" 25 #include "base/process_util.h"
26 #include "base/stringprintf.h"
26 #include "base/string_number_conversions.h" 27 #include "base/string_number_conversions.h"
27 #include "base/string_tokenizer.h" 28 #include "base/string_tokenizer.h"
28 #include "base/string_util.h"
29 #include "base/task.h" 29 #include "base/task.h"
30 #include "base/threading/thread.h" 30 #include "base/threading/thread.h"
31 #include "base/utf_string_conversions.h" 31 #include "base/utf_string_conversions.h"
32 #include "build/build_config.h" 32 #include "build/build_config.h"
33 #include "chrome/browser/web_applications/web_app.h" 33 #include "chrome/browser/web_applications/web_app.h"
34 #include "chrome/common/chrome_constants.h" 34 #include "chrome/common/chrome_constants.h"
35 #include "chrome/common/chrome_paths.h" 35 #include "chrome/common/chrome_paths.h"
36 #include "content/browser/browser_thread.h" 36 #include "content/browser/browser_thread.h"
37 #include "googleurl/src/gurl.h" 37 #include "googleurl/src/gurl.h"
38 #include "ui/gfx/codec/png_codec.h" 38 #include "ui/gfx/codec/png_codec.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } else if (tokenizer.token().substr(0, 5) == "Name=") { 400 } else if (tokenizer.token().substr(0, 5) == "Name=") {
401 std::string final_title = UTF16ToUTF8(title); 401 std::string final_title = UTF16ToUTF8(title);
402 // Make sure no endline characters can slip in and possibly introduce 402 // Make sure no endline characters can slip in and possibly introduce
403 // additional lines (like Exec, which makes it a security risk). Also 403 // additional lines (like Exec, which makes it a security risk). Also
404 // use the URL as a default when the title is empty. 404 // use the URL as a default when the title is empty.
405 if (final_title.empty() || 405 if (final_title.empty() ||
406 final_title.find("\n") != std::string::npos || 406 final_title.find("\n") != std::string::npos ||
407 final_title.find("\r") != std::string::npos) { 407 final_title.find("\r") != std::string::npos) {
408 final_title = url.spec(); 408 final_title = url.spec();
409 } 409 }
410 output_buffer += StringPrintf("Name=%s\n", final_title.c_str()); 410 output_buffer += base::StringPrintf("Name=%s\n", final_title.c_str());
411 } else if (tokenizer.token().substr(0, 11) == "GenericName" || 411 } else if (tokenizer.token().substr(0, 11) == "GenericName" ||
412 tokenizer.token().substr(0, 7) == "Comment" || 412 tokenizer.token().substr(0, 7) == "Comment" ||
413 tokenizer.token().substr(0, 1) == "#") { 413 tokenizer.token().substr(0, 1) == "#") {
414 // Skip comment lines. 414 // Skip comment lines.
415 } else if (tokenizer.token().substr(0, 9) == "MimeType=") { 415 } else if (tokenizer.token().substr(0, 9) == "MimeType=") {
416 // Skip MimeType lines, they are only relevant for a web browser 416 // Skip MimeType lines, they are only relevant for a web browser
417 // shortcut, not a web application shortcut. 417 // shortcut, not a web application shortcut.
418 } else if (tokenizer.token().substr(0, 15) == "StartupWMClass=") { 418 } else if (tokenizer.token().substr(0, 15) == "StartupWMClass=") {
419 // Skip StartupWMClass; it will certainly be wrong since we emit a 419 // Skip StartupWMClass; it will certainly be wrong since we emit a
420 // different one based on the app name below. 420 // different one based on the app name below.
421 } else if (tokenizer.token().substr(0, 5) == "Icon=" && 421 } else if (tokenizer.token().substr(0, 5) == "Icon=" &&
422 !icon_name.empty()) { 422 !icon_name.empty()) {
423 output_buffer += StringPrintf("Icon=%s\n", icon_name.c_str()); 423 output_buffer += base::StringPrintf("Icon=%s\n", icon_name.c_str());
424 } else { 424 } else {
425 output_buffer += tokenizer.token() + "\n"; 425 output_buffer += tokenizer.token() + "\n";
426 } 426 }
427 } 427 }
428 428
429 #if defined(TOOLKIT_USES_GTK) 429 #if defined(TOOLKIT_USES_GTK)
430 std::string wmclass = web_app::GetWMClassFromAppName(app_name); 430 std::string wmclass = web_app::GetWMClassFromAppName(app_name);
431 if (!wmclass.empty()) { 431 if (!wmclass.empty()) {
432 output_buffer += StringPrintf("StartupWMClass=%s\n", wmclass.c_str()); 432 output_buffer += base::StringPrintf("StartupWMClass=%s\n", wmclass.c_str());
433 } 433 }
434 #endif 434 #endif
435 435
436 return output_buffer; 436 return output_buffer;
437 } 437 }
438 438
439 // static 439 // static
440 void ShellIntegration::CreateDesktopShortcut( 440 void ShellIntegration::CreateDesktopShortcut(
441 const ShortcutInfo& shortcut_info, const std::string& shortcut_template) { 441 const ShortcutInfo& shortcut_info, const std::string& shortcut_template) {
442 // TODO(phajdan.jr): Report errors from this function, possibly as infobars. 442 // TODO(phajdan.jr): Report errors from this function, possibly as infobars.
(...skipping 15 matching lines...) Expand all
458 shortcut_info.extension_id, 458 shortcut_info.extension_id,
459 shortcut_info.title, 459 shortcut_info.title,
460 icon_name); 460 icon_name);
461 461
462 if (shortcut_info.create_on_desktop) 462 if (shortcut_info.create_on_desktop)
463 CreateShortcutOnDesktop(shortcut_filename, contents); 463 CreateShortcutOnDesktop(shortcut_filename, contents);
464 464
465 if (shortcut_info.create_in_applications_menu) 465 if (shortcut_info.create_in_applications_menu)
466 CreateShortcutInApplicationsMenu(shortcut_filename, contents); 466 CreateShortcutInApplicationsMenu(shortcut_filename, contents);
467 } 467 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/sync/glue/session_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698