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

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: parens 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
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | ppapi/cpp/private/find_private.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index d23c141edffcfd6ff0bd4c4b40f2fcaf7352b5ef..8fd5afb36dbba0a5d791d1b0950ee36731c1f994 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1232,7 +1232,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) {
@@ -1909,16 +1909,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;
@@ -3432,7 +3436,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);
}
}
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | ppapi/cpp/private/find_private.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698