Index: pdf/out_of_process_instance.cc |
diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc |
index df881c5fada58a70748004cb95090572e325aea9..808606be7dece140fd6fad6bcaa5ba48d028a5d2 100644 |
--- a/pdf/out_of_process_instance.cc |
+++ b/pdf/out_of_process_instance.cc |
@@ -303,23 +303,24 @@ bool OutOfProcessInstance::Init(uint32_t argc, |
const char* argn[], |
const char* argv[]) { |
// Check if the PDF is being loaded in the PDF chrome extension. We only allow |
- // the plugin to be put into "full frame" mode when it is being loaded in the |
- // extension because this enables some features that we don't want pages |
- // abusing outside of the extension. |
+ // the plugin to be loaded in the extension and print preview to avoid |
+ // exposing sensitive APIs directly to external websites. |
pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); |
- std::string document_url = document_url_var.is_string() ? |
- document_url_var.AsString() : std::string(); |
+ if (!document_url_var.is_string()) |
+ return false; |
+ std::string document_url = document_url_var.AsString(); |
std::string extension_url = std::string(kChromeExtension); |
- bool in_extension = |
- !document_url.compare(0, extension_url.size(), extension_url); |
- |
- if (in_extension) { |
- // Check if the plugin is full frame. This is passed in from JS. |
- for (uint32_t i = 0; i < argc; ++i) { |
- if (strcmp(argn[i], "full-frame") == 0) { |
- full_ = true; |
- break; |
- } |
+ std::string print_preview_url = std::string(kChromePrint); |
+ if (!base::StringPiece(document_url).starts_with(kChromeExtension) && |
+ !base::StringPiece(document_url).starts_with(kChromePrint)) { |
+ return false; |
+ } |
+ |
+ // Check if the plugin is full frame. This is passed in from JS. |
+ for (uint32_t i = 0; i < argc; ++i) { |
+ if (strcmp(argn[i], "full-frame") == 0) { |
+ full_ = true; |
+ break; |
} |
} |