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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 2000323005: PDF: Use an empty password as a sentinel value for no password. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | 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 ac00af5c590d3827fb2493b4e615f44729fed331..5ee7e623ac43e20b3098cb3097ff2bec45443f99 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -2403,8 +2403,8 @@ void PDFiumEngine::LoadDocument() {
ScopedUnsupportedFeature scoped_unsupported_feature(this);
bool needs_password = false;
- if (TryLoadingDoc(false, std::string(), &needs_password)) {
- ContinueLoadingDocument(false, std::string());
+ if (TryLoadingDoc(std::string(), &needs_password)) {
+ ContinueLoadingDocument(std::string());
return;
}
if (needs_password)
@@ -2413,15 +2413,14 @@ void PDFiumEngine::LoadDocument() {
client_->DocumentLoadFailed();
}
-bool PDFiumEngine::TryLoadingDoc(bool with_password,
- const std::string& password,
+bool PDFiumEngine::TryLoadingDoc(const std::string& password,
bool* needs_password) {
*needs_password = false;
if (doc_)
return true;
const char* password_cstr = nullptr;
- if (with_password) {
+ if (!password.empty()) {
password_cstr = password.c_str();
password_tries_remaining_--;
}
@@ -2449,24 +2448,18 @@ void PDFiumEngine::OnGetPasswordComplete(int32_t result,
const pp::Var& password) {
getting_password_ = false;
- bool password_given = false;
std::string password_text;
- if (result == PP_OK && password.is_string()) {
+ if (result == PP_OK && password.is_string())
password_text = password.AsString();
- if (!password_text.empty())
- password_given = true;
- }
- ContinueLoadingDocument(password_given, password_text);
+ ContinueLoadingDocument(password_text);
}
-void PDFiumEngine::ContinueLoadingDocument(
- bool has_password,
- const std::string& password) {
+void PDFiumEngine::ContinueLoadingDocument(const std::string& password) {
ScopedUnsupportedFeature scoped_unsupported_feature(this);
bool needs_password = false;
- bool loaded = TryLoadingDoc(has_password, password, &needs_password);
- bool password_incorrect = !loaded && has_password && needs_password;
+ bool loaded = TryLoadingDoc(password, &needs_password);
+ bool password_incorrect = !loaded && needs_password && !password.empty();
if (password_incorrect && password_tries_remaining_ > 0) {
GetPasswordAndLoad();
return;
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698