Commit 82aff9dd authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Revert "Clean up SpeechRecognitionSessionContext."

This reverts commit e9c5d973.

Reason for revert: There were clients depending on this confusion of invalid ID. It's not clear what broke, as tests are not reliable, so reverting to make sure that the 66 branch works.

Original change's description:
> Clean up SpeechRecognitionSessionContext.
> 
> The correct "no process" id is not 0; use instead
> content::ChildProcessHost::kInvalidUniqueID (-1).
> 
> The correct "no view/frame" id is not 0; use instead
> MSG_ROUTING_NONE (-2).
> 
> In addition, guest_render_view_id is not actually used,
> so remove it.
> 
> BUG=390749
> 
> Change-Id: Iaf0510b00e8646f71d23eee2c9309e64f59e0903
> Reviewed-on: https://chromium-review.googlesource.com/922802
> Reviewed-by: Olga Sharonova <olka@chromium.org>
> Reviewed-by: Justin Schuh <jschuh@chromium.org>
> Commit-Queue: Avi Drissman <avi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#537378}

TBR=avi@chromium.org,jschuh@chromium.org,olka@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 390749
Change-Id: Icceeb7ff0e609e9193ae4c3a88e7a69f537242fe
Reviewed-on: https://chromium-review.googlesource.com/938723Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Olga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539503}
parent b5d31d97
......@@ -32,7 +32,6 @@
#include "content/public/browser/speech_recognition_session_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/speech_recognition_error.h"
#include "content/public/common/speech_recognition_result.h"
#include "extensions/features/features.h"
......@@ -276,13 +275,11 @@ void ChromeSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
// Make sure that initiators (extensions/web pages) properly set the
// |render_process_id| field, which is needed later to retrieve the profile.
DCHECK_NE(context.render_process_id,
content::ChildProcessHost::kInvalidUniqueID);
DCHECK_NE(context.render_process_id, 0);
int render_process_id = context.render_process_id;
int render_view_id = context.render_view_id;
if (context.embedder_render_process_id !=
content::ChildProcessHost::kInvalidUniqueID) {
if (context.embedder_render_process_id) {
// If this is a request originated from a guest, we need to re-route the
// permission check through the embedder (app).
render_process_id = context.embedder_render_process_id;
......
......@@ -17,7 +17,6 @@
#include "content/public/browser/speech_recognition_manager_delegate.h"
#include "content/public/browser/speech_recognition_session_config.h"
#include "content/public/browser/speech_recognition_session_context.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_switches.h"
namespace content {
......@@ -90,7 +89,7 @@ void SpeechRecognitionDispatcherHost::OnStartRequest(
return;
}
int embedder_render_process_id = ChildProcessHost::kInvalidUniqueID;
int embedder_render_process_id = 0;
int embedder_render_view_id = MSG_ROUTING_NONE;
RenderViewHostImpl* render_view_host =
RenderViewHostImpl::FromID(render_process_id_, params.render_view_id);
......@@ -110,7 +109,7 @@ void SpeechRecognitionDispatcherHost::OnStartRequest(
// to decide permission.
embedder_render_process_id =
outer_web_contents->GetRenderViewHost()->GetProcess()->GetID();
DCHECK_NE(embedder_render_process_id, ChildProcessHost::kInvalidUniqueID);
DCHECK_NE(embedder_render_process_id, 0);
embedder_render_view_id =
outer_web_contents->GetRenderViewHost()->GetRoutingID();
DCHECK_NE(embedder_render_view_id, MSG_ROUTING_NONE);
......@@ -150,6 +149,8 @@ void SpeechRecognitionDispatcherHost::OnStartRequestOnIO(
context.render_frame_id = params_render_frame_id;
context.embedder_render_process_id = embedder_render_process_id;
context.embedder_render_view_id = embedder_render_view_id;
if (embedder_render_process_id)
context.guest_render_view_id = params.render_view_id;
context.request_id = params.request_id;
SpeechRecognitionSessionConfig config;
......
......@@ -4,18 +4,19 @@
#include "content/public/browser/speech_recognition_session_context.h"
#include "content/public/common/child_process_host.h"
#include "ipc/ipc_message.h"
namespace content {
SpeechRecognitionSessionContext::SpeechRecognitionSessionContext()
: render_process_id(ChildProcessHost::kInvalidUniqueID),
render_view_id(MSG_ROUTING_NONE),
render_frame_id(MSG_ROUTING_NONE),
embedder_render_process_id(ChildProcessHost::kInvalidUniqueID),
: render_process_id(0),
render_view_id(0),
render_frame_id(0),
guest_render_view_id(MSG_ROUTING_NONE),
embedder_render_process_id(0),
embedder_render_view_id(MSG_ROUTING_NONE),
request_id(0) {}
request_id(0) {
}
SpeechRecognitionSessionContext::SpeechRecognitionSessionContext(
const SpeechRecognitionSessionContext& other) = default;
......
......@@ -29,6 +29,16 @@ struct CONTENT_EXPORT SpeechRecognitionSessionContext {
int render_view_id;
int render_frame_id;
// Browser plugin guest's render view id, if this context represents a speech
// recognition request from an embedder on behalf of the guest. This is used
// for input tag where speech bubble is to be shown.
//
// TODO(lazyboy): Right now showing bubble from guest does not work, we fall
// back to embedder instead, fix this and use
// embedder_render_process_id/embedder_render_view_id similar to Web Speech
// API below.
int guest_render_view_id;
// The pair (|embedder_render_process_id|, |embedder_render_view_id|)
// represents a Browser plugin guest's embedder. This is filled in if the
// session is from a guest Web Speech API. We use these to check if the
......
......@@ -10,7 +10,6 @@
#include "content/public/browser/speech_recognition_manager.h"
#include "content/public/browser/speech_recognition_session_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h"
#include "extensions/browser/view_type_utils.h"
using content::BrowserThread;
......@@ -75,8 +74,7 @@ void ShellSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
// Make sure that initiators (extensions/web pages) properly set the
// |render_process_id| field, which is needed later to retrieve the profile.
DCHECK_NE(context.render_process_id,
content::ChildProcessHost::kInvalidUniqueID);
DCHECK_NE(context.render_process_id, 0);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
......
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