diff options
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 19 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.h | 15 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_android.cc | 4 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_linux.cc | 8 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.mm | 9 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_win.cc | 17 |
6 files changed, 70 insertions, 2 deletions
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index e7558e5..654299e 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -38,6 +38,16 @@ void DeleteShortcutsOnFileThread( shortcut_data_dir, shortcut_info); } +void UpdateShortcutsOnFileThread( + const ShellIntegration::ShortcutInfo& shortcut_info) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + + FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory( + shortcut_info.profile_path, shortcut_info.extension_id, GURL()); + return web_app::internals::UpdatePlatformShortcuts( + shortcut_data_dir, shortcut_info); +} + } // namespace namespace web_app { @@ -148,6 +158,15 @@ void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { base::Bind(&DeleteShortcutsOnFileThread, shortcut_info)); } +void UpdateAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + BrowserThread::PostTask( + BrowserThread::FILE, + FROM_HERE, + base::Bind(&UpdateShortcutsOnFileThread, shortcut_info)); +} + bool CreateShortcutsOnFileThread( const ShellIntegration::ShortcutInfo& shortcut_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index 2322504..56b6612 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -47,13 +47,17 @@ std::string GenerateApplicationNameFromExtensionId(const std::string& id); std::string GetExtensionIdFromApplicationName(const std::string& app_name); // Creates shortcuts for web application based on given shortcut data. -// |shortcut_info| contains information about the shortcut to create. +// |shortcut_info| contains information about the shortcuts to create. void CreateShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); // Delete all the shortcuts that have been created for the given // |shortcut_data| in the profile with |profile_path|. void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); +// Updates shortcuts for web application based on given shortcut data. +// |shortcut_info| contains information about the shortcuts to update. +void UpdateAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); + // Creates a shortcut. Must be called on the file thread. This is used to // implement CreateShortcuts() above, and can also be used directly from the // file thread. |shortcut_info| contains info about the shortcut to create. @@ -95,11 +99,18 @@ bool CreatePlatformShortcuts( // Delete all the shortcuts we have added for this extension. This is the // platform specific implementation of the DeleteAllShortcuts function, and -// is executed on the FILE thread.. +// is executed on the FILE thread. void DeletePlatformShortcuts( const FilePath& shortcut_data_path, const ShellIntegration::ShortcutInfo& shortcut_info); +// Updates all the shortcuts we have added for this extension. This is the +// platform specific implementation of the UpdateAllShortcuts function, and +// is executed on the FILE thread. +void UpdatePlatformShortcuts( + const FilePath& shortcut_data_path, + const ShellIntegration::ShortcutInfo& shortcut_info); + // Sanitizes |name| and returns a version of it that is safe to use as an // on-disk file name . FilePath GetSanitizedFileName(const string16& name); diff --git a/chrome/browser/web_applications/web_app_android.cc b/chrome/browser/web_applications/web_app_android.cc index b5f00cf..2008ece 100644 --- a/chrome/browser/web_applications/web_app_android.cc +++ b/chrome/browser/web_applications/web_app_android.cc @@ -17,5 +17,9 @@ void DeletePlatformShortcuts( const FilePath& web_app_path, const ShellIntegration::ShortcutInfo& shortcut_info) {} +void UpdatePlatformShortcuts( + const FilePath& web_app_path, + const ShellIntegration::ShortcutInfo& shortcut_info) {} + } // namespace internals } // namespace web_app diff --git a/chrome/browser/web_applications/web_app_linux.cc b/chrome/browser/web_applications/web_app_linux.cc index c66968d..18ac835 100644 --- a/chrome/browser/web_applications/web_app_linux.cc +++ b/chrome/browser/web_applications/web_app_linux.cc @@ -10,6 +10,7 @@ #include "content/public/browser/browser_thread.h" namespace web_app { + namespace internals { bool CreatePlatformShortcuts( @@ -35,5 +36,12 @@ void DeletePlatformShortcuts( shortcut_info.extension_id); } +void UpdatePlatformShortcuts( + const FilePath& web_app_path, + const ShellIntegration::ShortcutInfo& shortcut_info) { + // TODO(benwells): Implement this. +} + } // namespace internals + } // namespace web_app diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index f373076..2ab8560 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -250,6 +250,7 @@ void WebAppShortcutCreator::RevealGeneratedBundleInFinder( } // namespace namespace web_app { + namespace internals { bool CreatePlatformShortcuts( @@ -269,5 +270,13 @@ void DeletePlatformShortcuts( // mac. } +void UpdatePlatformShortcuts( + const FilePath& web_app_path, + const ShellIntegration::ShortcutInfo& shortcut_info) { + // TODO(benwells): Implement this when shortcuts / weblings are enabled on + // mac. +} + } // namespace internals + } // namespace web_app diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index d1d5634..f1df116 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -296,6 +296,23 @@ bool CreatePlatformShortcuts( return success; } +void UpdatePlatformShortcuts( + const FilePath& web_app_path, + const ShellIntegration::ShortcutInfo& shortcut_info) { + // Generates file name to use with persisted ico and shortcut file. + FilePath file_name = + web_app::internals::GetSanitizedFileName(shortcut_info.title); + + // If an icon file exists, and is out of date, replace it with the new icon + // and let the shell know the icon has been modified. + FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension( + FILE_PATH_LITERAL(".ico")); + if (file_util::PathExists(icon_file)) { + web_app::internals::CheckAndSaveIcon(icon_file, + *shortcut_info.favicon.ToSkBitmap()); + } +} + void DeletePlatformShortcuts( const FilePath& web_app_path, const ShellIntegration::ShortcutInfo& shortcut_info) { |