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 @@
#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
......
......@@ -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,
const GURL& source,
const GURL& referrer);
} // namespace file_metadata
} // namespace content
#endif // CONTENT_BROWSER_DOWNLOAD_FILE_METADATA_LINUX_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_
......@@ -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
......@@ -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
......@@ -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',
......
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