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/image_loader.h" | 15 #include "chrome/browser/extensions/image_loader.h" |
16 #include "chrome/browser/extensions/tab_helper.h" | |
17 #include "chrome/browser/favicon/favicon_tab_helper.h" | |
16 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
20 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 22 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
23 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.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" |
26 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
27 #include "skia/ext/image_operations.h" | 29 #include "skia/ext/image_operations.h" |
28 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
29 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
30 #include "ui/gfx/icon_util.h" | |
31 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
32 #include "ui/gfx/image/image_family.h" | 33 #include "ui/gfx/image/image_family.h" |
33 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
34 | 35 |
36 #if defined(OS_WIN) | |
37 #include "ui/gfx/icon_util.h" | |
38 #endif | |
39 | |
35 using content::BrowserThread; | 40 using content::BrowserThread; |
36 | 41 |
37 namespace { | 42 namespace { |
38 | 43 |
39 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
40 const int kDesiredSizes[] = {16, 32, 128, 256, 512}; | 45 const int kDesiredSizes[] = {16, 32, 128, 256, 512}; |
41 const size_t kNumDesiredSizes = arraysize(kDesiredSizes); | 46 const size_t kNumDesiredSizes = arraysize(kDesiredSizes); |
42 #elif defined(OS_LINUX) | 47 #elif defined(OS_LINUX) |
43 // Linux supports icons of any size. FreeDesktop Icon Theme Specification states | 48 // Linux supports icons of any size. FreeDesktop Icon Theme Specification states |
44 // that "Minimally you should install a 48x48 icon in the hicolor theme." | 49 // that "Minimally you should install a 48x48 icon in the hicolor theme." |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 base::string16 file_name = name; | 129 base::string16 file_name = name; |
125 #else | 130 #else |
126 std::string file_name = base::UTF16ToUTF8(name); | 131 std::string file_name = base::UTF16ToUTF8(name); |
127 #endif | 132 #endif |
128 file_util::ReplaceIllegalCharactersInPath(&file_name, '_'); | 133 file_util::ReplaceIllegalCharactersInPath(&file_name, '_'); |
129 return base::FilePath(file_name); | 134 return base::FilePath(file_name); |
130 } | 135 } |
131 | 136 |
132 } // namespace internals | 137 } // namespace internals |
133 | 138 |
139 void GetShortcutInfoForTab(content::WebContents* web_contents, | |
140 ShellIntegration::ShortcutInfo* info) { | |
141 DCHECK(info); // Must provide a valid info. | |
142 | |
143 const FaviconTabHelper* favicon_tab_helper = | |
144 FaviconTabHelper::FromWebContents(web_contents); | |
145 const extensions::TabHelper* extensions_tab_helper = | |
146 extensions::TabHelper::FromWebContents(web_contents); | |
147 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info(); | |
148 | |
149 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : | |
150 app_info.app_url; | |
151 info->title = app_info.title.empty() ? | |
152 (web_contents->GetTitle().empty() ? base::UTF8ToUTF16(info->url.spec()) : | |
benwells
2014/03/28 02:55:26
Is this clang format?
jackhou1
2014/04/02 03:25:56
This is just copied directly from web_app_ui.cc. I
| |
153 web_contents->GetTitle()) : | |
154 app_info.title; | |
155 info->description = app_info.description; | |
156 info->favicon.Add(favicon_tab_helper->GetFavicon()); | |
157 | |
158 Profile* profile = | |
159 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
160 info->profile_path = profile->GetPath(); | |
161 } | |
162 | |
134 ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile( | 163 ShellIntegration::ShortcutInfo ShortcutInfoForExtensionAndProfile( |
135 const extensions::Extension* app, Profile* profile) { | 164 const extensions::Extension* app, Profile* profile) { |
136 ShellIntegration::ShortcutInfo shortcut_info; | 165 ShellIntegration::ShortcutInfo shortcut_info; |
137 shortcut_info.extension_id = app->id(); | 166 shortcut_info.extension_id = app->id(); |
138 shortcut_info.is_platform_app = app->is_platform_app(); | 167 shortcut_info.is_platform_app = app->is_platform_app(); |
139 shortcut_info.url = extensions::AppLaunchInfo::GetLaunchWebURL(app); | 168 shortcut_info.url = extensions::AppLaunchInfo::GetLaunchWebURL(app); |
140 shortcut_info.title = base::UTF8ToUTF16(app->name()); | 169 shortcut_info.title = base::UTF8ToUTF16(app->name()); |
141 shortcut_info.description = base::UTF8ToUTF16(app->description()); | 170 shortcut_info.description = base::UTF8ToUTF16(app->description()); |
142 shortcut_info.extension_path = app->path(); | 171 shortcut_info.extension_path = app->path(); |
143 shortcut_info.profile_path = profile->GetPath(); | 172 shortcut_info.profile_path = profile->GetPath(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 | 377 |
349 #if defined(OS_LINUX) | 378 #if defined(OS_LINUX) |
350 std::string GetWMClassFromAppName(std::string app_name) { | 379 std::string GetWMClassFromAppName(std::string app_name) { |
351 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); | 380 file_util::ReplaceIllegalCharactersInPath(&app_name, '_'); |
352 base::TrimString(app_name, "_", &app_name); | 381 base::TrimString(app_name, "_", &app_name); |
353 return app_name; | 382 return app_name; |
354 } | 383 } |
355 #endif | 384 #endif |
356 | 385 |
357 } // namespace web_app | 386 } // namespace web_app |
OLD | NEW |