OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_ |
| 6 #define CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_ |
| 7 |
| 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" |
| 12 |
| 13 namespace content { |
| 14 class NotificationDetails; |
| 15 class NotificationSource; |
| 16 class WebContents; |
| 17 } |
| 18 |
| 19 namespace web_app { |
| 20 |
| 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 { |
| 27 public: |
| 28 explicit UpdateShortcutWorker(content::WebContents* web_contents); |
| 29 |
| 30 void Run(); |
| 31 |
| 32 private: |
| 33 // Overridden from content::NotificationObserver: |
| 34 virtual void Observe(int type, |
| 35 const content::NotificationSource& source, |
| 36 const content::NotificationDetails& details); |
| 37 |
| 38 // Downloads icon via the FaviconTabHelper. |
| 39 void DownloadIcon(); |
| 40 |
| 41 // Favicon download callback. |
| 42 void DidDownloadFavicon( |
| 43 int requested_size, |
| 44 int id, |
| 45 int http_status_code, |
| 46 const GURL& image_url, |
| 47 const std::vector<SkBitmap>& bitmaps, |
| 48 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 49 |
| 50 // Checks if shortcuts exists on desktop, start menu and quick launch. |
| 51 void CheckExistingShortcuts(); |
| 52 |
| 53 // Update shortcut files and icons. |
| 54 void UpdateShortcuts(); |
| 55 void UpdateShortcutsOnFileThread(); |
| 56 |
| 57 // Callback after shortcuts are updated. |
| 58 void OnShortcutsUpdated(bool); |
| 59 |
| 60 // Deletes the worker on UI thread where it gets created. |
| 61 void DeleteMe(); |
| 62 void DeleteMeOnUIThread(); |
| 63 |
| 64 content::NotificationRegistrar registrar_; |
| 65 |
| 66 // Underlying WebContents whose shortcuts will be updated. |
| 67 content::WebContents* web_contents_; |
| 68 |
| 69 // Icons info from web_contents_'s web app data. |
| 70 web_app::IconInfoList unprocessed_icons_; |
| 71 |
| 72 // Cached shortcut data from the web_contents_. |
| 73 ShellIntegration::ShortcutInfo shortcut_info_; |
| 74 |
| 75 // Our copy of profile path. |
| 76 base::FilePath profile_path_; |
| 77 |
| 78 // File name of shortcut/ico file based on app title. |
| 79 base::FilePath file_name_; |
| 80 |
| 81 // Existing shortcuts. |
| 82 std::vector<base::FilePath> shortcut_files_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(UpdateShortcutWorker); |
| 85 }; |
| 86 |
| 87 } // namespace web_app |
| 88 |
| 89 #endif // CHROME_BROWSER_WEB_APPLICATIONS_UPDATE_SHORTCUT_WORKER_WIN_H_ |
OLD | NEW |