diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 05:45:56 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 05:45:56 +0000 |
commit | f8a312958582694a435f0da923da8b50612b7eb7 (patch) | |
tree | 9c1a4602b8361324b7fda4cfae1087947ae503c7 /chrome/browser/web_applications | |
parent | 381500970819966e039bf3221dec75f0f1affb70 (diff) | |
download | chromium_src-f8a312958582694a435f0da923da8b50612b7eb7.zip chromium_src-f8a312958582694a435f0da923da8b50612b7eb7.tar.gz chromium_src-f8a312958582694a435f0da923da8b50612b7eb7.tar.bz2 |
Revert of Make ShortcutManager directly pass Profile* and Extension* to web_app::CreateShortcuts. (https://codereview.chromium.org/205563005/)
Reason for revert:
Breaks build: http://build.chromium.org/p/chromium.linux/buildstatus?builder=Linux%20GTK%20Builder&number=2457
Original issue's description:
> Make ShortcutManager directly pass Profile* and Extension* to web_app::CreateShortcuts.
>
> This simplifies ShortcutManager as it no longer needs to create a
> ShortcutInfo. It also means we can add file handler info to just
> web_app.cc.
>
> The remaining code paths for "web_app::CreateShortcut*" are:
> create_application_shortcut_view
> create_application_shortcuts_dialog_gtk
> app_list_view_delegate.cc
> app_list_service_mac.mm
>
> All of the above do not need to pass file handler info.
>
> BUG=356889
> COLLABORATOR=mgiuca@chromium.org
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=261665
TBR=mgiuca@chromium.org,benwells@chromium.org,erg@google.com,sky@chromium.org,erg@chromium.org,jackhou@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=356889
Review URL: https://codereview.chromium.org/225183003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 76 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.h | 43 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.mm | 22 |
3 files changed, 58 insertions, 83 deletions
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index c31ccb7..0d90975 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -86,17 +86,6 @@ void UpdateShortcutsOnFileThread( shortcut_data_dir, old_app_title, shortcut_info); } -void UpdateAllShortcutsForShortcutInfo( - const base::string16& old_app_title, - const ShellIntegration::ShortcutInfo& shortcut_info) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - BrowserThread::PostTask( - BrowserThread::FILE, - FROM_HERE, - base::Bind(&UpdateShortcutsOnFileThread, old_app_title, shortcut_info)); -} - void OnImageLoaded(ShellIntegration::ShortcutInfo shortcut_info, web_app::ShortcutInfoCallback callback, const gfx::ImageFamily& image_family) { @@ -145,19 +134,6 @@ base::FilePath GetSanitizedFileName(const base::string16& name) { return base::FilePath(file_name); } -bool CreateShortcutsOnFileThread( - ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - const ShellIntegration::ShortcutInfo& shortcut_info) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - - base::FilePath shortcut_data_dir = GetWebAppDataDirectory( - shortcut_info.profile_path, shortcut_info.extension_id, - shortcut_info.url); - return internals::CreatePlatformShortcuts( - shortcut_data_dir, shortcut_info, locations, reason); -} - } // namespace internals void GetShortcutInfoForTab(content::WebContents* web_contents, @@ -322,52 +298,50 @@ std::string GetExtensionIdFromApplicationName(const std::string& app_name) { return app_name.substr(prefix.length()); } -void CreateShortcutsForShortcutInfo( - web_app::ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - const ShellIntegration::ShortcutInfo& shortcut_info) { +void CreateShortcuts( + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations, + ShortcutCreationReason creation_reason) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( - base::IgnoreResult(&web_app::internals::CreateShortcutsOnFileThread), - reason, locations, shortcut_info)); + base::Bind(base::IgnoreResult(&CreateShortcutsOnFileThread), + shortcut_info, creation_locations, creation_reason)); } -void CreateShortcuts( - ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - Profile* profile, - const extensions::Extension* app) { +void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - web_app::UpdateShortcutInfoAndIconForApp( - app, - profile, - base::Bind(&CreateShortcutsForShortcutInfo, reason, locations)); + BrowserThread::PostTask( + BrowserThread::FILE, + FROM_HERE, + base::Bind(&DeleteShortcutsOnFileThread, shortcut_info)); } -void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { +void UpdateAllShortcuts(const base::string16& old_app_title, + const ShellIntegration::ShortcutInfo& shortcut_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&DeleteShortcutsOnFileThread, - web_app::ShortcutInfoForExtensionAndProfile(app, profile))); + base::Bind(&UpdateShortcutsOnFileThread, old_app_title, shortcut_info)); } -void UpdateAllShortcuts(const base::string16& old_app_title, - Profile* profile, - const extensions::Extension* app) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +bool CreateShortcutsOnFileThread( + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations, + ShortcutCreationReason creation_reason) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - web_app::UpdateShortcutInfoAndIconForApp( - app, - profile, - base::Bind(&UpdateAllShortcutsForShortcutInfo, old_app_title)); + base::FilePath shortcut_data_dir = GetWebAppDataDirectory( + shortcut_info.profile_path, shortcut_info.extension_id, + shortcut_info.url); + return internals::CreatePlatformShortcuts(shortcut_data_dir, shortcut_info, + creation_locations, + creation_reason); } bool IsValidUrl(const GURL& url) { diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index 468bdba..79ea5a5 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -90,31 +90,33 @@ std::string GenerateApplicationNameFromExtensionId(const std::string& id); // Extracts the extension id from the app name. std::string GetExtensionIdFromApplicationName(const std::string& app_name); -// Create shortcuts for web application based on given shortcut data. +// Creates shortcuts for web application based on given shortcut data. // |shortcut_info| contains information about the shortcuts to create, and // |creation_locations| contains information about where to create them. -void CreateShortcutsForShortcutInfo( - web_app::ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - const ShellIntegration::ShortcutInfo& shortcut_info); - -// Creates shortcuts for an app. void CreateShortcuts( - ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - Profile* profile, - const extensions::Extension* app); + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations, + ShortcutCreationReason creation_reason); -// Delete all shortcuts that have been created for the given profile and -// extension. -void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app); +// 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. This // refreshes existing shortcuts and their icons, but does not create new ones. // |old_app_title| contains the title of the app prior to this update. +// |shortcut_info| contains information about the shortcuts to update. void UpdateAllShortcuts(const base::string16& old_app_title, - Profile* profile, - const extensions::Extension* app); + 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, and +// |creation_locations| contains information about where to create them. +bool CreateShortcutsOnFileThread( + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations, + ShortcutCreationReason creation_reason); // Returns true if given url is a valid web app url. bool IsValidUrl(const GURL& url); @@ -143,15 +145,6 @@ std::vector<base::FilePath> GetShortcutPaths( const ShellIntegration::ShortcutLocations& creation_locations); #endif -// 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, and -// |creation_locations| contains information about where to create them. -bool CreateShortcutsOnFileThread( - ShortcutCreationReason reason, - const ShellIntegration::ShortcutLocations& locations, - const ShellIntegration::ShortcutInfo& shortcut_info); - // Implemented for each platform, does the platform specific parts of creating // shortcuts. Used internally by CreateShortcutsOnFileThread. // |shortcut_data_path| is where to store any resources created for the diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 46b689b..903f243 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -417,6 +417,17 @@ ShellIntegration::ShortcutInfo BuildShortcutInfoFromBundle( return shortcut_info; } +void CreateShortcutsAndRunCallback( + const base::Closure& close_callback, + const ShellIntegration::ShortcutInfo& shortcut_info) { + // creation_locations will be ignored by CreatePlatformShortcuts on Mac. + ShellIntegration::ShortcutLocations creation_locations; + web_app::CreateShortcuts(shortcut_info, creation_locations, + web_app::SHORTCUT_CREATION_BY_USER); + if (!close_callback.is_null()) + close_callback.Run(); +} + } // namespace namespace chrome { @@ -426,13 +437,10 @@ void ShowCreateChromeAppShortcutsDialog(gfx::NativeWindow /*parent_window*/, const extensions::Extension* app, const base::Closure& close_callback) { // Normally we would show a dialog, but since we always create the app - // shortcut in ~/Applications there are no options for the user to choose. - web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER, - ShellIntegration::ShortcutLocations(), - profile, - app); - if (!close_callback.is_null()) - close_callback.Run(); + // shortcut in /Applications there are no options for the user to choose. + web_app::UpdateShortcutInfoAndIconForApp( + app, profile, + base::Bind(&CreateShortcutsAndRunCallback, close_callback)); } } // namespace chrome |