| 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/extension_ui_util.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | |
| 17 #include "chrome/browser/favicon/favicon_tab_helper.h" | |
| 18 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 22 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 23 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 24 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
| 25 #include "extensions/browser/image_loader.h" | 23 #include "extensions/browser/image_loader.h" |
| 26 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 27 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/extension_set.h" | 26 #include "extensions/common/extension_set.h" |
| 29 #include "extensions/common/manifest_handlers/icons_handler.h" | 27 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 30 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 31 #include "skia/ext/image_operations.h" | 29 #include "skia/ext/image_operations.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| 35 #include "ui/gfx/image/image_family.h" | 33 #include "ui/gfx/image/image_family.h" |
| 36 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
| 37 #include "url/url_constants.h" | 35 #include "url/url_constants.h" |
| 38 | 36 |
| 39 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 40 #include "ui/gfx/icon_util.h" | 38 #include "ui/gfx/icon_util.h" |
| 41 #endif | 39 #endif |
| 42 | 40 |
| 41 #if defined(TOOLKIT_VIEWS) |
| 42 #include "chrome/browser/extensions/tab_helper.h" |
| 43 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 44 #endif |
| 45 |
| 43 using content::BrowserThread; | 46 using content::BrowserThread; |
| 44 | 47 |
| 45 namespace { | 48 namespace { |
| 46 | 49 |
| 47 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
| 48 const int kDesiredSizes[] = {16, 32, 128, 256, 512}; | 51 const int kDesiredSizes[] = {16, 32, 128, 256, 512}; |
| 49 const size_t kNumDesiredSizes = arraysize(kDesiredSizes); | 52 const size_t kNumDesiredSizes = arraysize(kDesiredSizes); |
| 50 #elif defined(OS_LINUX) | 53 #elif defined(OS_LINUX) |
| 51 // Linux supports icons of any size. FreeDesktop Icon Theme Specification states | 54 // Linux supports icons of any size. FreeDesktop Icon Theme Specification states |
| 52 // that "Minimally you should install a 48x48 icon in the hicolor theme." | 55 // that "Minimally you should install a 48x48 icon in the hicolor theme." |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 233 } |
| 231 | 234 |
| 232 ShortcutInfo::~ShortcutInfo() {} | 235 ShortcutInfo::~ShortcutInfo() {} |
| 233 | 236 |
| 234 ShortcutLocations::ShortcutLocations() | 237 ShortcutLocations::ShortcutLocations() |
| 235 : on_desktop(false), | 238 : on_desktop(false), |
| 236 applications_menu_location(APP_MENU_LOCATION_NONE), | 239 applications_menu_location(APP_MENU_LOCATION_NONE), |
| 237 in_quick_launch_bar(false) { | 240 in_quick_launch_bar(false) { |
| 238 } | 241 } |
| 239 | 242 |
| 243 #if defined(TOOLKIT_VIEWS) |
| 240 void GetShortcutInfoForTab(content::WebContents* web_contents, | 244 void GetShortcutInfoForTab(content::WebContents* web_contents, |
| 241 ShortcutInfo* info) { | 245 ShortcutInfo* info) { |
| 242 DCHECK(info); // Must provide a valid info. | 246 DCHECK(info); // Must provide a valid info. |
| 243 | 247 |
| 244 const FaviconTabHelper* favicon_tab_helper = | 248 const FaviconTabHelper* favicon_tab_helper = |
| 245 FaviconTabHelper::FromWebContents(web_contents); | 249 FaviconTabHelper::FromWebContents(web_contents); |
| 246 const extensions::TabHelper* extensions_tab_helper = | 250 const extensions::TabHelper* extensions_tab_helper = |
| 247 extensions::TabHelper::FromWebContents(web_contents); | 251 extensions::TabHelper::FromWebContents(web_contents); |
| 248 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info(); | 252 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info(); |
| 249 | 253 |
| 250 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : | 254 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : |
| 251 app_info.app_url; | 255 app_info.app_url; |
| 252 info->title = app_info.title.empty() ? | 256 info->title = app_info.title.empty() ? |
| 253 (web_contents->GetTitle().empty() ? base::UTF8ToUTF16(info->url.spec()) : | 257 (web_contents->GetTitle().empty() ? base::UTF8ToUTF16(info->url.spec()) : |
| 254 web_contents->GetTitle()) : | 258 web_contents->GetTitle()) : |
| 255 app_info.title; | 259 app_info.title; |
| 256 info->description = app_info.description; | 260 info->description = app_info.description; |
| 257 info->favicon.Add(favicon_tab_helper->GetFavicon()); | 261 info->favicon.Add(favicon_tab_helper->GetFavicon()); |
| 258 | 262 |
| 259 Profile* profile = | 263 Profile* profile = |
| 260 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 264 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 261 info->profile_path = profile->GetPath(); | 265 info->profile_path = profile->GetPath(); |
| 262 } | 266 } |
| 267 #endif |
| 263 | 268 |
| 264 #if !defined(OS_WIN) | 269 #if !defined(OS_WIN) |
| 265 void UpdateShortcutForTabContents(content::WebContents* web_contents) {} | 270 void UpdateShortcutForTabContents(content::WebContents* web_contents) {} |
| 266 #endif | 271 #endif |
| 267 | 272 |
| 268 ShortcutInfo ShortcutInfoForExtensionAndProfile( | 273 ShortcutInfo ShortcutInfoForExtensionAndProfile( |
| 269 const extensions::Extension* app, Profile* profile) { | 274 const extensions::Extension* app, Profile* profile) { |
| 270 ShortcutInfo shortcut_info; | 275 ShortcutInfo shortcut_info; |
| 271 shortcut_info.extension_id = app->id(); | 276 shortcut_info.extension_id = app->id(); |
| 272 shortcut_info.is_platform_app = app->is_platform_app(); | 277 shortcut_info.is_platform_app = app->is_platform_app(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 448 |
| 444 #if defined(OS_LINUX) | 449 #if defined(OS_LINUX) |
| 445 std::string GetWMClassFromAppName(std::string app_name) { | 450 std::string GetWMClassFromAppName(std::string app_name) { |
| 446 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); | 451 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 447 base::TrimString(app_name, "_", &app_name); | 452 base::TrimString(app_name, "_", &app_name); |
| 448 return app_name; | 453 return app_name; |
| 449 } | 454 } |
| 450 #endif | 455 #endif |
| 451 | 456 |
| 452 } // namespace web_app | 457 } // namespace web_app |
| OLD | NEW |