| OLD | NEW |
| 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/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/i18n/file_util_icu.h" | 14 #include "base/i18n/file_util_icu.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 size, size); | 112 size, size); |
| 112 gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bmp); | 113 gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bmp); |
| 113 // We are on the UI thread, and this image is needed from the FILE thread, | 114 // We are on the UI thread, and this image is needed from the FILE thread, |
| 114 // for creating shortcut icon files. | 115 // for creating shortcut icon files. |
| 115 image_skia.MakeThreadSafe(); | 116 image_skia.MakeThreadSafe(); |
| 116 shortcut_info->favicon.Add(gfx::Image(image_skia)); | 117 shortcut_info->favicon.Add(gfx::Image(image_skia)); |
| 117 } else { | 118 } else { |
| 118 shortcut_info->favicon = image_family; | 119 shortcut_info->favicon = image_family; |
| 119 } | 120 } |
| 120 | 121 |
| 121 callback.Run(shortcut_info.Pass(), file_handlers_info); | 122 callback.Run(std::move(shortcut_info), file_handlers_info); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void IgnoreFileHandlersInfo( | 125 void IgnoreFileHandlersInfo( |
| 125 const web_app::ShortcutInfoCallback& shortcut_info_callback, | 126 const web_app::ShortcutInfoCallback& shortcut_info_callback, |
| 126 scoped_ptr<web_app::ShortcutInfo> shortcut_info, | 127 scoped_ptr<web_app::ShortcutInfo> shortcut_info, |
| 127 const extensions::FileHandlersInfo& file_handlers_info) { | 128 const extensions::FileHandlersInfo& file_handlers_info) { |
| 128 shortcut_info_callback.Run(shortcut_info.Pass()); | 129 shortcut_info_callback.Run(std::move(shortcut_info)); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void ScheduleCreatePlatformShortcut( | 132 void ScheduleCreatePlatformShortcut( |
| 132 web_app::ShortcutCreationReason reason, | 133 web_app::ShortcutCreationReason reason, |
| 133 const web_app::ShortcutLocations& locations, | 134 const web_app::ShortcutLocations& locations, |
| 134 scoped_ptr<web_app::ShortcutInfo> shortcut_info, | 135 scoped_ptr<web_app::ShortcutInfo> shortcut_info, |
| 135 const extensions::FileHandlersInfo& file_handlers_info) { | 136 const extensions::FileHandlersInfo& file_handlers_info) { |
| 136 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); | 137 base::FilePath shortcut_data_dir = GetShortcutDataDir(*shortcut_info); |
| 137 BrowserThread::PostTask( | 138 BrowserThread::PostTask( |
| 138 BrowserThread::FILE, FROM_HERE, | 139 BrowserThread::FILE, FROM_HERE, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 return; | 405 return; |
| 405 | 406 |
| 406 extensions::ExtensionRegistry* registry = | 407 extensions::ExtensionRegistry* registry = |
| 407 extensions::ExtensionRegistry::Get(profile); | 408 extensions::ExtensionRegistry::Get(profile); |
| 408 const extensions::Extension* extension = registry->GetExtensionById( | 409 const extensions::Extension* extension = registry->GetExtensionById( |
| 409 shortcut_info->extension_id, extensions::ExtensionRegistry::EVERYTHING); | 410 shortcut_info->extension_id, extensions::ExtensionRegistry::EVERYTHING); |
| 410 if (!extension) | 411 if (!extension) |
| 411 return; | 412 return; |
| 412 } | 413 } |
| 413 | 414 |
| 414 ScheduleCreatePlatformShortcut(reason, locations, shortcut_info.Pass(), | 415 ScheduleCreatePlatformShortcut(reason, locations, std::move(shortcut_info), |
| 415 file_handlers_info); | 416 file_handlers_info); |
| 416 } | 417 } |
| 417 | 418 |
| 418 void CreateNonAppShortcut(const ShortcutLocations& locations, | 419 void CreateNonAppShortcut(const ShortcutLocations& locations, |
| 419 scoped_ptr<ShortcutInfo> shortcut_info) { | 420 scoped_ptr<ShortcutInfo> shortcut_info) { |
| 420 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations, | 421 ScheduleCreatePlatformShortcut(SHORTCUT_CREATION_AUTOMATED, locations, |
| 421 shortcut_info.Pass(), | 422 std::move(shortcut_info), |
| 422 extensions::FileHandlersInfo()); | 423 extensions::FileHandlersInfo()); |
| 423 } | 424 } |
| 424 | 425 |
| 425 void CreateShortcuts(ShortcutCreationReason reason, | 426 void CreateShortcuts(ShortcutCreationReason reason, |
| 426 const ShortcutLocations& locations, | 427 const ShortcutLocations& locations, |
| 427 Profile* profile, | 428 Profile* profile, |
| 428 const extensions::Extension* app) { | 429 const extensions::Extension* app) { |
| 429 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 430 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 430 | 431 |
| 431 if (!ShouldCreateShortcutFor(reason, profile, app)) | 432 if (!ShouldCreateShortcutFor(reason, profile, app)) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 495 |
| 495 #if defined(OS_LINUX) | 496 #if defined(OS_LINUX) |
| 496 std::string GetWMClassFromAppName(std::string app_name) { | 497 std::string GetWMClassFromAppName(std::string app_name) { |
| 497 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); | 498 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 498 base::TrimString(app_name, "_", &app_name); | 499 base::TrimString(app_name, "_", &app_name); |
| 499 return app_name; | 500 return app_name; |
| 500 } | 501 } |
| 501 #endif | 502 #endif |
| 502 | 503 |
| 503 } // namespace web_app | 504 } // namespace web_app |
| OLD | NEW |