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

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_host.h

Issue 6014003: Intergration of the client-side phishing detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dont DCHECK because some unit tests are failing. Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/ref_counted.h"
12 #include "base/scoped_callback_factory.h"
13 #include "base/task.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/tab_contents/tab_contents_observer.h"
16 #include "googleurl/src/gurl.h"
17
18 class TabContents;
19
20 namespace safe_browsing {
21
22 class ClientSideDetectionService;
23 class CsdClient;
24
25 // This class is used to receive the IPC from the renderer which
26 // notifies the browser that a URL was classified as phishing. This
27 // class relays this information to the client-side detection service
28 // class which sends a ping to a server to validate the verdict.
29 // TODO(noelutz): move all client-side detection IPCs to this class.
lzheng 2011/02/11 19:39:42 What are other IPC messages that would be moved he
noelutz 2011/02/15 23:00:55 I guess we have three IPCs? Browser -> Renderer:
lzheng 2011/02/16 19:09:32 I agree. On 2011/02/15 23:00:55, noelutz wrote:
30 class ClientSideDetectionHost : public TabContentsObserver {
31 public:
32 // The caller keeps ownership of the tab object and is responsible for
33 // ensuring that it stays valid for the entire lifetime of this object.
34 explicit ClientSideDetectionHost(TabContents* tab);
35 virtual ~ClientSideDetectionHost();
36
37 // From TabContentsObserver.
38 virtual bool OnMessageReceived(const IPC::Message& message);
39
40 // From TabContentsObserver. If we navigate way we cancel all pending
Brian Ryner 2011/02/11 01:30:39 way -> away
noelutz 2011/02/15 23:00:55 Done.
41 // callbacks that could show an interstitial.
42 virtual void DidNavigateMainFramePostCommit(
43 const NavigationController::LoadCommittedDetails& details,
44 const ViewHostMsg_FrameNavigate_Params& params);
45
46 private:
47 friend class ClientSideDetectionHostTest;
48 FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionHostTest, OnDetectedPhishingSite);
49
50 // Handles the IPC that is sent from the renderer the a URL is
jam 2011/02/15 18:54:53 nit: no need to comment IPC message handlers, sinc
noelutz 2011/02/15 23:00:55 Done.
jam 2011/02/15 23:34:42 nit: there's still a comment, what i mean is nothi
noelutz 2011/02/16 21:24:43 Done.
51 // classified as phishing. This method will send a server ping to validate
52 // the phishing verdict.
53 void OnDetectedPhishingSite(const GURL& phishing_url, double phishing_score);
54
55 // Callback that is called when the server ping back is
56 // done. Display an interstitial if |is_phishing| is true.
57 // Otherwise, we do nothgin. Called in UI thread.
58 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing);
59
60 // Used for testing. This function does not take ownership of the service
61 // class.
62 void set_client_side_detection_service(ClientSideDetectionService* service);
63
64 // Used for testing. This function does not take ownership of the service
65 // class.
66 void set_safe_browsing_service(SafeBrowsingService* service);
lzheng 2011/02/11 19:39:42 set_client_side_detection_service and set_safe_bro
noelutz 2011/02/15 23:00:55 see comment in the cc file.
67
68 // We are not responsible for deleting these objects. The tab contents as
69 // well as the service object outlive this object.
70 TabContents* tab_;
71 ClientSideDetectionService* service_; // might be NULL.
Brian Ryner 2011/02/11 01:30:39 Here and on line 73 - can you explain briefly when
noelutz 2011/02/15 23:00:55 Done.
72
73 scoped_refptr<SafeBrowsingService> sb_service_; // might be NULL.
74
75 base::ScopedCallbackFactory<ClientSideDetectionHost> cb_factory_;
76
77 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost);
78 };
79
80 // This class is used to display the phishing interstitial.
81 // TODO(noelutz): might want to move this class to the CC file.
Brian Ryner 2011/02/11 01:30:39 Seems reasonable to me to move it.
noelutz 2011/02/15 23:00:55 Done.
82 class CsdClient : public SafeBrowsingService::Client {
83 public:
84 explicit CsdClient();
Brian Ryner 2011/02/11 01:30:39 "explicit" is only needed for 1-argument construct
noelutz 2011/02/15 23:00:55 Sure. Leftover from previous version of the code.
85
86 // Method from SafeBrowsingService::Client. This method is called on the
87 // IO thread once the interstitial is going away. This method simply deletes
88 // the CsdClient object.
89 virtual void OnBlockingPageComplete(bool proceed);
90
91 private:
92 friend class DeleteTask<CsdClient>; // Calls the private destructor.
93
94 // We're taking care of deleting this object. No-one else should delete
95 // this object.
96 ~CsdClient();
Brian Ryner 2011/02/11 01:30:39 This should be declared virtual since it's virtual
noelutz 2011/02/15 23:00:55 Nice catch.
97
98 DISALLOW_COPY_AND_ASSIGN(CsdClient);
99 };
100
101 } // namespace safe_browsing
102
103 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698