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

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

Issue 56135: Adding unit tests for the SafeBrowsingBlockingPage class (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months 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_blocking_page.h
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_blocking_page.h (revision 12779)
+++ chrome/browser/safe_browsing/safe_browsing_blocking_page.h (working copy)
@@ -38,9 +38,9 @@
class DictionaryValue;
class MessageLoop;
class NavigationController;
+class SafeBrowsingBlockingPageFactory;
class WebContents;
-
class SafeBrowsingBlockingPage : public InterstitialPage {
public:
virtual ~SafeBrowsingBlockingPage();
@@ -54,23 +54,29 @@
SafeBrowsingService* service,
const SafeBrowsingService::UnsafeResource& resource);
+ // Makes the passed |factory| the factory used to instanciate
+ // SafeBrowsingBlockingPage objects. Usefull for tests.
+ static void RegisterFactory(SafeBrowsingBlockingPageFactory* factory) {
+ factory_ = factory;
+ }
+
// InterstitialPage method:
virtual std::string GetHTMLContents();
virtual void Proceed();
virtual void DontProceed();
+ typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList;
+
protected:
// InterstitialPage method:
virtual void CommandReceived(const std::string& command);
- private:
- typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList;
-
// Don't instanciate this class directly, use ShowBlockingPage instead.
SafeBrowsingBlockingPage(SafeBrowsingService* service,
WebContents* web_contents,
const UnsafeResourceList& unsafe_resources);
+ private:
// Fills the passed dictionary with the strings passed to JS Template when
// creating the HTML.
void PopulateMultipleThreatStringDictionary(DictionaryValue* strings);
@@ -103,6 +109,8 @@
static bool IsMainPage(const UnsafeResourceList& unsafe_resources);
private:
+ friend class SafeBrowsingBlockingPageFactoryImpl;
+
// For reporting back user actions.
SafeBrowsingService* sb_service_;
MessageLoop* report_loop_;
@@ -117,7 +125,23 @@
// The list of unsafe resources this page is warning about.
UnsafeResourceList unsafe_resources_;
+ // The factory used to instanciate SafeBrowsingBlockingPage objects.
+ // Usefull for tests, so they can provide their own implementation of
+ // SafeBrowsingBlockingPage.
+ static SafeBrowsingBlockingPageFactory* factory_;
+
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage);
};
+// Factory for creating SafeBrowsingBlockingPage. Useful for tests.
+class SafeBrowsingBlockingPageFactory {
+ public:
+ ~SafeBrowsingBlockingPageFactory() { }
+
+ virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
+ SafeBrowsingService* service,
+ WebContents* web_contents,
+ const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0;
+};
+
#endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_
« no previous file with comments | « chrome/browser/renderer_host/mock_render_process_host.cc ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698