1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_
6 #define CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_
8 #include "chrome/browser/shell_integration.h"
9 #include "chrome/browser/web_applications/web_app.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
14 class NotificationDetails
;
15 class NotificationSource
;
21 // UpdateShortcutWorker holds all context data needed for update shortcut.
22 // It schedules a pre-update check to find all shortcuts that needs to be
23 // updated. If there are such shortcuts, it schedules icon download and
24 // update them when icons are downloaded. It observes TAB_CLOSING notification
25 // and cancels all the work when the underlying tab is closing.
26 class UpdateShortcutWorker
: public content::NotificationObserver
{
28 explicit UpdateShortcutWorker(content::WebContents
* web_contents
);
33 // Overridden from content::NotificationObserver:
34 virtual void Observe(int type
,
35 const content::NotificationSource
& source
,
36 const content::NotificationDetails
& details
);
38 // Downloads icon via the FaviconTabHelper.
41 // Favicon download callback.
42 void DidDownloadFavicon(
46 const GURL
& image_url
,
47 const std::vector
<SkBitmap
>& bitmaps
,
48 const std::vector
<gfx::Size
>& original_bitmap_sizes
);
50 // Checks if shortcuts exists on desktop, start menu and quick launch.
51 void CheckExistingShortcuts();
53 // Update shortcut files and icons.
54 void UpdateShortcuts();
55 void UpdateShortcutsOnFileThread();
57 // Callback after shortcuts are updated.
58 void OnShortcutsUpdated(bool);
60 // Deletes the worker on UI thread where it gets created.
62 void DeleteMeOnUIThread();
64 content::NotificationRegistrar registrar_
;
66 // Underlying WebContents whose shortcuts will be updated.
67 content::WebContents
* web_contents_
;
69 // Icons info from web_contents_'s web app data.
70 web_app::IconInfoList unprocessed_icons_
;
72 // Cached shortcut data from the web_contents_.
73 web_app::ShortcutInfo shortcut_info_
;
75 // Our copy of profile path.
76 base::FilePath profile_path_
;
78 // File name of shortcut/ico file based on app title.
79 base::FilePath file_name_
;
81 // Existing shortcuts.
82 std::vector
<base::FilePath
> shortcut_files_
;
84 DISALLOW_COPY_AND_ASSIGN(UpdateShortcutWorker
);
87 } // namespace web_app
89 #endif // CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_