15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "base/callback.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/shell_integration.h"
16b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "chrome/common/web_application_info.h"
17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "extensions/common/manifest_handlers/file_handler_info.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
19e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass Profile;
20e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
21c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochnamespace content {
22c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass WebContents;
23c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch}
24c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace extensions {
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Extension;
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace gfx {
30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class ImageFamily;
31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
33a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// This namespace contains everything related to integrating Chrome apps into
34a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// the OS. E.g. creating and updating shorcuts for apps, setting up file
35a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// associations, etc.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace web_app {
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
38a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// Represents the info required to create a shortcut for an app.
39a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochstruct ShortcutInfo {
40a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  ShortcutInfo();
41a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  ~ShortcutInfo();
42a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
43a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  GURL url;
44a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // If |extension_id| is non-empty, this is short cut is to an extension-app
45a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // and the launch url will be detected at start-up. In this case, |url|
46a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // is still used to generate the app id (windows app id, not chrome app id).
47a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  std::string extension_id;
48a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  bool is_platform_app;
49a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  base::string16 title;
50a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  base::string16 description;
51a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  base::FilePath extension_path;
52a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  gfx::ImageFamily favicon;
53a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  base::FilePath profile_path;
54a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  std::string profile_name;
55a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch};
56a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
57a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// This specifies a folder in the system applications menu (e.g the Start Menu
58a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// on Windows).
59a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch//
60a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// These represent the applications menu root, the "Google Chrome" folder and
61a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// the "Chrome Apps" folder respectively.
62a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch//
63f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// APP_MENU_LOCATION_HIDDEN specifies a shortcut that is used to register the
64f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// app with the OS (in order to give its windows shelf icons, and correct icons
65f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// and titles), but the app should not show up in menus or search results.
66f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)//
67a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// NB: On Linux, these locations may not be used by the window manager (e.g
68a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// Unity and Gnome Shell).
69a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochenum ApplicationsMenuLocation {
70a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  APP_MENU_LOCATION_NONE,
71a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  APP_MENU_LOCATION_ROOT,
72a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  APP_MENU_LOCATION_SUBDIR_CHROME,
73a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  APP_MENU_LOCATION_SUBDIR_CHROMEAPPS,
74f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  APP_MENU_LOCATION_HIDDEN,
75a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch};
76a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
77a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// Info about which locations to create app shortcuts in.
78a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochstruct ShortcutLocations {
79a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  ShortcutLocations();
80a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
81a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  bool on_desktop;
82a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
83a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  ApplicationsMenuLocation applications_menu_location;
84a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
85a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // For Windows, this refers to quick launch bar prior to Win7. In Win7,
86a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // this means "pin to taskbar". For Mac/Linux, this could be used for
87a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // Mac dock or the gnome/kde application launcher. However, those are not
88a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // implemented yet.
89a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  bool in_quick_launch_bar;
90a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch};
91a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
92558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch// This encodes the cause of shortcut creation as the correct behavior in each
93558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch// case is implementation specific.
94558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdochenum ShortcutCreationReason {
95558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  SHORTCUT_CREATION_BY_USER,
96558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  SHORTCUT_CREATION_AUTOMATED,
97eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch};
98eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
99f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Called by GetInfoForApp after fetching the ShortcutInfo and FileHandlersInfo.
100f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)typedef base::Callback<void(const ShortcutInfo&,
101f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                            const extensions::FileHandlersInfo&)> InfoCallback;
102f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
103116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Called by GetShortcutInfoForApp after fetching the ShortcutInfo.
104cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)typedef base::Callback<void(const ShortcutInfo&)> ShortcutInfoCallback;
105e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
106116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#if defined(TOOLKIT_VIEWS)
107c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Extracts shortcut info of the given WebContents.
108c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochvoid GetShortcutInfoForTab(content::WebContents* web_contents,
109cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                           ShortcutInfo* info);
110116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif
111c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
112c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Updates web app shortcut of the WebContents. This function checks and
113c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// updates web app icon and shortcuts if needed. For icon, the check is based
114c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// on MD5 hash of icon image. For shortcuts, it checks the desktop, start menu
115c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// and quick launch (as well as pinned shortcut) for shortcut and only
116c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// updates (recreates) them if they exits.
117c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochvoid UpdateShortcutForTabContents(content::WebContents* web_contents);
118c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
119cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)ShortcutInfo ShortcutInfoForExtensionAndProfile(
120e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    const extensions::Extension* app,
121e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    Profile* profile);
122e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
123116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Populates a ShortcutInfo and FileHandlersInfo for the given |extension| in
124116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// |profile| and passes them to |callback| after asynchronously loading all icon
125116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// representations.
126116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid GetInfoForApp(const extensions::Extension* extension,
127116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                   Profile* profile,
128116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                   const InfoCallback& callback);
129116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
130116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Populates a ShortcutInfo for the given |extension| in |profile| and passes
131116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// it to |callback| after asynchronously loading all icon representations. This
132116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// is equivalent to GetInfoForApp, but it throws away the FileHandlersInfo.
133116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid GetShortcutInfoForApp(const extensions::Extension* extension,
134116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                           Profile* profile,
135116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch                           const ShortcutInfoCallback& callback);
136e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
13746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// Whether to create a shortcut for this type of extension.
13846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)bool ShouldCreateShortcutFor(Profile* profile,
13946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)                             const extensions::Extension* extension);
14046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the user data directory for given web app. The path for the directory is
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// based on |extension_id|. If |extension_id| is empty then |url| is used
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to construct a unique ID.
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      const std::string& extension_id,
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      const GURL& url);
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the user data directory to use for |extension| located inside
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |profile_path|.
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      const extensions::Extension& extension);
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Compute a deterministic name based on data in the shortcut_info.
154cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info);
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Compute a deterministic name based on the URL. We use this pseudo name
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as a key to store window location per application URLs in Browser and
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as app id for BrowserWindow, shortcut and jump list.
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GenerateApplicationNameFromURL(const GURL& url);
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Compute a deterministic name based on an extension/apps's id.
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GenerateApplicationNameFromExtensionId(const std::string& id);
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Extracts the extension id from the app name.
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GetExtensionIdFromApplicationName(const std::string& app_name);
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
167c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Create shortcuts for web application based on given shortcut data.
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |shortcut_info| contains information about the shortcuts to create, and
169116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// |locations| contains information about where to create them, while
170116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// |file_handlers_info| contains information about the file handlers to create.
171116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid CreateShortcutsWithInfo(
172116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    ShortcutCreationReason reason,
173116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    const ShortcutLocations& locations,
174116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    const ShortcutInfo& shortcut_info,
175116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    const extensions::FileHandlersInfo& file_handlers_info);
176c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch
177116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Creates shortcuts for an app. This loads the app's icon from disk, and calls
178116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// CreateShortcutsWithInfo(). If you already have a ShortcutInfo with the app's
179116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// icon loaded, you should use CreateShortcutsWithInfo() directly.
180cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void CreateShortcuts(ShortcutCreationReason reason,
181cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     const ShortcutLocations& locations,
182cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     Profile* profile,
183cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                     const extensions::Extension* app);
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Delete all shortcuts that have been created for the given profile and
186c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// extension.
187c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochvoid DeleteAllShortcuts(Profile* profile, const extensions::Extension* app);
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Updates shortcuts for web application based on given shortcut data. This
190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// refreshes existing shortcuts and their icons, but does not create new ones.
19190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// |old_app_title| contains the title of the app prior to this update.
192a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void UpdateAllShortcuts(const base::string16& old_app_title,
193c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                        Profile* profile,
194c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                        const extensions::Extension* app);
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
19646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// Updates shortcuts for all apps in this profile. This is expected to be called
19746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// on the UI thread.
19846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)void UpdateShortcutsForAllApps(Profile* profile,
19946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)                               const base::Closure& callback);
20046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if given url is a valid web app url.
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool IsValidUrl(const GURL& url);
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(TOOLKIT_VIEWS)
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Extracts icons info from web app data. Take only square shaped icons and
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sort them from smallest to largest.
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef std::vector<WebApplicationInfo::IconInfo> IconInfoList;
208cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void GetIconsInfo(const WebApplicationInfo& app_info, IconInfoList* icons);
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#if defined(OS_LINUX)
21258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Windows that correspond to web apps need to have a deterministic (and
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// different) WMClass than normal chrome windows so the window manager groups
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// them as a separate application.
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GetWMClassFromAppName(std::string app_name);
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace internals {
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
221a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Returns the Windows user-level shortcut paths that are specified in
222a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// |creation_locations|.
223c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)std::vector<base::FilePath> GetShortcutPaths(
224cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const ShortcutLocations& creation_locations);
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Implemented for each platform, does the platform specific parts of creating
228116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// shortcuts. Used internally by CreateShortcuts methods.
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |shortcut_data_path| is where to store any resources created for the
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// shortcut, and is also used as the UserDataDir for platform app shortcuts.
2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |shortcut_info| contains info about the shortcut to create, and
2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// |creation_locations| contains information about where to create them.
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool CreatePlatformShortcuts(
2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const base::FilePath& shortcut_data_path,
235cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const ShortcutInfo& shortcut_info,
236a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const extensions::FileHandlersInfo& file_handlers_info,
237cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const ShortcutLocations& creation_locations,
238558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch    ShortcutCreationReason creation_reason);
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Delete all the shortcuts we have added for this extension. This is the
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// platform specific implementation of the DeleteAllShortcuts function, and
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is executed on the FILE thread.
243cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void DeletePlatformShortcuts(const base::FilePath& shortcut_data_path,
244cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                             const ShortcutInfo& shortcut_info);
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Updates all the shortcuts we have added for this extension. This is the
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// platform specific implementation of the UpdateAllShortcuts function, and
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is executed on the FILE thread.
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void UpdatePlatformShortcuts(
2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const base::FilePath& shortcut_data_path,
251a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    const base::string16& old_app_title,
252cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const ShortcutInfo& shortcut_info,
253a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const extensions::FileHandlersInfo& file_handlers_info);
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Delete all the shortcuts for an entire profile.
256eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// This is executed on the FILE thread.
257eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochvoid DeleteAllShortcutsForProfile(const base::FilePath& profile_path);
258eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sanitizes |name| and returns a version of it that is safe to use as an
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// on-disk file name .
261a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)base::FilePath GetSanitizedFileName(const base::string16& name);
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace internals
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace web_app
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
268