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

Unified Diff: pdf/out_of_process_instance.cc

Issue 918953002: Fix for PDFs with lots of named destinations take a long time to load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« chrome/browser/resources/pdf/pdf.js ('K') | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/out_of_process_instance.cc
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 169a4403498a21b2a2eb9dac16f5c88ff5e022f8..a365871cdbe67efc4f8064ce0cbffd86e4b81e43 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -140,9 +140,13 @@ const char kJSGetSelectedTextType[] = "getSelectedText";
const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply";
const char kJSSelectedText[] = "selectedText";
-// List of named destinations (Plugin -> Page)
-const char kJSSetNamedDestinationsType[] = "setNamedDestinations";
-const char kJSNamedDestinations[] = "namedDestinations";
+// Get the named destinations (Page -> Plugin)
+const char KJSGetNamedDestinationType[] = "getNamedDestination";
+const char KJSGetNamedDestination[] = "namedDestination";
+const char KJSGetNavigationUrl[] = "navigationUrl";
+// Reply with page number of named destination (Plugin -> Page)
+const char kJSGetNamedDestinationReplyType[] = "getNamedDestinationReply";
+const char kJSNamedDestinationPageNumber[] = "namedDestinationPageNumber";
const int kFindResultCooldownMs = 100;
@@ -476,6 +480,18 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
reply.Set(pp::Var(kType), pp::Var(kJSGetSelectedTextReplyType));
reply.Set(pp::Var(kJSSelectedText), selected_text);
PostMessage(reply);
+ } else if (type == KJSGetNamedDestinationType &&
+ dict.Get(pp::Var(KJSGetNamedDestination)).is_string()) {
+ int page_number = engine_->GetNamedDestinationPage(
+ dict.Get(pp::Var(KJSGetNamedDestination)).AsString());
+ pp::VarDictionary reply;
+ reply.Set(pp::Var(kType), pp::Var(kJSGetNamedDestinationReplyType));
+ if (dict.Get(pp::Var(KJSGetNavigationUrl)).is_string())
+ reply.Set(pp::Var(KJSGetNavigationUrl),
+ dict.Get(pp::Var(KJSGetNavigationUrl)));
+ if (page_number >= 0)
+ reply.Set(pp::Var(kJSNamedDestinationPageNumber), page_number);
+ PostMessage(reply);
} else {
NOTREACHED();
}
@@ -1091,14 +1107,6 @@ void OutOfProcessInstance::DocumentLoadComplete(int page_count) {
OnGeometryChanged(0, 0);
}
- pp::VarDictionary named_destinations_message;
- pp::VarDictionary named_destinations = engine_->GetNamedDestinations();
- named_destinations_message.Set(pp::Var(kType),
- pp::Var(kJSSetNamedDestinationsType));
- named_destinations_message.Set(pp::Var(kJSNamedDestinations),
- pp::Var(named_destinations));
- PostMessage(named_destinations_message);
-
pp::VarDictionary bookmarks_message;
bookmarks_message.Set(pp::Var(kType), pp::Var(kJSBookmarksType));
bookmarks_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks());
« chrome/browser/resources/pdf/pdf.js ('K') | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698