diff options
author | cristian.patrasciuc@gmail.com <cristian.patrasciuc@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-28 23:22:57 +0000 |
---|---|---|
committer | cristian.patrasciuc@gmail.com <cristian.patrasciuc@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-28 23:22:57 +0000 |
commit | 5dd464d64e8e6862861244e355020076d82f6d1f (patch) | |
tree | 0d01e8851d0c2e1592f2803079d1aaa16b4c26a0 | |
parent | 3d81b04e91218a3626d34019294aa366498ba13f (diff) | |
download | chromium_src-5dd464d64e8e6862861244e355020076d82f6d1f.zip chromium_src-5dd464d64e8e6862861244e355020076d82f6d1f.tar.gz chromium_src-5dd464d64e8e6862861244e355020076d82f6d1f.tar.bz2 |
Moving file_metadata files under content/browser/download
Some cleanup of the file_metadata files (especially for Mac OS).
I moved them under content/browser/download and changed the
namespace to "content" to match the Linux implementation and the
style guide.
I also included a small change to the Linux-related unittests.
Review URL: https://chromiumcodereview.appspot.com/10821069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148910 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/download/base_file.cc | 8 | ||||
-rw-r--r-- | content/browser/download/file_metadata_linux.cc | 2 | ||||
-rw-r--r-- | content/browser/download/file_metadata_linux.h | 2 | ||||
-rw-r--r-- | content/browser/download/file_metadata_mac.h (renamed from content/browser/file_metadata_mac.h) | 10 | ||||
-rw-r--r-- | content/browser/download/file_metadata_mac.mm (renamed from content/browser/file_metadata_mac.mm) | 6 | ||||
-rw-r--r-- | content/browser/download/file_metadata_unittest_linux.cc | 40 | ||||
-rw-r--r-- | content/content_browser.gypi | 4 |
7 files changed, 34 insertions, 38 deletions
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc index 786e78c..1d5d1e2 100644 --- a/content/browser/download/base_file.cc +++ b/content/browser/download/base_file.cc @@ -26,7 +26,7 @@ #include "content/browser/safe_util_win.h" #elif defined(OS_MACOSX) -#include "content/browser/file_metadata_mac.h" +#include "content/browser/download/file_metadata_mac.h" #elif defined(OS_LINUX) #include "content/browser/download/file_metadata_linux.h" #endif @@ -468,10 +468,8 @@ void BaseFile::AnnotateWithSourceInformation() { win_util::SetInternetZoneIdentifier(full_path_, UTF8ToWide(source_url_.spec())); #elif defined(OS_MACOSX) - file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_, - referrer_url_); - file_metadata::AddOriginMetadataToFile(full_path_, source_url_, - referrer_url_); + content::AddQuarantineMetadataToFile(full_path_, source_url_, referrer_url_); + content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_); #elif defined(OS_LINUX) content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_); #endif diff --git a/content/browser/download/file_metadata_linux.cc b/content/browser/download/file_metadata_linux.cc index 5beece5..8f7001b 100644 --- a/content/browser/download/file_metadata_linux.cc +++ b/content/browser/download/file_metadata_linux.cc @@ -40,4 +40,4 @@ void AddOriginMetadataToFile(const FilePath& file, const GURL& source, } } -} // namespace file_metadata +} // namespace content diff --git a/content/browser/download/file_metadata_linux.h b/content/browser/download/file_metadata_linux.h index b735f6e..5494add 100644 --- a/content/browser/download/file_metadata_linux.h +++ b/content/browser/download/file_metadata_linux.h @@ -26,6 +26,6 @@ CONTENT_EXPORT void AddOriginMetadataToFile(const FilePath& file, const GURL& source, const GURL& referrer); -} // namespace file_metadata +} // namespace content #endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_LINUX_H_ diff --git a/content/browser/file_metadata_mac.h b/content/browser/download/file_metadata_mac.h index 1ed9fc6..7d63a3c 100644 --- a/content/browser/file_metadata_mac.h +++ b/content/browser/download/file_metadata_mac.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_FILE_METADATA_MAC_H_ -#define CONTENT_BROWSER_FILE_METADATA_MAC_H_ +#ifndef CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_ +#define CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_ class FilePath; class GURL; -namespace file_metadata { +namespace content { // Adds origin metadata to the file. // |source| should be the source URL for the download, and |referrer| should be @@ -23,6 +23,6 @@ void AddOriginMetadataToFile(const FilePath& file, const GURL& source, void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source, const GURL& referrer); -} // namespace file_metadata +} // namespace content -#endif // CONTENT_BROWSER_FILE_METADATA_MAC_H_ +#endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_ diff --git a/content/browser/file_metadata_mac.mm b/content/browser/download/file_metadata_mac.mm index d7d5ba8..8a60f44 100644 --- a/content/browser/file_metadata_mac.mm +++ b/content/browser/download/file_metadata_mac.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/file_metadata_mac.h" +#include "content/browser/download/file_metadata_mac.h" #include <ApplicationServices/ApplicationServices.h> #include <Foundation/Foundation.h> @@ -14,7 +14,7 @@ #include "base/mac/scoped_cftyperef.h" #include "googleurl/src/gurl.h" -namespace file_metadata { +namespace content { // As of Mac OS X 10.4 ("Tiger"), files can be tagged with metadata describing // various attributes. Metadata is integrated with the system's Spotlight @@ -165,4 +165,4 @@ void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source, } } -} // namespace file_metadata +} // namespace content diff --git a/content/browser/download/file_metadata_unittest_linux.cc b/content/browser/download/file_metadata_unittest_linux.cc index 40ed3e5..ec2041a 100644 --- a/content/browser/download/file_metadata_unittest_linux.cc +++ b/content/browser/download/file_metadata_unittest_linux.cc @@ -19,6 +19,7 @@ #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" +namespace content { namespace { using std::istringstream; @@ -92,17 +93,14 @@ class FileMetadataLinuxTest : public testing::Test { // Check if the attributes are set on the file vector<string>::const_iterator pos = find(attr_names.begin(), - attr_names.end(), content::kSourceURLAttrName); + attr_names.end(), kSourceURLAttrName); EXPECT_NE(pos, attr_names.end()); - pos = find(attr_names.begin(), attr_names.end(), - content::kReferrerURLAttrName); + pos = find(attr_names.begin(), attr_names.end(), kReferrerURLAttrName); EXPECT_NE(pos, attr_names.end()); // Check if the attribute values are set correctly - CheckExtendedAttributeValue(content::kSourceURLAttrName, - source_url().spec()); - CheckExtendedAttributeValue(content::kReferrerURLAttrName, - referrer_url().spec()); + CheckExtendedAttributeValue(kSourceURLAttrName, source_url().spec()); + CheckExtendedAttributeValue(kReferrerURLAttrName, referrer_url().spec()); } private: @@ -115,15 +113,15 @@ class FileMetadataLinuxTest : public testing::Test { TEST_F(FileMetadataLinuxTest, CheckMetadataSetCorrectly) { if (!is_xattr_supported()) return; - content::AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); + AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); VerifyAttributesAreSetCorrectly(); } TEST_F(FileMetadataLinuxTest, SetMetadataMultipleTimes) { if (!is_xattr_supported()) return; - content::AddOriginMetadataToFile(test_file(), - GURL("http://www.dummy.com"), GURL("http://www.dummy.com")); - content::AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); + GURL dummy_url("http://www.dummy.com"); + AddOriginMetadataToFile(test_file(), dummy_url, dummy_url); + AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); VerifyAttributesAreSetCorrectly(); } @@ -131,35 +129,35 @@ TEST_F(FileMetadataLinuxTest, InvalidSourceURLTest) { if (!is_xattr_supported()) return; GURL invalid_url; vector<string> attr_names; - content::AddOriginMetadataToFile(test_file(), invalid_url, referrer_url()); + AddOriginMetadataToFile(test_file(), invalid_url, referrer_url()); GetExtendedAttributeNames(&attr_names); EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), - content::kSourceURLAttrName)); - CheckExtendedAttributeValue(content::kReferrerURLAttrName, - referrer_url().spec()); + kSourceURLAttrName)); + CheckExtendedAttributeValue(kReferrerURLAttrName, referrer_url().spec()); } TEST_F(FileMetadataLinuxTest, InvalidReferrerURLTest) { if (!is_xattr_supported()) return; GURL invalid_url; vector<string> attr_names; - content::AddOriginMetadataToFile(test_file(), source_url(), invalid_url); + AddOriginMetadataToFile(test_file(), source_url(), invalid_url); GetExtendedAttributeNames(&attr_names); EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), - content::kReferrerURLAttrName)); - CheckExtendedAttributeValue(content::kSourceURLAttrName, source_url().spec()); + kReferrerURLAttrName)); + CheckExtendedAttributeValue(kSourceURLAttrName, source_url().spec()); } TEST_F(FileMetadataLinuxTest, InvalidURLsTest) { if (!is_xattr_supported()) return; GURL invalid_url; vector<string> attr_names; - content::AddOriginMetadataToFile(test_file(), invalid_url, invalid_url); + AddOriginMetadataToFile(test_file(), invalid_url, invalid_url); GetExtendedAttributeNames(&attr_names); EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), - content::kSourceURLAttrName)); + kSourceURLAttrName)); EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), - content::kReferrerURLAttrName)); + kReferrerURLAttrName)); } } // namespace +} // namespace content diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 074a209..0ffffc8 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -320,6 +320,8 @@ 'browser/download/drag_download_util.h', 'browser/download/file_metadata_linux.cc', 'browser/download/file_metadata_linux.h', + 'browser/download/file_metadata_mac.h', + 'browser/download/file_metadata_mac.mm', 'browser/download/mhtml_generation_manager.cc', 'browser/download/mhtml_generation_manager.h', 'browser/download/save_file.cc', @@ -340,8 +342,6 @@ 'browser/fileapi/chrome_blob_storage_context.h', 'browser/fileapi/fileapi_message_filter.cc', 'browser/fileapi/fileapi_message_filter.h', - 'browser/file_metadata_mac.h', - 'browser/file_metadata_mac.mm', 'browser/font_list_async.cc', 'browser/gamepad/data_fetcher.h', 'browser/gamepad/gamepad_provider.cc', |