Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5055)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_util.h

Issue 1410343012: Revert of Move more declarations from c/b/sb/sb_util.h to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_components
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_util.h
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.h b/chrome/browser/safe_browsing/safe_browsing_util.h
index 9cbb3cd97583c7f99754b8bf56911ccc9e52ff89..b01f6a3d4e4607498e424d2f6cb2f3dc39b777b4 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.h
+++ b/chrome/browser/safe_browsing/safe_browsing_util.h
@@ -16,11 +16,13 @@
#include "base/strings/string_piece.h"
#include "base/time/time.h"
#include "chrome/browser/safe_browsing/chunk_range.h"
-#include "components/safe_browsing_db/util.h"
+#include "components/safe_browsing_db/safe_browsing_db_util.h"
namespace safe_browsing {
class ChunkData;
};
+
+class GURL;
// Container for holding a chunk URL and the list it belongs to.
struct ChunkUrl {
@@ -63,6 +65,24 @@
DISALLOW_COPY_AND_ASSIGN(SBChunkData);
};
+// Used when we get a gethash response.
+struct SBFullHashResult {
+ SBFullHash hash;
+ // TODO(shess): Refactor to allow ListType here.
+ int list_id;
+ std::string metadata;
+};
+
+// Caches individual response from GETHASH request.
+struct SBCachedFullHashResult {
+ SBCachedFullHashResult();
+ explicit SBCachedFullHashResult(const base::Time& in_expire_after);
+ ~SBCachedFullHashResult();
+
+ base::Time expire_after;
+ std::vector<SBFullHashResult> full_hashes;
+};
+
// Contains information about a list in the database.
struct SBListChunkRanges {
explicit SBListChunkRanges(const std::string& n);
@@ -82,4 +102,81 @@
std::vector<ChunkRange> chunk_del;
};
+// Utility functions -----------------------------------------------------------
+
+namespace safe_browsing_util {
+
+// SafeBrowsing list names.
+extern const char kMalwareList[];
+extern const char kPhishingList[];
+// Binary Download list name.
+extern const char kBinUrlList[];
+// SafeBrowsing client-side detection whitelist list name.
+extern const char kCsdWhiteList[];
+// SafeBrowsing download whitelist list name.
+extern const char kDownloadWhiteList[];
+// SafeBrowsing extension list name.
+extern const char kExtensionBlacklist[];
+// SafeBrowsing csd malware IP blacklist name.
+extern const char kIPBlacklist[];
+// SafeBrowsing unwanted URL list.
+extern const char kUnwantedUrlList[];
+// SafeBrowsing off-domain inclusion whitelist list name.
+extern const char kInclusionWhitelist[];
+
+// This array must contain all Safe Browsing lists.
+extern const char* kAllLists[9];
+
+enum ListType {
+ INVALID = -1,
+ MALWARE = 0,
+ PHISH = 1,
+ BINURL = 2,
+ // Obsolete BINHASH = 3,
+ CSDWHITELIST = 4,
+ // SafeBrowsing lists are stored in pairs. Keep ListType 5
+ // available for a potential second list that we would store in the
+ // csd-whitelist store file.
+ DOWNLOADWHITELIST = 6,
+ // See above comment. Leave 7 available.
+ EXTENSIONBLACKLIST = 8,
+ // See above comment. Leave 9 available.
+ // Obsolete SIDEEFFECTFREEWHITELIST = 10,
+ // See above comment. Leave 11 available.
+ IPBLACKLIST = 12,
+ // See above comment. Leave 13 available.
+ UNWANTEDURL = 14,
+ // See above comment. Leave 15 available.
+ INCLUSIONWHITELIST = 16,
+ // See above comment. Leave 17 available.
+};
+
+// Maps a list name to ListType.
+ListType GetListId(const base::StringPiece& name);
+
+// Maps a ListId to list name. Return false if fails.
+bool GetListName(ListType list_id, std::string* list);
+
+// Canonicalizes url as per Google Safe Browsing Specification.
+// See section 6.1 in
+// http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec.
+void CanonicalizeUrl(const GURL& url, std::string* canonicalized_hostname,
+ std::string* canonicalized_path,
+ std::string* canonicalized_query);
+
+// Given a URL, returns all the hosts we need to check. They are returned
+// in order of size (i.e. b.c is first, then a.b.c).
+void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts);
+
+// Given a URL, returns all the paths we need to check.
+void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths);
+
+// Given a URL, returns all the patterns we need to check.
+void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls);
+
+SBFullHash StringToSBFullHash(const std::string& hash_in);
+std::string SBFullHashToString(const SBFullHash& hash_out);
+
+} // namespace safe_browsing_util
+
#endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store_unittest.cc ('k') | chrome/browser/safe_browsing/safe_browsing_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698