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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/extensions/extension_service.h" | |
17 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/tab_contents/tab_util.h" | 17 #include "chrome/browser/tab_contents/tab_util.h" |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
24 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
25 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/resource_context.h" | 26 #include "content/public/browser/resource_context.h" |
28 #include "content/public/browser/speech_recognition_manager.h" | 27 #include "content/public/browser/speech_recognition_manager.h" |
29 #include "content/public/browser/speech_recognition_session_config.h" | 28 #include "content/public/browser/speech_recognition_session_config.h" |
30 #include "content/public/browser/speech_recognition_session_context.h" | 29 #include "content/public/browser/speech_recognition_session_context.h" |
31 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
32 #include "content/public/common/speech_recognition_error.h" | 31 #include "content/public/common/speech_recognition_error.h" |
33 #include "content/public/common/speech_recognition_result.h" | 32 #include "content/public/common/speech_recognition_result.h" |
34 #include "extensions/browser/view_type_utils.h" | |
35 #include "net/url_request/url_request_context_getter.h" | 33 #include "net/url_request/url_request_context_getter.h" |
36 | 34 |
37 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
38 #include "chrome/installer/util/wmi.h" | 36 #include "chrome/installer/util/wmi.h" |
39 #endif | 37 #endif |
40 | 38 |
| 39 #if defined(ENABLE_EXTENSIONS) |
| 40 #include "chrome/browser/extensions/extension_service.h" |
| 41 #include "extensions/browser/view_type_utils.h" |
| 42 #endif |
| 43 |
41 using content::BrowserThread; | 44 using content::BrowserThread; |
42 using content::SpeechRecognitionManager; | 45 using content::SpeechRecognitionManager; |
43 using content::WebContents; | 46 using content::WebContents; |
44 | 47 |
45 namespace speech { | 48 namespace speech { |
46 | 49 |
47 namespace { | 50 namespace { |
48 | 51 |
49 void TabClosedCallbackOnIOThread(int render_process_id, int render_view_id) { | 52 void TabClosedCallbackOnIOThread(int render_process_id, int render_view_id) { |
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); | 419 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); |
417 | 420 |
418 // chrome://app-list/ uses speech recognition. | 421 // chrome://app-list/ uses speech recognition. |
419 if (web_contents->GetCommittedWebUI() && | 422 if (web_contents->GetCommittedWebUI() && |
420 web_contents->GetLastCommittedURL().spec() == | 423 web_contents->GetLastCommittedURL().spec() == |
421 chrome::kChromeUIAppListStartPageURL) { | 424 chrome::kChromeUIAppListStartPageURL) { |
422 allowed = true; | 425 allowed = true; |
423 check_permission = false; | 426 check_permission = false; |
424 } | 427 } |
425 | 428 |
| 429 #if defined(ENABLE_EXTENSIONS) |
426 extensions::ViewType view_type = extensions::GetViewType(web_contents); | 430 extensions::ViewType view_type = extensions::GetViewType(web_contents); |
427 | 431 |
428 if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS || | 432 if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS || |
429 view_type == extensions::VIEW_TYPE_APP_WINDOW || | 433 view_type == extensions::VIEW_TYPE_APP_WINDOW || |
430 view_type == extensions::VIEW_TYPE_VIRTUAL_KEYBOARD || | 434 view_type == extensions::VIEW_TYPE_VIRTUAL_KEYBOARD || |
431 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 435 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
432 // If it is a tab, we can check for permission. For apps, this means | 436 // If it is a tab, we can check for permission. For apps, this means |
433 // manifest would be checked for permission. | 437 // manifest would be checked for permission. |
434 allowed = true; | 438 allowed = true; |
435 check_permission = true; | 439 check_permission = true; |
436 } | 440 } |
| 441 #else |
| 442 // Otherwise this should be a regular tab contents. |
| 443 allowed = true; |
| 444 check_permission = true; |
| 445 #endif |
437 | 446 |
438 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 447 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
439 base::Bind(callback, check_permission, allowed)); | 448 base::Bind(callback, check_permission, allowed)); |
440 } | 449 } |
441 | 450 |
442 } // namespace speech | 451 } // namespace speech |
OLD | NEW |