summaryrefslogtreecommitdiffstats
path: root/pdf/out_of_process_instance.cc
diff options
context:
space:
mode:
authordeepak.m1 <deepak.m1@samsung.com>2015-02-17 14:47:32 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-17 22:48:08 +0000
commit9cdcfdfdb5fd39249669a5743f39d739fe05b47a (patch)
treeee62346bb7fc767feb7d66f0ccf0ef379af3e519 /pdf/out_of_process_instance.cc
parentb78ef8a2fa5917acbb12242cffe32ea3e73e3ab5 (diff)
downloadchromium_src-9cdcfdfdb5fd39249669a5743f39d739fe05b47a.zip
chromium_src-9cdcfdfdb5fd39249669a5743f39d739fe05b47a.tar.gz
chromium_src-9cdcfdfdb5fd39249669a5743f39d739fe05b47a.tar.bz2
Fix for PDFs with lots of named destinations take a long time to load.
When PDF have lots of named destinations then as we are fetching all the named destinations at load time, so this will increase loading time. This is a workaround so that we will get named destination whenever it is required by passing message from page to plugin. BUG=457457 Review URL: https://codereview.chromium.org/918953002 Cr-Commit-Position: refs/heads/master@{#316685}
Diffstat (limited to 'pdf/out_of_process_instance.cc')
-rw-r--r--pdf/out_of_process_instance.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 74544d9..ef83cd9 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -140,9 +140,12 @@ 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 destination with the given name (Page -> Plugin)
+const char KJSGetNamedDestinationType[] = "getNamedDestination";
+const char KJSGetNamedDestination[] = "namedDestination";
+// Reply with the page number of the named destination (Plugin -> Page)
+const char kJSGetNamedDestinationReplyType[] = "getNamedDestinationReply";
+const char kJSNamedDestinationPageNumber[] = "pageNumber";
// Selecting text in document (Plugin -> Page)
const char kJSSetIsSelectingType[] = "setIsSelecting";
@@ -480,6 +483,15 @@ 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 (page_number >= 0)
+ reply.Set(pp::Var(kJSNamedDestinationPageNumber), page_number);
+ PostMessage(reply);
} else {
NOTREACHED();
}
@@ -1095,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());