Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 } | 136 } |
| 137 | 137 |
| 138 void PhishingClassifierDelegate::OnStartPhishingDetection(const GURL& url) { | 138 void PhishingClassifierDelegate::OnStartPhishingDetection(const GURL& url) { |
| 139 last_url_received_from_browser_ = StripRef(url); | 139 last_url_received_from_browser_ = StripRef(url); |
| 140 // Start classifying the current page if all conditions are met. | 140 // Start classifying the current page if all conditions are met. |
| 141 // See MaybeStartClassification() for details. | 141 // See MaybeStartClassification() for details. |
| 142 MaybeStartClassification(); | 142 MaybeStartClassification(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PhishingClassifierDelegate::DidCommitProvisionalLoad( | 145 void PhishingClassifierDelegate::DidCommitProvisionalLoad( |
| 146 bool is_new_navigation, | 146 bool /*is_new_navigation*/, |
| 147 bool is_same_page_navigation) { | 147 bool /*is_same_page_navigation*/) { |
|
Charlie Reis
2017/03/15 02:43:10
Let's leave this change out. It's unrelated, and
Eugene But (OOO till 7-30)
2017/03/15 16:16:16
Done.
| |
| 148 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); | 148 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 149 // A new page is starting to load, so cancel classificaiton. | 149 // A new page is starting to load, so cancel classificaiton. |
| 150 // | 150 // |
| 151 // TODO(bryner): We shouldn't need to cancel classification if the navigation | 151 // TODO(bryner): We shouldn't need to cancel classification if the navigation |
| 152 // is within the same page. However, if we let classification continue in | 152 // is within the same page. However, if we let classification continue in |
|
Charlie Reis
2017/03/15 02:43:10
s/page/document/
Eugene But (OOO till 7-30)
2017/03/15 16:16:16
Done.
| |
| 153 // this case, we need to properly deal with the fact that PageCaptured will | 153 // this case, we need to properly deal with the fact that PageCaptured will |
| 154 // be called again for the in-page navigation. We need to be sure not to | 154 // be called again for the in-page navigation. We need to be sure not to |
|
Charlie Reis
2017/03/15 02:43:10
s/in-page/same-document/
Eugene But (OOO till 7-30)
2017/03/15 16:16:16
Done.
| |
| 155 // swap out the page text while the term feature extractor is still running. | 155 // swap out the page text while the term feature extractor is still running. |
| 156 DocumentState* document_state = DocumentState::FromDataSource( | 156 DocumentState* document_state = DocumentState::FromDataSource( |
| 157 frame->dataSource()); | 157 frame->dataSource()); |
| 158 NavigationState* navigation_state = document_state->navigation_state(); | 158 NavigationState* navigation_state = document_state->navigation_state(); |
| 159 CancelPendingClassification(navigation_state->WasWithinSamePage() | 159 CancelPendingClassification(navigation_state->WasWithinSameDocument() |
| 160 ? NAVIGATE_WITHIN_PAGE | 160 ? NAVIGATE_WITHIN_PAGE |
| 161 : NAVIGATE_AWAY); | 161 : NAVIGATE_AWAY); |
| 162 if (frame->parent()) | 162 if (frame->parent()) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 last_main_frame_transition_ = navigation_state->GetTransitionType(); | 165 last_main_frame_transition_ = navigation_state->GetTransitionType(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void PhishingClassifierDelegate::PageCaptured(base::string16* page_text, | 168 void PhishingClassifierDelegate::PageCaptured(base::string16* page_text, |
| 169 bool preliminary_capture) { | 169 bool preliminary_capture) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 &classifier_page_text_, | 287 &classifier_page_text_, |
| 288 base::Bind(&PhishingClassifierDelegate::ClassificationDone, | 288 base::Bind(&PhishingClassifierDelegate::ClassificationDone, |
| 289 base::Unretained(this))); | 289 base::Unretained(this))); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void PhishingClassifierDelegate::OnDestruct() { | 292 void PhishingClassifierDelegate::OnDestruct() { |
| 293 delete this; | 293 delete this; |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace safe_browsing | 296 } // namespace safe_browsing |
| OLD | NEW |