Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: extensions/shell/browser/shell_speech_recognition_manager_delegate.cc

Issue 636863003: Make SpeechRecognition per RenderFrame instead of per RenderView. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/shell/browser/shell_speech_recognition_manager_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" 5 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/speech_recognition_manager.h" 10 #include "content/public/browser/speech_recognition_manager.h"
11 #include "content/public/browser/speech_recognition_session_context.h" 11 #include "content/public/browser/speech_recognition_session_context.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "extensions/browser/view_type_utils.h" 13 #include "extensions/browser/view_type_utils.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 using content::SpeechRecognitionManager; 16 using content::SpeechRecognitionManager;
17 using content::WebContents; 17 using content::WebContents;
18 18
19 namespace extensions { 19 namespace extensions {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id); 78 SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
79 79
80 // Make sure that initiators (extensions/web pages) properly set the 80 // Make sure that initiators (extensions/web pages) properly set the
81 // |render_process_id| field, which is needed later to retrieve the profile. 81 // |render_process_id| field, which is needed later to retrieve the profile.
82 DCHECK_NE(context.render_process_id, 0); 82 DCHECK_NE(context.render_process_id, 0);
83 83
84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 84 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
85 base::Bind(&CheckRenderViewType, 85 base::Bind(&CheckRenderViewType,
86 callback, 86 callback,
87 context.render_process_id, 87 context.render_process_id,
88 context.render_view_id)); 88 context.render_frame_id));
89 } 89 }
90 90
91 content::SpeechRecognitionEventListener* 91 content::SpeechRecognitionEventListener*
92 ShellSpeechRecognitionManagerDelegate::GetEventListener() { 92 ShellSpeechRecognitionManagerDelegate::GetEventListener() {
93 return this; 93 return this;
94 } 94 }
95 95
96 bool ShellSpeechRecognitionManagerDelegate::FilterProfanities( 96 bool ShellSpeechRecognitionManagerDelegate::FilterProfanities(
97 int render_process_id) { 97 int render_process_id) {
98 // TODO(zork): Determine where this preference should come from. 98 // TODO(zork): Determine where this preference should come from.
99 return true; 99 return true;
100 } 100 }
101 101
102 // static 102 // static
103 void ShellSpeechRecognitionManagerDelegate::CheckRenderViewType( 103 void ShellSpeechRecognitionManagerDelegate::CheckRenderViewType(
104 base::Callback<void(bool ask_user, bool is_allowed)> callback, 104 base::Callback<void(bool ask_user, bool is_allowed)> callback,
105 int render_process_id, 105 int render_process_id,
106 int render_view_id) { 106 int render_frame_id) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
108 const content::RenderViewHost* render_view_host = 108
109 content::RenderViewHost::FromID(render_process_id, render_view_id); 109 content::RenderFrameHost* render_frame_host =
110 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
110 bool allowed = false; 111 bool allowed = false;
111 bool check_permission = false; 112 bool check_permission = false;
112 113
113 if (render_view_host) { 114 if (render_frame_host) {
114 WebContents* web_contents = 115 WebContents* web_contents =
115 WebContents::FromRenderViewHost(render_view_host); 116 WebContents::FromRenderFrameHost(render_frame_host);
116 extensions::ViewType view_type = extensions::GetViewType(web_contents); 117 extensions::ViewType view_type = extensions::GetViewType(web_contents);
117 118
118 if (view_type == extensions::VIEW_TYPE_APP_WINDOW || 119 if (view_type == extensions::VIEW_TYPE_APP_WINDOW ||
119 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 120 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
120 allowed = true; 121 allowed = true;
121 check_permission = true; 122 check_permission = true;
122 } else { 123 } else {
123 LOG(WARNING) << "Speech recognition only supported in Apps."; 124 LOG(WARNING) << "Speech recognition only supported in Apps.";
124 } 125 }
125 } 126 }
126 127
127 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 128 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
128 base::Bind(callback, check_permission, allowed)); 129 base::Bind(callback, check_permission, allowed));
129 } 130 }
130 131
131 } // namespace speech 132 } // namespace speech
132 } // namespace extensions 133 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/browser/shell_speech_recognition_manager_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698