diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 09:26:22 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-19 09:26:22 +0000 |
commit | 777379d9865bad6a87c038da386ae0b0c53fea26 (patch) | |
tree | 075d830c0cc4d266ef832e5387d33461dc71d8ce /chrome/browser/web_applications | |
parent | da62657847fcc3d001ce2dbdc6f44d61e756eb1f (diff) | |
download | chromium_src-777379d9865bad6a87c038da386ae0b0c53fea26.zip chromium_src-777379d9865bad6a87c038da386ae0b0c53fea26.tar.gz chromium_src-777379d9865bad6a87c038da386ae0b0c53fea26.tar.bz2 |
Revert 188944 "[mac] Create app shortcuts in a subfolder of /App..."
The "CreateFailure" test is failing on Mac bots:
http://build.chromium.org/p/chromium.mac/buildstatus?builder=Mac10.6%20Tests%20%282%29&number=34198
> [mac] Create app shortcuts in a subfolder of /Applications
>
> App shortcuts will be created in /Applications/Chrome Apps.localized, to
> support future localization of the directory name (see
> https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/LocalizingPathnames.html
> for details)
>
> R=benwells@chromium.org, rsesek@chromium.org
> BUG=180745
>
>
> Review URL: https://chromiumcodereview.appspot.com/12912003
TBR=jeremya@chromium.org
Review URL: https://codereview.chromium.org/12916007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_applications')
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.h | 3 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_mac.mm | 38 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_mac_unittest.mm | 8 |
3 files changed, 18 insertions, 31 deletions
diff --git a/chrome/browser/web_applications/web_app_mac.h b/chrome/browser/web_applications/web_app_mac.h index 8f9b90c..177142a 100644 --- a/chrome/browser/web_applications/web_app_mac.h +++ b/chrome/browser/web_applications/web_app_mac.h @@ -43,7 +43,8 @@ class WebAppShortcutCreator { base::FilePath GetAppLoaderPath() const; // Returns a path to the destination where the app should be written to. - virtual base::FilePath GetDestinationPath() const; + virtual base::FilePath GetDestinationPath( + const base::FilePath& app_file_name) const; // Updates the plist inside |app_path| with information about the app. bool UpdatePlist(const base::FilePath& app_path) const; diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index 608b5b2..2c61548 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -80,24 +80,11 @@ bool AddBitmapImageRepToIconFamily(IconFamily* icon_family, } } -base::FilePath GetWritableApplicationsDirectory() { - base::FilePath path; - if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) && - file_util::PathIsWritable(path)) { - return path; - } - if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) - return path; - return base::FilePath(); -} - } // namespace namespace web_app { -const char kChromeAppDirName[] = "Chrome Apps.localized"; - WebAppShortcutCreator::WebAppShortcutCreator( const base::FilePath& user_data_dir, const ShellIntegration::ShortcutInfo& shortcut_info, @@ -132,15 +119,7 @@ bool WebAppShortcutCreator::CreateShortcut() { if (!UpdateIcon(staging_path)) return false; - base::FilePath dst_path = GetDestinationPath(); - if (dst_path.empty()) { - LOG(ERROR) << "Couldn't find an Applications directory to copy app to."; - return false; - } - if (!file_util::CreateDirectory(dst_path)) { - LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; - return false; - } + base::FilePath dst_path = GetDestinationPath(app_file_name); if (!file_util::CopyDirectory(staging_path, dst_path, true)) { LOG(ERROR) << "Copying app to dst path: " << dst_path.value() << " failed"; return false; @@ -158,11 +137,18 @@ base::FilePath WebAppShortcutCreator::GetAppLoaderPath() const { base::mac::NSToCFCast(@"app_mode_loader.app")); } -base::FilePath WebAppShortcutCreator::GetDestinationPath() const { - base::FilePath path = GetWritableApplicationsDirectory(); - if (path.empty()) +base::FilePath WebAppShortcutCreator::GetDestinationPath( + const base::FilePath& app_file_name) const { + base::FilePath path; + if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) && + file_util::PathIsWritable(path)) { + return path; + } + + if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) return path; - return path.Append(kChromeAppDirName); + + return base::FilePath(); } bool WebAppShortcutCreator::UpdatePlist(const base::FilePath& app_path) const { diff --git a/chrome/browser/web_applications/web_app_mac_unittest.mm b/chrome/browser/web_applications/web_app_mac_unittest.mm index 193412a..ee6b647 100644 --- a/chrome/browser/web_applications/web_app_mac_unittest.mm +++ b/chrome/browser/web_applications/web_app_mac_unittest.mm @@ -38,7 +38,7 @@ class WebAppShortcutCreatorMock : public web_app::WebAppShortcutCreator { UTF8ToUTF16("fake.cfbundleidentifier")) { } - MOCK_CONST_METHOD0(GetDestinationPath, base::FilePath()); + MOCK_CONST_METHOD1(GetDestinationPath, base::FilePath(const base::FilePath&)); MOCK_CONST_METHOD1(RevealGeneratedBundleInFinder, void (const base::FilePath&)); }; @@ -67,7 +67,7 @@ TEST(WebAppShortcutCreatorTest, CreateShortcut) { base::FilePath dst_path = dst_folder.Append(UTF16ToUTF8(info.title) + ".app"); NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); - EXPECT_CALL(shortcut_creator, GetDestinationPath()) + EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) .WillRepeatedly(Return(dst_folder)); EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path)); @@ -106,7 +106,7 @@ TEST(WebAppShortcutCreatorTest, RunShortcut) { base::FilePath dst_path = dst_folder.Append(UTF16ToUTF8(info.title) + ".app"); NiceMock<WebAppShortcutCreatorMock> shortcut_creator(info); - EXPECT_CALL(shortcut_creator, GetDestinationPath()) + EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) .WillRepeatedly(Return(dst_folder)); EXPECT_CALL(shortcut_creator, RevealGeneratedBundleInFinder(dst_path)); @@ -121,7 +121,7 @@ TEST(WebAppShortcutCreatorTest, RunShortcut) { TEST(WebAppShortcutCreatorTest, CreateFailure) { NiceMock<WebAppShortcutCreatorMock> shortcut_creator(GetShortcutInfo()); - EXPECT_CALL(shortcut_creator, GetDestinationPath()) + EXPECT_CALL(shortcut_creator, GetDestinationPath(_)) .WillRepeatedly(Return(base::FilePath("/non-existant/path/"))); EXPECT_FALSE(shortcut_creator.CreateShortcut()); } |