summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authorraymes <raymes@chromium.org>2015-01-22 17:14:47 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-23 01:15:23 +0000
commitc121c2269073e9249c982d9ba7c3301cb6e778a7 (patch)
treeb87beb374649ba26119ff44692243a838f42257b /pdf
parent298156be041512f6d4a78bdba5c90454d3d2dfdb (diff)
downloadchromium_src-c121c2269073e9249c982d9ba7c3301cb6e778a7.zip
chromium_src-c121c2269073e9249c982d9ba7c3301cb6e778a7.tar.gz
chromium_src-c121c2269073e9249c982d9ba7c3301cb6e778a7.tar.bz2
Make the scripting OOP PDF API easier to use (take 2)
This mainly removes the need to call setParentWindow before using the API but it also delays more messages from being received until the document is loaded which makes the API easier to use. BUG=415858 Review URL: https://codereview.chromium.org/870453002 Cr-Commit-Position: refs/heads/master@{#312722}
Diffstat (limited to 'pdf')
-rw-r--r--pdf/out_of_process_instance.cc36
-rw-r--r--pdf/out_of_process_instance.h4
2 files changed, 14 insertions, 26 deletions
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc
index 58b25a9..d6ad71a 100644
--- a/pdf/out_of_process_instance.cc
+++ b/pdf/out_of_process_instance.cc
@@ -267,8 +267,7 @@ OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance)
recently_sent_find_update_(false),
received_viewport_message_(false),
did_call_start_loading_(false),
- stop_scrolling_(false),
- delay_print_(false) {
+ stop_scrolling_(false) {
loader_factory_.Initialize(this);
timer_factory_.Initialize(this);
form_factory_.Initialize(this);
@@ -970,11 +969,6 @@ void OutOfProcessInstance::Email(const std::string& to,
}
void OutOfProcessInstance::Print() {
- if (document_load_state_ == LOAD_STATE_LOADING) {
- delay_print_ = true;
- return;
- }
-
if (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) &&
!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY)) {
return;
@@ -1102,25 +1096,23 @@ void OutOfProcessInstance::DocumentLoadComplete(int page_count) {
progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100));
PostMessage(progress_message);
- if (full_) {
- if (did_call_start_loading_) {
- pp::PDF::DidStopLoading(this);
- did_call_start_loading_ = false;
- }
+ if (!full_)
+ return;
- int content_restrictions =
- CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE;
- if (!engine_->HasPermission(PDFEngine::PERMISSION_COPY))
- content_restrictions |= CONTENT_RESTRICTION_COPY;
+ if (did_call_start_loading_) {
+ pp::PDF::DidStopLoading(this);
+ did_call_start_loading_ = false;
+ }
- pp::PDF::SetContentRestriction(this, content_restrictions);
+ int content_restrictions =
+ CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE;
+ if (!engine_->HasPermission(PDFEngine::PERMISSION_COPY))
+ content_restrictions |= CONTENT_RESTRICTION_COPY;
- uma_.HistogramCustomCounts("PDF.PageCount", page_count,
- 1, 1000000, 50);
- }
+ pp::PDF::SetContentRestriction(this, content_restrictions);
- if (delay_print_)
- Print();
+ uma_.HistogramCustomCounts("PDF.PageCount", page_count,
+ 1, 1000000, 50);
}
void OutOfProcessInstance::RotateClockwise() {
diff --git a/pdf/out_of_process_instance.h b/pdf/out_of_process_instance.h
index bcd507d..eb30458 100644
--- a/pdf/out_of_process_instance.h
+++ b/pdf/out_of_process_instance.h
@@ -339,10 +339,6 @@ class OutOfProcessInstance : public pp::Instance,
// zooming the plugin so that flickering doesn't occur while zooming.
bool stop_scrolling_;
- // If a print command comes in before the document has loaded, we set
- // |delay_print_| to true and print after the document has loaded.
- bool delay_print_;
-
// The callback for receiving the password from the page.
scoped_ptr<pp::CompletionCallbackWithOutput<pp::Var> > password_callback_;
};