Commit a1fa2144 authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Disable logging if the chrome://inspect page web view is purged.

The system may purge the web view associated with the chrome://inspect page if
it is left with logging enabled and many other tabs are used.

Since the web view is gone, a page reload must occur when the user navigates
back to the tab. The reload will cause all logs to be cleared from the
chrome://inspect page and will reset the button back to "Start Logging". Turning
off logging in InspectDOMHandler ensures that the state matches what the user
will see when they navigate back to the chrome://inspect tab.

Bug: 920823
Change-Id: I852d5a264f2d11424e8183fe1aeffb0299572537
Reviewed-on: https://chromium-review.googlesource.com/c/1435035
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626196}
parent 2cbe8356
...@@ -186,6 +186,15 @@ void InspectDOMHandler::DidReceiveConsoleMessage( ...@@ -186,6 +186,15 @@ void InspectDOMHandler::DidReceiveConsoleMessage(
web::WebState* web_state, web::WebState* web_state,
web::WebFrame* sender_frame, web::WebFrame* sender_frame,
const JavaScriptConsoleMessage& message) { const JavaScriptConsoleMessage& message) {
web::WebFrame* inspect_ui_main_frame =
web::GetMainWebFrame(web_ui()->GetWebState());
if (!inspect_ui_main_frame) {
// Disable logging and drop this message because the main frame no longer
// exists.
SetLoggingEnabled(false);
return;
}
std::vector<base::Value> params; std::vector<base::Value> params;
web::WebFrame* main_web_frame = web::GetMainWebFrame(web_state); web::WebFrame* main_web_frame = web::GetMainWebFrame(web_state);
params.push_back(base::Value(main_web_frame->GetFrameId())); params.push_back(base::Value(main_web_frame->GetFrameId()));
...@@ -194,8 +203,8 @@ void InspectDOMHandler::DidReceiveConsoleMessage( ...@@ -194,8 +203,8 @@ void InspectDOMHandler::DidReceiveConsoleMessage(
params.push_back(base::Value(message.level)); params.push_back(base::Value(message.level));
params.push_back(message.message->Clone()); params.push_back(message.message->Clone());
web::GetMainWebFrame(web_ui()->GetWebState()) inspect_ui_main_frame->CallJavaScriptFunction(
->CallJavaScriptFunction("inspectWebUI.logMessageReceived", params); "inspectWebUI.logMessageReceived", params);
} }
void InspectDOMHandler::SetDelegateForWebStatesInTabModel( void InspectDOMHandler::SetDelegateForWebStatesInTabModel(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment