Record the PDF and top level URL when the PDF plugin crashes.
BUG=638716 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Review-Url: https://codereview.chromium.org/2299943002 Cr-Commit-Position: refs/heads/master@{#417214}
This commit is contained in:
chrome/browser
pdf
ppapi
c
private
cpp
proxy
thunk
@ -85,7 +85,7 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler(
|
||||
if (handler->HasPlugin()) {
|
||||
GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() +
|
||||
handler->handler_url());
|
||||
auto tab_id = ExtensionTabUtil::GetTabId(web_contents);
|
||||
int tab_id = ExtensionTabUtil::GetTabId(web_contents);
|
||||
std::unique_ptr<StreamContainer> stream_container(new StreamContainer(
|
||||
std::move(stream), tab_id, embedded, handler_url, extension_id));
|
||||
MimeHandlerStreamManager::Get(browser_context_)
|
||||
|
@ -152,15 +152,24 @@ function createBrowserApiForMimeHandlerView() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
chrome.mimeHandlerPrivate.getStreamInfo(resolve);
|
||||
}).then(function(streamInfo) {
|
||||
let promises = [];
|
||||
let manageZoom = !streamInfo.embedded && streamInfo.tabId != -1;
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!manageZoom) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
chrome.tabs.setZoomSettings(
|
||||
streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve);
|
||||
}).then(function() { return BrowserApi.create(streamInfo, manageZoom); });
|
||||
if (streamInfo.tabId != -1) {
|
||||
promises.push(new Promise(function(resolve) {
|
||||
chrome.tabs.get(streamInfo.tabId, resolve);
|
||||
}).then(function(tab) {
|
||||
if (tab)
|
||||
streamInfo.tabUrl = tab.url;
|
||||
}));
|
||||
}
|
||||
if (manageZoom) {
|
||||
promises.push(new Promise(function(resolve) {
|
||||
chrome.tabs.setZoomSettings(
|
||||
streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve);
|
||||
}));
|
||||
}
|
||||
return Promise.all(promises).then(
|
||||
function() { return BrowserApi.create(streamInfo, manageZoom); });
|
||||
});
|
||||
}
|
||||
|
||||
@ -185,6 +194,7 @@ function createBrowserApiForStandaloneExtension() {
|
||||
}
|
||||
chrome.tabs.getCurrent(function(tab) {
|
||||
streamInfo.tabId = tab.id;
|
||||
streamInfo.tabUrl = tab.url;
|
||||
resolve();
|
||||
});
|
||||
}).then(function() { return BrowserApi.create(streamInfo, false); });
|
||||
|
@ -172,8 +172,12 @@ function PDFViewer(browserApi) {
|
||||
this.plugin_.setAttribute('background-color', backgroundColor);
|
||||
this.plugin_.setAttribute('top-toolbar-height', topToolbarHeight);
|
||||
|
||||
if (!this.browserApi_.getStreamInfo().embedded)
|
||||
if (this.browserApi_.getStreamInfo().embedded) {
|
||||
this.plugin_.setAttribute('top-level-url',
|
||||
this.browserApi_.getStreamInfo().tabUrl);
|
||||
} else {
|
||||
this.plugin_.setAttribute('full-frame', '');
|
||||
}
|
||||
document.body.appendChild(this.plugin_);
|
||||
|
||||
// Setup the button event listeners.
|
||||
|
@ -343,6 +343,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
|
||||
|
||||
const char* stream_url = nullptr;
|
||||
const char* original_url = nullptr;
|
||||
const char* top_level_url = nullptr;
|
||||
const char* headers = nullptr;
|
||||
for (uint32_t i = 0; i < argc; ++i) {
|
||||
bool success = true;
|
||||
@ -350,6 +351,8 @@ bool OutOfProcessInstance::Init(uint32_t argc,
|
||||
original_url = argv[i];
|
||||
else if (strcmp(argn[i], "stream-url") == 0)
|
||||
stream_url = argv[i];
|
||||
else if (strcmp(argn[i], "top-level-url") == 0)
|
||||
top_level_url = argv[i];
|
||||
else if (strcmp(argn[i], "headers") == 0)
|
||||
headers = argv[i];
|
||||
else if (strcmp(argn[i], "background-color") == 0)
|
||||
@ -376,6 +379,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
|
||||
|
||||
LoadUrl(stream_url);
|
||||
url_ = original_url;
|
||||
pp::PDF::SetCrashData(GetPluginInstance(), original_url, top_level_url);
|
||||
return engine_->New(original_url, headers);
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,11 @@ struct PPB_PDF {
|
||||
struct PP_PrivateAccessibilityPageInfo* page_info,
|
||||
struct PP_PrivateAccessibilityTextRunInfo text_runs[],
|
||||
struct PP_PrivateAccessibilityCharInfo chars[]);
|
||||
|
||||
// Sends information about the PDF's URL and the embedder's URL.
|
||||
void (*SetCrashData)(PP_Instance instance,
|
||||
const char* pdf_url,
|
||||
const char* top_level_url);
|
||||
};
|
||||
|
||||
#endif // PPAPI_C_PRIVATE_PPB_PDF_H_
|
||||
|
@ -183,4 +183,14 @@ void PDF::SetAccessibilityPageInfo(
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void PDF::SetCrashData(const InstanceHandle& instance,
|
||||
const char* pdf_url,
|
||||
const char* top_level_url) {
|
||||
if (has_interface<PPB_PDF>()) {
|
||||
get_interface<PPB_PDF>()->SetCrashData(instance.pp_instance(), pdf_url,
|
||||
top_level_url);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pp
|
||||
|
@ -69,6 +69,9 @@ class PDF {
|
||||
PP_PrivateAccessibilityPageInfo* page_info,
|
||||
PP_PrivateAccessibilityTextRunInfo text_runs[],
|
||||
PP_PrivateAccessibilityCharInfo chars[]);
|
||||
static void SetCrashData(const InstanceHandle& instance,
|
||||
const char* pdf_url,
|
||||
const char* top_level_url);
|
||||
};
|
||||
|
||||
} // namespace pp
|
||||
|
@ -10,11 +10,13 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/debug/crash_logging.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/private/ppb_pdf.h"
|
||||
#include "ppapi/proxy/plugin_globals.h"
|
||||
#include "ppapi/proxy/ppapi_messages.h"
|
||||
#include "ppapi/shared_impl/var.h"
|
||||
#include "third_party/icu/source/i18n/unicode/usearch.h"
|
||||
@ -190,5 +192,12 @@ void PDFResource::SetAccessibilityPageInfo(
|
||||
*page_info, text_run_vector, char_vector));
|
||||
}
|
||||
|
||||
void PDFResource::SetCrashData(const char* pdf_url, const char* top_level_url) {
|
||||
if (pdf_url)
|
||||
base::debug::SetCrashKeyValue("subresource_url", pdf_url);
|
||||
if (top_level_url)
|
||||
PluginGlobals::Get()->SetActiveURL(top_level_url);
|
||||
}
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
||||
|
@ -62,6 +62,7 @@ class PPAPI_PROXY_EXPORT PDFResource
|
||||
PP_PrivateAccessibilityPageInfo* page_info,
|
||||
PP_PrivateAccessibilityTextRunInfo text_runs[],
|
||||
PP_PrivateAccessibilityCharInfo chars[]) override;
|
||||
void SetCrashData(const char* pdf_url, const char* top_level_url) override;
|
||||
|
||||
private:
|
||||
std::string locale_;
|
||||
|
@ -40,6 +40,8 @@ class PPB_PDF_API {
|
||||
PP_PrivateAccessibilityPageInfo* page_info,
|
||||
PP_PrivateAccessibilityTextRunInfo text_runs[],
|
||||
PP_PrivateAccessibilityCharInfo chars[]) = 0;
|
||||
virtual void SetCrashData(const char* pdf_url, const char* top_level_url) = 0;
|
||||
|
||||
static const SingletonResourceID kSingletonResourceID = PDF_SINGLETON_ID;
|
||||
};
|
||||
|
||||
|
@ -160,24 +160,34 @@ void SetAccessibilityPageInfo(
|
||||
enter.functions()->SetAccessibilityPageInfo(page_info, text_runs, chars);
|
||||
}
|
||||
|
||||
void SetCrashData(PP_Instance instance,
|
||||
const char* pdf_url,
|
||||
const char* top_level_url) {
|
||||
EnterInstanceAPI<PPB_PDF_API> enter(instance);
|
||||
if (enter.failed())
|
||||
return;
|
||||
enter.functions()->SetCrashData(pdf_url, top_level_url);
|
||||
}
|
||||
|
||||
const PPB_PDF g_ppb_pdf_thunk = {
|
||||
&GetFontFileWithFallback,
|
||||
&GetFontTableForPrivateFontFile,
|
||||
&SearchString,
|
||||
&DidStartLoading,
|
||||
&DidStopLoading,
|
||||
&SetContentRestriction,
|
||||
&UserMetricsRecordAction,
|
||||
&HasUnsupportedFeature,
|
||||
&SaveAs,
|
||||
&Print,
|
||||
&IsFeatureEnabled,
|
||||
&SetSelectedText,
|
||||
&SetLinkUnderCursor,
|
||||
&GetV8ExternalSnapshotData,
|
||||
&SetAccessibilityViewportInfo,
|
||||
&SetAccessibilityDocInfo,
|
||||
&SetAccessibilityPageInfo
|
||||
&GetFontFileWithFallback,
|
||||
&GetFontTableForPrivateFontFile,
|
||||
&SearchString,
|
||||
&DidStartLoading,
|
||||
&DidStopLoading,
|
||||
&SetContentRestriction,
|
||||
&UserMetricsRecordAction,
|
||||
&HasUnsupportedFeature,
|
||||
&SaveAs,
|
||||
&Print,
|
||||
&IsFeatureEnabled,
|
||||
&SetSelectedText,
|
||||
&SetLinkUnderCursor,
|
||||
&GetV8ExternalSnapshotData,
|
||||
&SetAccessibilityViewportInfo,
|
||||
&SetAccessibilityDocInfo,
|
||||
&SetAccessibilityPageInfo,
|
||||
&SetCrashData,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user