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
parent 3d81b04e
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "content/browser/safe_util_win.h" #include "content/browser/safe_util_win.h"
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include "content/browser/file_metadata_mac.h" #include "content/browser/download/file_metadata_mac.h"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#include "content/browser/download/file_metadata_linux.h" #include "content/browser/download/file_metadata_linux.h"
#endif #endif
...@@ -468,10 +468,8 @@ void BaseFile::AnnotateWithSourceInformation() { ...@@ -468,10 +468,8 @@ void BaseFile::AnnotateWithSourceInformation() {
win_util::SetInternetZoneIdentifier(full_path_, win_util::SetInternetZoneIdentifier(full_path_,
UTF8ToWide(source_url_.spec())); UTF8ToWide(source_url_.spec()));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
file_metadata::AddQuarantineMetadataToFile(full_path_, source_url_, content::AddQuarantineMetadataToFile(full_path_, source_url_, referrer_url_);
referrer_url_); content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
file_metadata::AddOriginMetadataToFile(full_path_, source_url_,
referrer_url_);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_); content::AddOriginMetadataToFile(full_path_, source_url_, referrer_url_);
#endif #endif
......
...@@ -40,4 +40,4 @@ void AddOriginMetadataToFile(const FilePath& file, const GURL& source, ...@@ -40,4 +40,4 @@ void AddOriginMetadataToFile(const FilePath& file, const GURL& source,
} }
} }
} // namespace file_metadata } // namespace content
...@@ -26,6 +26,6 @@ CONTENT_EXPORT void AddOriginMetadataToFile(const FilePath& file, ...@@ -26,6 +26,6 @@ CONTENT_EXPORT void AddOriginMetadataToFile(const FilePath& file,
const GURL& source, const GURL& source,
const GURL& referrer); const GURL& referrer);
} // namespace file_metadata } // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_LINUX_H_ #endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_LINUX_H_
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_FILE_METADATA_MAC_H_ #ifndef CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_
#define CONTENT_BROWSER_FILE_METADATA_MAC_H_ #define CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_
class FilePath; class FilePath;
class GURL; class GURL;
namespace file_metadata { namespace content {
// Adds origin metadata to the file. // Adds origin metadata to the file.
// |source| should be the source URL for the download, and |referrer| should be // |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, ...@@ -23,6 +23,6 @@ void AddOriginMetadataToFile(const FilePath& file, const GURL& source,
void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source, void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source,
const GURL& referrer); const GURL& referrer);
} // namespace file_metadata } // namespace content
#endif // CONTENT_BROWSER_FILE_METADATA_MAC_H_ #endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_MAC_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 <ApplicationServices/ApplicationServices.h>
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "googleurl/src/gurl.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 // 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 // various attributes. Metadata is integrated with the system's Spotlight
...@@ -165,4 +165,4 @@ void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source, ...@@ -165,4 +165,4 @@ void AddQuarantineMetadataToFile(const FilePath& file, const GURL& source,
} }
} }
} // namespace file_metadata } // namespace content
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content {
namespace { namespace {
using std::istringstream; using std::istringstream;
...@@ -92,17 +93,14 @@ class FileMetadataLinuxTest : public testing::Test { ...@@ -92,17 +93,14 @@ class FileMetadataLinuxTest : public testing::Test {
// Check if the attributes are set on the file // Check if the attributes are set on the file
vector<string>::const_iterator pos = find(attr_names.begin(), vector<string>::const_iterator pos = find(attr_names.begin(),
attr_names.end(), content::kSourceURLAttrName); attr_names.end(), kSourceURLAttrName);
EXPECT_NE(pos, attr_names.end()); EXPECT_NE(pos, attr_names.end());
pos = find(attr_names.begin(), attr_names.end(), pos = find(attr_names.begin(), attr_names.end(), kReferrerURLAttrName);
content::kReferrerURLAttrName);
EXPECT_NE(pos, attr_names.end()); EXPECT_NE(pos, attr_names.end());
// Check if the attribute values are set correctly // Check if the attribute values are set correctly
CheckExtendedAttributeValue(content::kSourceURLAttrName, CheckExtendedAttributeValue(kSourceURLAttrName, source_url().spec());
source_url().spec()); CheckExtendedAttributeValue(kReferrerURLAttrName, referrer_url().spec());
CheckExtendedAttributeValue(content::kReferrerURLAttrName,
referrer_url().spec());
} }
private: private:
...@@ -115,15 +113,15 @@ class FileMetadataLinuxTest : public testing::Test { ...@@ -115,15 +113,15 @@ class FileMetadataLinuxTest : public testing::Test {
TEST_F(FileMetadataLinuxTest, CheckMetadataSetCorrectly) { TEST_F(FileMetadataLinuxTest, CheckMetadataSetCorrectly) {
if (!is_xattr_supported()) return; if (!is_xattr_supported()) return;
content::AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); AddOriginMetadataToFile(test_file(), source_url(), referrer_url());
VerifyAttributesAreSetCorrectly(); VerifyAttributesAreSetCorrectly();
} }
TEST_F(FileMetadataLinuxTest, SetMetadataMultipleTimes) { TEST_F(FileMetadataLinuxTest, SetMetadataMultipleTimes) {
if (!is_xattr_supported()) return; if (!is_xattr_supported()) return;
content::AddOriginMetadataToFile(test_file(), GURL dummy_url("http://www.dummy.com");
GURL("http://www.dummy.com"), GURL("http://www.dummy.com")); AddOriginMetadataToFile(test_file(), dummy_url, dummy_url);
content::AddOriginMetadataToFile(test_file(), source_url(), referrer_url()); AddOriginMetadataToFile(test_file(), source_url(), referrer_url());
VerifyAttributesAreSetCorrectly(); VerifyAttributesAreSetCorrectly();
} }
...@@ -131,35 +129,35 @@ TEST_F(FileMetadataLinuxTest, InvalidSourceURLTest) { ...@@ -131,35 +129,35 @@ TEST_F(FileMetadataLinuxTest, InvalidSourceURLTest) {
if (!is_xattr_supported()) return; if (!is_xattr_supported()) return;
GURL invalid_url; GURL invalid_url;
vector<string> attr_names; vector<string> attr_names;
content::AddOriginMetadataToFile(test_file(), invalid_url, referrer_url()); AddOriginMetadataToFile(test_file(), invalid_url, referrer_url());
GetExtendedAttributeNames(&attr_names); GetExtendedAttributeNames(&attr_names);
EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(),
content::kSourceURLAttrName)); kSourceURLAttrName));
CheckExtendedAttributeValue(content::kReferrerURLAttrName, CheckExtendedAttributeValue(kReferrerURLAttrName, referrer_url().spec());
referrer_url().spec());
} }
TEST_F(FileMetadataLinuxTest, InvalidReferrerURLTest) { TEST_F(FileMetadataLinuxTest, InvalidReferrerURLTest) {
if (!is_xattr_supported()) return; if (!is_xattr_supported()) return;
GURL invalid_url; GURL invalid_url;
vector<string> attr_names; vector<string> attr_names;
content::AddOriginMetadataToFile(test_file(), source_url(), invalid_url); AddOriginMetadataToFile(test_file(), source_url(), invalid_url);
GetExtendedAttributeNames(&attr_names); GetExtendedAttributeNames(&attr_names);
EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(),
content::kReferrerURLAttrName)); kReferrerURLAttrName));
CheckExtendedAttributeValue(content::kSourceURLAttrName, source_url().spec()); CheckExtendedAttributeValue(kSourceURLAttrName, source_url().spec());
} }
TEST_F(FileMetadataLinuxTest, InvalidURLsTest) { TEST_F(FileMetadataLinuxTest, InvalidURLsTest) {
if (!is_xattr_supported()) return; if (!is_xattr_supported()) return;
GURL invalid_url; GURL invalid_url;
vector<string> attr_names; vector<string> attr_names;
content::AddOriginMetadataToFile(test_file(), invalid_url, invalid_url); AddOriginMetadataToFile(test_file(), invalid_url, invalid_url);
GetExtendedAttributeNames(&attr_names); GetExtendedAttributeNames(&attr_names);
EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(), 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(), EXPECT_EQ(attr_names.end(), find(attr_names.begin(), attr_names.end(),
content::kReferrerURLAttrName)); kReferrerURLAttrName));
} }
} // namespace } // namespace
} // namespace content
...@@ -320,6 +320,8 @@ ...@@ -320,6 +320,8 @@
'browser/download/drag_download_util.h', 'browser/download/drag_download_util.h',
'browser/download/file_metadata_linux.cc', 'browser/download/file_metadata_linux.cc',
'browser/download/file_metadata_linux.h', '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.cc',
'browser/download/mhtml_generation_manager.h', 'browser/download/mhtml_generation_manager.h',
'browser/download/save_file.cc', 'browser/download/save_file.cc',
...@@ -340,8 +342,6 @@ ...@@ -340,8 +342,6 @@
'browser/fileapi/chrome_blob_storage_context.h', 'browser/fileapi/chrome_blob_storage_context.h',
'browser/fileapi/fileapi_message_filter.cc', 'browser/fileapi/fileapi_message_filter.cc',
'browser/fileapi/fileapi_message_filter.h', 'browser/fileapi/fileapi_message_filter.h',
'browser/file_metadata_mac.h',
'browser/file_metadata_mac.mm',
'browser/font_list_async.cc', 'browser/font_list_async.cc',
'browser/gamepad/data_fetcher.h', 'browser/gamepad/data_fetcher.h',
'browser/gamepad/gamepad_provider.cc', 'browser/gamepad/gamepad_provider.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment