| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/i18n/file_util_icu.h" | 10 #include "base/i18n/file_util_icu.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 callback.Run(shortcut_info, file_handlers_info); | 157 callback.Run(shortcut_info, file_handlers_info); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void GetInfoForApp(const extensions::Extension* extension, | 160 void GetInfoForApp(const extensions::Extension* extension, |
| 161 Profile* profile, | 161 Profile* profile, |
| 162 const InfoCallback& callback) { | 162 const InfoCallback& callback) { |
| 163 web_app::ShortcutInfo shortcut_info = | 163 web_app::ShortcutInfo shortcut_info = |
| 164 web_app::ShortcutInfoForExtensionAndProfile(extension, profile); | 164 web_app::ShortcutInfoForExtensionAndProfile(extension, profile); |
| 165 extensions::FileHandlersInfo file_handlers_info( | 165 extensions::FileHandlersInfo file_handlers_info; |
| 166 extensions::FileHandlers::GetFileHandlers(extension)); | 166 const std::vector<extensions::FileHandlerInfo>* file_handlers = |
| 167 extensions::FileHandlers::GetFileHandlers(extension); |
| 168 if (file_handlers) |
| 169 file_handlers_info.handlers = *file_handlers; |
| 167 | 170 |
| 168 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; | 171 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; |
| 169 for (size_t i = 0; i < kNumDesiredSizes; ++i) { | 172 for (size_t i = 0; i < kNumDesiredSizes; ++i) { |
| 170 int size = kDesiredSizes[i]; | 173 int size = kDesiredSizes[i]; |
| 171 extensions::ExtensionResource resource = | 174 extensions::ExtensionResource resource = |
| 172 extensions::IconsInfo::GetIconResource( | 175 extensions::IconsInfo::GetIconResource( |
| 173 extension, size, ExtensionIconSet::MATCH_EXACTLY); | 176 extension, size, ExtensionIconSet::MATCH_EXACTLY); |
| 174 if (!resource.empty()) { | 177 if (!resource.empty()) { |
| 175 info_list.push_back(extensions::ImageLoader::ImageRepresentation( | 178 info_list.push_back(extensions::ImageLoader::ImageRepresentation( |
| 176 resource, | 179 resource, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 return base::FilePath(file_name); | 244 return base::FilePath(file_name); |
| 242 } | 245 } |
| 243 | 246 |
| 244 bool CreateShortcutsOnFileThread( | 247 bool CreateShortcutsOnFileThread( |
| 245 ShortcutCreationReason reason, | 248 ShortcutCreationReason reason, |
| 246 const web_app::ShortcutLocations& locations, | 249 const web_app::ShortcutLocations& locations, |
| 247 const web_app::ShortcutInfo& shortcut_info) { | 250 const web_app::ShortcutInfo& shortcut_info) { |
| 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 249 | 252 |
| 250 return CreateShortcutsWithInfoOnFileThread( | 253 return CreateShortcutsWithInfoOnFileThread( |
| 251 reason, locations, shortcut_info, extensions::FileHandlersInfo(NULL)); | 254 reason, locations, shortcut_info, extensions::FileHandlersInfo()); |
| 252 } | 255 } |
| 253 | 256 |
| 254 } // namespace internals | 257 } // namespace internals |
| 255 | 258 |
| 256 web_app::ShortcutInfo::ShortcutInfo() | 259 web_app::ShortcutInfo::ShortcutInfo() |
| 257 : is_platform_app(false) { | 260 : is_platform_app(false) { |
| 258 } | 261 } |
| 259 | 262 |
| 260 web_app::ShortcutInfo::~ShortcutInfo() {} | 263 web_app::ShortcutInfo::~ShortcutInfo() {} |
| 261 | 264 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 474 |
| 472 #if defined(OS_LINUX) | 475 #if defined(OS_LINUX) |
| 473 std::string GetWMClassFromAppName(std::string app_name) { | 476 std::string GetWMClassFromAppName(std::string app_name) { |
| 474 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); | 477 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 475 base::TrimString(app_name, "_", &app_name); | 478 base::TrimString(app_name, "_", &app_name); |
| 476 return app_name; | 479 return app_name; |
| 477 } | 480 } |
| 478 #endif | 481 #endif |
| 479 | 482 |
| 480 } // namespace web_app | 483 } // namespace web_app |
| OLD | NEW |