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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1365563003: Prevent guest views from issuing a search for empty text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 5 years, 3 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: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 5f1eec6b62d4df63183dc1f0da9469c79aad7d00..87af508fdeffa2f213056fc2e095bb8867201b66 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1324,7 +1324,7 @@ void PDFiumEngine::UnsupportedFeature(int type) {
}
void PDFiumEngine::ContinueFind(int32_t result) {
- StartFind(current_find_text_.c_str(), !!result);
+ StartFind(current_find_text_, result != 0);
}
bool PDFiumEngine::HandleEvent(const pp::InputEvent& event) {
@@ -2001,16 +2001,20 @@ bool PDFiumEngine::OnChar(const pp::KeyboardInputEvent& event) {
event.GetModifiers());
}
-void PDFiumEngine::StartFind(const char* text, bool case_sensitive) {
- // We can get a call to StartFind before we have any page information (i.e.
+void PDFiumEngine::StartFind(const std::string& text, bool case_sensitive) {
+ // If the caller asks StartFind() to search for no text, then this is an
+ // error on the part of the caller. The PPAPI Find_Private interface
+ // guarantees it is not empty, so this should never happen.
+ DCHECK(!text.empty());
+
+ // If StartFind() gets called before we have any page information (i.e.
// before the first call to LoadDocument has happened). Handle this case.
if (pages_.empty())
return;
- bool first_search = false;
+ bool first_search = (current_find_text_ != text);
int character_to_start_searching_from = 0;
- if (current_find_text_ != text) { // First time we search for this text.
- first_search = true;
+ if (first_search) {
std::vector<PDFiumRange> old_selection = selection_;
StopFind();
current_find_text_ = text;
@@ -3504,7 +3508,7 @@ void PDFiumEngine::RotateInternal() {
if (!current_find_text.empty()) {
// Clear the UI.
client_->NotifyNumberOfFindResultsChanged(0, false);
- StartFind(current_find_text.c_str(), false);
+ StartFind(current_find_text, false);
}
}

Powered by Google App Engine
This is Rietveld 408576698