OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 5 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "chrome/common/chrome_view_type.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/render_view_host_delegate.h" | 21 #include "content/public/browser/render_view_host_delegate.h" |
21 #include "content/public/browser/resource_context.h" | 22 #include "content/public/browser/resource_context.h" |
22 #include "content/public/browser/speech_recognition_manager.h" | 23 #include "content/public/browser/speech_recognition_manager.h" |
23 #include "content/public/browser/speech_recognition_session_context.h" | 24 #include "content/public/browser/speech_recognition_session_context.h" |
24 #include "content/public/common/speech_recognition_error.h" | 25 #include "content/public/common/speech_recognition_error.h" |
25 #include "content/public/common/speech_recognition_result.h" | 26 #include "content/public/common/speech_recognition_result.h" |
26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 229 |
229 void ChromeSpeechRecognitionManagerDelegate::CheckRenderViewType( | 230 void ChromeSpeechRecognitionManagerDelegate::CheckRenderViewType( |
230 int session_id, | 231 int session_id, |
231 base::Callback<void(int session_id, bool is_allowed)> callback, | 232 base::Callback<void(int session_id, bool is_allowed)> callback, |
232 int render_process_id, | 233 int render_process_id, |
233 int render_view_id) { | 234 int render_view_id) { |
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
235 const content::RenderViewHost* render_view_host = | 236 const content::RenderViewHost* render_view_host = |
236 content::RenderViewHost::FromID(render_process_id, render_view_id); | 237 content::RenderViewHost::FromID(render_process_id, render_view_id); |
237 | 238 |
238 // For host delegates other than VIEW_TYPE_WEB_CONTENTS we can't reliably show | 239 // For host delegates other than VIEW_TYPE_TAB_CONTENTS we can't reliably show |
239 // a popup, including the speech input bubble. In these cases for privacy | 240 // a popup, including the speech input bubble. In these cases for privacy |
240 // reasons we don't want to start recording if the user can't be properly | 241 // reasons we don't want to start recording if the user can't be properly |
241 // notified. An example of this is trying to show the speech input bubble | 242 // notified. An example of this is trying to show the speech input bubble |
242 // within an extension popup: http://crbug.com/92083. In these situations the | 243 // within an extension popup: http://crbug.com/92083. In these situations the |
243 // speech input extension API should be used instead. | 244 // speech input extension API should be used instead. |
244 | 245 |
245 const bool allowed = (render_view_host != NULL && | 246 const bool allowed = (render_view_host != NULL && |
246 render_view_host->GetDelegate() != NULL && | 247 render_view_host->GetDelegate() != NULL && |
247 render_view_host->GetDelegate()->GetRenderViewType() == | 248 render_view_host->GetDelegate()->GetRenderViewType() == |
248 content::VIEW_TYPE_WEB_CONTENTS); | 249 chrome::VIEW_TYPE_TAB_CONTENTS); |
249 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 250 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
250 base::Bind(callback, session_id, allowed)); | 251 base::Bind(callback, session_id, allowed)); |
251 } | 252 } |
252 | 253 |
253 } // namespace speech | 254 } // namespace speech |
OLD | NEW |