diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 07:48:53 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-01 07:48:53 +0000 |
commit | b5ff7ab385273571a809832c52939e98e97455fa (patch) | |
tree | a04b83adbf90c19fb03bf0205955f3d4b8116e40 /chrome/browser/web_applications | |
parent | ea315d056841c6ea0f30f17b2e61ce930c1c5ccd (diff) | |
download | chromium_src-b5ff7ab385273571a809832c52939e98e97455fa.zip chromium_src-b5ff7ab385273571a809832c52939e98e97455fa.tar.gz chromium_src-b5ff7ab385273571a809832c52939e98e97455fa.tar.bz2 |
Split the location flags from ShortcutInfo into a new struct ShortcutLocations.
The majority of code using ShortcutInfo ignores these flags, making it hard to
reason about exactly when they will be respected. Now ShortcutLocations is
explicitly passed in all the places where it is required (relatively few).
Generally, shortcut creation makes use of these flags, whereas shortcut update
and deletion does not.
In a few places (web_app_ui: ShortcutInfoForExtensionAndProfile,
web_app_ui: CheckExistingShortcuts) these booleans were being assigned to, but
never read back. Deleted those assignments.
BUG=178964
Review URL: https://chromiumcodereview.appspot.com/12382011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app.cc | 12 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app.h | 19 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_android.cc | 3 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_linux.cc | 5 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_win.cc | 37 |
6 files changed, 47 insertions, 32 deletions
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc index 4af6705..d0b01a2 100644 --- a/chrome/browser/web_applications/web_app.cc +++ b/chrome/browser/web_applications/web_app.cc @@ -140,14 +140,16 @@ std::string GetExtensionIdFromApplicationName(const std::string& app_name) { return app_name.substr(prefix.length()); } -void CreateShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { +void CreateShortcuts( + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(base::IgnoreResult(&CreateShortcutsOnFileThread), - shortcut_info)); + shortcut_info, creation_locations)); } void DeleteAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { @@ -169,13 +171,15 @@ void UpdateAllShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info) { } bool CreateShortcutsOnFileThread( - const ShellIntegration::ShortcutInfo& shortcut_info) { + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations) { 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); + return internals::CreatePlatformShortcuts(shortcut_data_dir, shortcut_info, + creation_locations); } bool IsValidUrl(const GURL& url) { diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h index ced6064..ceacac2 100644 --- a/chrome/browser/web_applications/web_app.h +++ b/chrome/browser/web_applications/web_app.h @@ -47,8 +47,11 @@ 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 shortcuts to create. -void CreateShortcuts(const ShellIntegration::ShortcutInfo& shortcut_info); +// |shortcut_info| contains information about the shortcuts to create, and +// |creation_locations| contains information about where to create them. +void CreateShortcuts( + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations); // Delete all the shortcuts that have been created for the given // |shortcut_data| in the profile with |profile_path|. @@ -60,9 +63,11 @@ 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. +// 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::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations); // Returns true if given url is a valid web app url. bool IsValidUrl(const GURL& url); @@ -92,10 +97,12 @@ bool CheckAndSaveIcon(const base::FilePath& icon_file, const SkBitmap& image); // shortcuts. Used internally by CreateShortcutsOnFileThread. // |shortcut_data_path| is where to store any resources created for the // shortcut, and is also used as the UserDataDir for platform app shortcuts. -// |shortcut_info| contains info about the shortcut to create. +// |shortcut_info| contains info about the shortcut to create, and +// |creation_locations| contains information about where to create them. bool CreatePlatformShortcuts( const base::FilePath& shortcut_data_path, - const ShellIntegration::ShortcutInfo& shortcut_info); + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations); // Delete all the shortcuts we have added for this extension. This is the // platform specific implementation of the DeleteAllShortcuts function, and diff --git a/chrome/browser/web_applications/web_app_android.cc b/chrome/browser/web_applications/web_app_android.cc index b6ff730..b8165f7 100644 --- a/chrome/browser/web_applications/web_app_android.cc +++ b/chrome/browser/web_applications/web_app_android.cc @@ -9,7 +9,8 @@ namespace internals { bool CreatePlatformShortcuts( const base::FilePath& web_app_path, - const ShellIntegration::ShortcutInfo& shortcut_info) { + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations) { return true; } diff --git a/chrome/browser/web_applications/web_app_linux.cc b/chrome/browser/web_applications/web_app_linux.cc index 325911f..0378b2a 100644 --- a/chrome/browser/web_applications/web_app_linux.cc +++ b/chrome/browser/web_applications/web_app_linux.cc @@ -15,7 +15,8 @@ namespace internals { bool CreatePlatformShortcuts( const base::FilePath& web_app_path, - const ShellIntegration::ShortcutInfo& shortcut_info) { + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); scoped_ptr<base::Environment> env(base::Environment::Create()); @@ -26,7 +27,7 @@ bool CreatePlatformShortcuts( return false; } return ShellIntegrationLinux::CreateDesktopShortcut( - shortcut_info, shortcut_template); + shortcut_info, creation_locations, shortcut_template); } void DeletePlatformShortcuts( diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 5224191..2c61548 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -279,7 +279,8 @@ base::FilePath GetAppBundleByExtensionId(std::string extension_id) { bool CreatePlatformShortcuts( const base::FilePath& web_app_path, - const ShellIntegration::ShortcutInfo& shortcut_info) { + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& /*creation_locations*/) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID()); WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info, diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index 0fa8a04..399b086 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -74,26 +74,26 @@ bool ShouldUpdateIcon(const base::FilePath& icon_file, const SkBitmap& image) { } std::vector<base::FilePath> GetShortcutPaths( - ShellIntegration::ShortcutInfo shortcut_info) { + const ShellIntegration::ShortcutLocations& creation_locations) { // Shortcut paths under which to create shortcuts. std::vector<base::FilePath> shortcut_paths; // Locations to add to shortcut_paths. struct { - const bool& use_this_location; + bool use_this_location; int location_id; const wchar_t* sub_dir; } locations[] = { { - shortcut_info.create_on_desktop, + creation_locations.on_desktop, base::DIR_USER_DESKTOP, NULL }, { - shortcut_info.create_in_applications_menu, + creation_locations.in_applications_menu, base::DIR_START_MENU, NULL }, { - shortcut_info.create_in_quick_launch_bar, + creation_locations.in_quick_launch_bar, // For Win7, create_in_quick_launch_bar means pinning to taskbar. Use // base::PATH_START as a flag for this case. (base::win::GetVersion() >= base::win::VERSION_WIN7) ? @@ -202,13 +202,15 @@ base::FilePath GetShortcutExecutablePath( bool CreatePlatformShortcuts( const base::FilePath& web_app_path, - const ShellIntegration::ShortcutInfo& shortcut_info) { + const ShellIntegration::ShortcutInfo& shortcut_info, + const ShellIntegration::ShortcutLocations& creation_locations) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); // Shortcut paths under which to create shortcuts. - std::vector<base::FilePath> shortcut_paths = GetShortcutPaths(shortcut_info); + std::vector<base::FilePath> shortcut_paths = + GetShortcutPaths(creation_locations); - bool pin_to_taskbar = shortcut_info.create_in_quick_launch_bar && + bool pin_to_taskbar = creation_locations.in_quick_launch_bar && (base::win::GetVersion() >= base::win::VERSION_WIN7); // For Win7's pinning support, any shortcut could be used. So we only create @@ -334,18 +336,17 @@ void DeletePlatformShortcuts( DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); // Get all possible locations for shortcuts. - ShellIntegration::ShortcutInfo all_shortcuts_info = shortcut_info; - all_shortcuts_info.create_in_applications_menu = true; - all_shortcuts_info.create_in_quick_launch_bar = true; - all_shortcuts_info.create_on_desktop = true; - std::vector<base::FilePath> shortcut_locations = GetShortcutPaths( - all_shortcuts_info); + ShellIntegration::ShortcutLocations all_shortcut_locations; + all_shortcut_locations.in_applications_menu = true; + all_shortcut_locations.in_quick_launch_bar = true; + all_shortcut_locations.on_desktop = true; + std::vector<base::FilePath> shortcut_paths = GetShortcutPaths( + all_shortcut_locations); if (base::win::GetVersion() >= base::win::VERSION_WIN7) - shortcut_locations.push_back(web_app_path); + shortcut_paths.push_back(web_app_path); - for (std::vector<base::FilePath>::const_iterator i = - shortcut_locations.begin(); - i != shortcut_locations.end(); ++i) { + for (std::vector<base::FilePath>::const_iterator i = shortcut_paths.begin(); + i != shortcut_paths.end(); ++i) { std::vector<base::FilePath> shortcut_files = MatchingShortcutsForProfileAndExtension(*i, shortcut_info.profile_path, shortcut_info.title); |