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" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "chrome/browser/extensions/extension_ui_util.h" |
15 #include "chrome/browser/extensions/image_loader.h" | 16 #include "chrome/browser/extensions/image_loader.h" |
16 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
17 #include "chrome/browser/favicon/favicon_tab_helper.h" | 18 #include "chrome/browser/favicon/favicon_tab_helper.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 22 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "extensions/browser/extension_registry.h" |
24 #include "extensions/common/constants.h" | 26 #include "extensions/common/constants.h" |
25 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/extension_set.h" |
26 #include "extensions/common/manifest_handlers/icons_handler.h" | 29 #include "extensions/common/manifest_handlers/icons_handler.h" |
27 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
28 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
30 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
32 #include "ui/gfx/image/image_family.h" | 35 #include "ui/gfx/image/image_family.h" |
33 #include "ui/gfx/image/image_skia.h" | 36 #include "ui/gfx/image/image_skia.h" |
34 #include "url/url_constants.h" | 37 #include "url/url_constants.h" |
35 | 38 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 288 } |
286 | 289 |
287 void UpdateShortcutInfoAndIconForApp(const extensions::Extension* extension, | 290 void UpdateShortcutInfoAndIconForApp(const extensions::Extension* extension, |
288 Profile* profile, | 291 Profile* profile, |
289 const ShortcutInfoCallback& callback) { | 292 const ShortcutInfoCallback& callback) { |
290 GetInfoForApp(extension, | 293 GetInfoForApp(extension, |
291 profile, | 294 profile, |
292 base::Bind(&IgnoreFileHandlersInfo, callback)); | 295 base::Bind(&IgnoreFileHandlersInfo, callback)); |
293 } | 296 } |
294 | 297 |
| 298 bool ShouldCreateShortcutFor(Profile* profile, |
| 299 const extensions::Extension* extension) { |
| 300 return extension->is_platform_app() && |
| 301 extension->location() != extensions::Manifest::COMPONENT && |
| 302 extensions::ui_util::ShouldDisplayInAppLauncher(extension, profile); |
| 303 } |
| 304 |
295 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, | 305 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, |
296 const std::string& extension_id, | 306 const std::string& extension_id, |
297 const GURL& url) { | 307 const GURL& url) { |
298 DCHECK(!profile_path.empty()); | 308 DCHECK(!profile_path.empty()); |
299 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname)); | 309 base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname)); |
300 | 310 |
301 if (!extension_id.empty()) { | 311 if (!extension_id.empty()) { |
302 return app_data_dir.AppendASCII( | 312 return app_data_dir.AppendASCII( |
303 GenerateApplicationNameFromExtensionId(extension_id)); | 313 GenerateApplicationNameFromExtensionId(extension_id)); |
304 } | 314 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 base::IgnoreResult(&web_app::internals::CreateShortcutsOnFileThread), | 377 base::IgnoreResult(&web_app::internals::CreateShortcutsOnFileThread), |
368 reason, locations, shortcut_info)); | 378 reason, locations, shortcut_info)); |
369 } | 379 } |
370 | 380 |
371 void CreateShortcuts(ShortcutCreationReason reason, | 381 void CreateShortcuts(ShortcutCreationReason reason, |
372 const ShortcutLocations& locations, | 382 const ShortcutLocations& locations, |
373 Profile* profile, | 383 Profile* profile, |
374 const extensions::Extension* app) { | 384 const extensions::Extension* app) { |
375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
376 | 386 |
| 387 if (!ShouldCreateShortcutFor(profile, app)) |
| 388 return; |
| 389 |
377 GetInfoForApp(app, | 390 GetInfoForApp(app, |
378 profile, | 391 profile, |
379 base::Bind(&CreateShortcutsWithInfo, reason, locations)); | 392 base::Bind(&CreateShortcutsWithInfo, reason, locations)); |
380 } | 393 } |
381 | 394 |
382 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { | 395 void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { |
383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
384 | 397 |
385 ShortcutInfo shortcut_info = | 398 ShortcutInfo shortcut_info = |
386 ShortcutInfoForExtensionAndProfile(app, profile); | 399 ShortcutInfoForExtensionAndProfile(app, profile); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 451 |
439 #if defined(OS_LINUX) | 452 #if defined(OS_LINUX) |
440 std::string GetWMClassFromAppName(std::string app_name) { | 453 std::string GetWMClassFromAppName(std::string app_name) { |
441 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); | 454 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); |
442 base::TrimString(app_name, "_", &app_name); | 455 base::TrimString(app_name, "_", &app_name); |
443 return app_name; | 456 return app_name; |
444 } | 457 } |
445 #endif | 458 #endif |
446 | 459 |
447 } // namespace web_app | 460 } // namespace web_app |
OLD | NEW |