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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 476733003: OOP PDF - Add support for "page" open pdf parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const char kJSNavigateType[] = "navigate"; 125 const char kJSNavigateType[] = "navigate";
126 const char kJSNavigateUrl[] = "url"; 126 const char kJSNavigateUrl[] = "url";
127 const char kJSNavigateNewTab[] = "newTab"; 127 const char kJSNavigateNewTab[] = "newTab";
128 // Open the email editor with the given parameters (Plugin -> Page) 128 // Open the email editor with the given parameters (Plugin -> Page)
129 const char kJSEmailType[] = "email"; 129 const char kJSEmailType[] = "email";
130 const char kJSEmailTo[] = "to"; 130 const char kJSEmailTo[] = "to";
131 const char kJSEmailCc[] = "cc"; 131 const char kJSEmailCc[] = "cc";
132 const char kJSEmailBcc[] = "bcc"; 132 const char kJSEmailBcc[] = "bcc";
133 const char kJSEmailSubject[] = "subject"; 133 const char kJSEmailSubject[] = "subject";
134 const char kJSEmailBody[] = "body"; 134 const char kJSEmailBody[] = "body";
135 // Handle open PDF parameters.
136 const char kJSHandleOpenPDFParams[] = "openPDFParams";
135 137
136 const int kFindResultCooldownMs = 100; 138 const int kFindResultCooldownMs = 100;
137 139
138 const double kMinZoom = 0.01; 140 const double kMinZoom = 0.01;
139 141
140 namespace { 142 namespace {
141 143
142 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; 144 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1;
143 145
144 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { 146 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) {
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 // Clear focus state for OSK. 1069 // Clear focus state for OSK.
1068 FormTextFieldFocusChange(false); 1070 FormTextFieldFocusChange(false);
1069 1071
1070 DCHECK(document_load_state_ == LOAD_STATE_LOADING); 1072 DCHECK(document_load_state_ == LOAD_STATE_LOADING);
1071 document_load_state_ = LOAD_STATE_COMPLETE; 1073 document_load_state_ = LOAD_STATE_COMPLETE;
1072 UserMetricsRecordAction("PDF.LoadSuccess"); 1074 UserMetricsRecordAction("PDF.LoadSuccess");
1073 1075
1074 // Note: If we are in print preview mode the scroll location is retained 1076 // Note: If we are in print preview mode the scroll location is retained
1075 // across document loads so we don't want to scroll again and override it. 1077 // across document loads so we don't want to scroll again and override it.
1076 if (!IsPrintPreview()) { 1078 if (!IsPrintPreview()) {
1077 int initial_page = GetInitialPage(url_); 1079 pp::VarDictionary message;
1078 if (initial_page >= 0) 1080 message.Set(pp::Var(kType), pp::Var(kJSHandleOpenPDFParams));
1079 ScrollToPage(initial_page); 1081 PostMessage(message);
raymes 2014/08/15 01:07:18 I don't think we need to add this new message type
Nikhil 2014/08/16 10:24:01 Done.
1080 } else { 1082 } else {
1081 AppendBlankPrintPreviewPages(); 1083 AppendBlankPrintPreviewPages();
1082 OnGeometryChanged(0, 0); 1084 OnGeometryChanged(0, 0);
1083 } 1085 }
1084 1086
1085 pp::VarDictionary message; 1087 pp::VarDictionary message;
1086 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); 1088 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType));
1087 message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)) ; 1089 message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)) ;
1088 PostMessage(message); 1090 PostMessage(message);
1089 1091
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 1299
1298 const PPB_URLLoaderTrusted* trusted_interface = 1300 const PPB_URLLoaderTrusted* trusted_interface =
1299 reinterpret_cast<const PPB_URLLoaderTrusted*>( 1301 reinterpret_cast<const PPB_URLLoaderTrusted*>(
1300 pp::Module::Get()->GetBrowserInterface( 1302 pp::Module::Get()->GetBrowserInterface(
1301 PPB_URLLOADERTRUSTED_INTERFACE)); 1303 PPB_URLLOADERTRUSTED_INTERFACE));
1302 if (trusted_interface) 1304 if (trusted_interface)
1303 trusted_interface->GrantUniversalAccess(loader.pp_resource()); 1305 trusted_interface->GrantUniversalAccess(loader.pp_resource());
1304 return loader; 1306 return loader;
1305 } 1307 }
1306 1308
1307 int OutOfProcessInstance::GetInitialPage(const std::string& url) { 1309 int OutOfProcessInstance::GetInitialPage(const std::string& url) {
raymes 2014/08/15 01:07:18 I think we can get rid of this entire function fro
Nikhil 2014/08/16 10:24:01 Done.
1308 size_t found_idx = url.find('#'); 1310 size_t found_idx = url.find('#');
1309 if (found_idx == std::string::npos) 1311 if (found_idx == std::string::npos)
1310 return -1; 1312 return -1;
1311 1313
1312 const std::string& ref = url.substr(found_idx + 1); 1314 const std::string& ref = url.substr(found_idx + 1);
1313 std::vector<std::string> fragments; 1315 std::vector<std::string> fragments;
1314 Tokenize(ref, kDelimiters, &fragments); 1316 Tokenize(ref, kDelimiters, &fragments);
1315 1317
1316 // Page number to return, zero-based. 1318 // Page number to return, zero-based.
1317 int page = -1; 1319 int page = -1;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( 1416 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument(
1415 const pp::Point& scroll_offset) { 1417 const pp::Point& scroll_offset) {
1416 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1418 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1417 int x = std::max(std::min(scroll_offset.x(), max_x), 0); 1419 int x = std::max(std::min(scroll_offset.x(), max_x), 0);
1418 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1420 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1419 int y = std::max(std::min(scroll_offset.y(), max_y), 0); 1421 int y = std::max(std::min(scroll_offset.y(), max_y), 0);
1420 return pp::Point(x, y); 1422 return pp::Point(x, y);
1421 } 1423 }
1422 1424
1423 } // namespace chrome_pdf 1425 } // namespace chrome_pdf
OLDNEW
« 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