diff options
author | n.bansal@samsung.com <n.bansal@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-19 09:52:16 +0000 |
---|---|---|
committer | n.bansal@samsung.com <n.bansal@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-19 09:54:00 +0000 |
commit | a6d93b2e41cd94d99c8b1fa3acde47082a8756de (patch) | |
tree | 68614bfcb26bd1a0c207d4b74d17635c3f12dd62 /pdf/out_of_process_instance.cc | |
parent | 6d15e9f322df89347b6feffbeb9e58066a53921f (diff) | |
download | chromium_src-a6d93b2e41cd94d99c8b1fa3acde47082a8756de.zip chromium_src-a6d93b2e41cd94d99c8b1fa3acde47082a8756de.tar.gz chromium_src-a6d93b2e41cd94d99c8b1fa3acde47082a8756de.tar.bz2 |
OOP PDF - Add support for "page" open pdf parameter
This patch adds support for "page" feature of open PDF
parameters in OOP PDF.
When page is used as an open PDF parameter, then PDF
should initially be loaded at the page specified by user.
BUG=64309
Review URL: https://codereview.chromium.org/476733003
Cr-Commit-Position: refs/heads/master@{#290529}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'pdf/out_of_process_instance.cc')
-rw-r--r-- | pdf/out_of_process_instance.cc | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index d1fd417..6a3a518 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -48,13 +48,6 @@ namespace chrome_pdf { -// URL reference parameters. -// For more possible parameters, see RFC 3778 and the "PDF Open Parameters" -// document from Adobe. -const char kDelimiters[] = "#&"; -const char kNamedDest[] = "nameddest"; -const char kPage[] = "page"; - const char kChromePrint[] = "chrome://print/"; const char kChromeExtension[] = "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; @@ -1073,11 +1066,7 @@ void OutOfProcessInstance::DocumentLoadComplete(int page_count) { // Note: If we are in print preview mode the scroll location is retained // across document loads so we don't want to scroll again and override it. - if (!IsPrintPreview()) { - int initial_page = GetInitialPage(url_); - if (initial_page >= 0) - ScrollToPage(initial_page); - } else { + if (IsPrintPreview()) { AppendBlankPrintPreviewPages(); OnGeometryChanged(0, 0); } @@ -1304,49 +1293,6 @@ pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { return loader; } -int OutOfProcessInstance::GetInitialPage(const std::string& url) { - size_t found_idx = url.find('#'); - if (found_idx == std::string::npos) - return -1; - - const std::string& ref = url.substr(found_idx + 1); - std::vector<std::string> fragments; - Tokenize(ref, kDelimiters, &fragments); - - // Page number to return, zero-based. - int page = -1; - - // Handle the case of http://foo.com/bar#NAMEDDEST. This is not explicitly - // mentioned except by example in the Adobe "PDF Open Parameters" document. - if ((fragments.size() == 1) && (fragments[0].find('=') == std::string::npos)) - return engine_->GetNamedDestinationPage(fragments[0]); - - for (size_t i = 0; i < fragments.size(); ++i) { - std::vector<std::string> key_value; - base::SplitString(fragments[i], '=', &key_value); - if (key_value.size() != 2) - continue; - const std::string& key = key_value[0]; - const std::string& value = key_value[1]; - - if (base::strcasecmp(kPage, key.c_str()) == 0) { - // |page_value| is 1-based. - int page_value = -1; - if (base::StringToInt(value, &page_value) && page_value > 0) - page = page_value - 1; - continue; - } - if (base::strcasecmp(kNamedDest, key.c_str()) == 0) { - // |page_value| is 0-based. - int page_value = engine_->GetNamedDestinationPage(value); - if (page_value >= 0) - page = page_value; - continue; - } - } - return page; -} - void OutOfProcessInstance::SetZoom(double scale) { double old_zoom = zoom_; zoom_ = scale; |