Chromium Code Reviews| Index: pdf/out_of_process_instance.cc |
| diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc |
| index 59b04394419410bc1eda3518839f2323169bbe94..921f390ab5f3e892beb4894d86976eeab99b2ce4 100644 |
| --- a/pdf/out_of_process_instance.cc |
| +++ b/pdf/out_of_process_instance.cc |
| @@ -128,6 +128,12 @@ const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; |
| // Select all text in the document (Page -> Plugin) |
| const char kJSSelectAllType[] = "selectAll"; |
| +// List of named destinations (Plugin -> Page) |
| +const char kJSNamedDestinations[] = "namedDestinations"; |
| +// URL reference parameters. |
| +const char kDelimiters[] = "#&"; |
| +const char kNamedDest[] = "nameddest"; |
| + |
| const int kFindResultCooldownMs = 100; |
| const double kMinZoom = 0.01; |
| @@ -842,7 +848,13 @@ void OutOfProcessInstance::NavigateTo(const std::string& url, |
| // If |url_copy| starts with '#', then it's for the same URL with a |
| // different URL fragment. |
| if (url_copy[0] == '#') { |
| - url_copy = url_ + url_copy; |
| + // if '#' is already present in |url_| then remove old fragment and add |
| + // new |url_copy| fragment. |
| + std::size_t index = url_.find('#'); |
| + if (index != std::string::npos) |
| + url_copy = url_.substr(0, index) + url_copy; |
| + else |
| + url_copy = url_ + url_copy; |
| } |
| // If there's no scheme, add http. |
| if (url_copy.find("://") == std::string::npos && |
| @@ -1094,8 +1106,11 @@ void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
| } |
| pp::VarDictionary message; |
| + pp::VarDictionary named_destinations; |
| + GetNamedDestinations(named_destinations); |
| message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)) ; |
| + message.Set(pp::Var(kJSNamedDestinations), pp::Var(named_destinations)); |
| PostMessage(message); |
| if (!full_) |
| @@ -1315,6 +1330,36 @@ pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { |
| return loader; |
| } |
| +void OutOfProcessInstance::GetNamedDestinations( |
|
raymes
2015/01/11 23:08:41
Can we move all of this inside pdfium_engine and j
Deepak
2015/01/12 09:21:43
Done.
|
| + pp::VarDictionary& named_destinations) { |
|
raymes
2015/01/11 23:08:41
for future reference: we never use references that
Deepak
2015/01/12 09:21:43
Done.
|
| + std::vector<std::string> name_dest(engine_->GetNameDestCount()); |
| + engine_->GetNameDests(&name_dest); |
| + |
| + for (size_t i = 0; i < name_dest.size(); ++i) { |
| + std::vector<std::string> fragments; |
| + Tokenize(name_dest[i], kDelimiters, &fragments); |
| + if ((fragments.size() == 1) && |
| + (fragments[0].find('=') == std::string::npos)) { |
| + int page_number = engine_->GetNamedDestinationPage(fragments[0]); |
| + if (page_number >= 0) |
| + named_destinations.Set(fragments[0], pp::Var(page_number)); |
| + continue; |
| + } |
| + |
| + std::vector<std::string> key_value; |
| + base::SplitString(name_dest[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(kNamedDest, key.c_str()) == 0) { |
| + int page_value = engine_->GetNamedDestinationPage(value); |
| + if (page_value >= 0) |
| + named_destinations.Set(value, page_value); |
| + } |
|
raymes
2015/01/11 23:08:41
Is all of this really needed?? Does FPDF_GetNamedD
Deepak
2015/01/12 09:21:43
I agree with you, This code currently no needed,we
|
| + } |
| +} |
| + |
| void OutOfProcessInstance::SetZoom(double scale) { |
| double old_zoom = zoom_; |
| zoom_ = scale; |