| 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/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 18 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
| 19 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
| 20 #include "chrome/browser/view_type_utils.h" | |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 22 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/resource_context.h" | 27 #include "content/public/browser/resource_context.h" |
| 29 #include "content/public/browser/speech_recognition_manager.h" | 28 #include "content/public/browser/speech_recognition_manager.h" |
| 30 #include "content/public/browser/speech_recognition_session_config.h" | 29 #include "content/public/browser/speech_recognition_session_config.h" |
| 31 #include "content/public/browser/speech_recognition_session_context.h" | 30 #include "content/public/browser/speech_recognition_session_context.h" |
| 32 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/common/speech_recognition_error.h" | 32 #include "content/public/common/speech_recognition_error.h" |
| 34 #include "content/public/common/speech_recognition_result.h" | 33 #include "content/public/common/speech_recognition_result.h" |
| 34 #include "extensions/browser/view_type_utils.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 38 | 38 |
| 39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 40 #include "chrome/installer/util/wmi.h" | 40 #include "chrome/installer/util/wmi.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 using content::BrowserThread; | 43 using content::BrowserThread; |
| 44 using content::SpeechRecognitionManager; | 44 using content::SpeechRecognitionManager; |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // This happens for extensions. Manifest should be checked for permission. | 494 // This happens for extensions. Manifest should be checked for permission. |
| 495 allowed = true; | 495 allowed = true; |
| 496 ask_permission = false; | 496 ask_permission = false; |
| 497 } | 497 } |
| 498 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 498 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 499 base::Bind(callback, ask_permission, allowed)); | 499 base::Bind(callback, ask_permission, allowed)); |
| 500 return; | 500 return; |
| 501 } | 501 } |
| 502 | 502 |
| 503 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); | 503 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); |
| 504 chrome::ViewType view_type = chrome::GetViewType(web_contents); | 504 extensions::ViewType view_type = extensions::GetViewType(web_contents); |
| 505 | 505 |
| 506 // TODO(kalman): Also enable speech bubble for extension popups | 506 // TODO(kalman): Also enable speech bubble for extension popups |
| 507 // (VIEW_TYPE_EXTENSION_POPUP) once popup-like control UI works properly in | 507 // (VIEW_TYPE_EXTENSION_POPUP) once popup-like control UI works properly in |
| 508 // extensions: http://crbug.com/163851. | 508 // extensions: http://crbug.com/163851. |
| 509 // Right now the extension popup closes and dismisses immediately on user | 509 // Right now the extension popup closes and dismisses immediately on user |
| 510 // click. | 510 // click. |
| 511 if (view_type == chrome::VIEW_TYPE_TAB_CONTENTS || | 511 if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS || |
| 512 view_type == chrome::VIEW_TYPE_APP_SHELL) { | 512 view_type == extensions::VIEW_TYPE_APP_SHELL) { |
| 513 // If it is a tab, we can show the speech input bubble or ask for | 513 // If it is a tab, we can show the speech input bubble or ask for |
| 514 // permission. | 514 // permission. |
| 515 | 515 |
| 516 allowed = true; | 516 allowed = true; |
| 517 if (js_api) | 517 if (js_api) |
| 518 ask_permission = true; | 518 ask_permission = true; |
| 519 } | 519 } |
| 520 | 520 |
| 521 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 521 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 522 base::Bind(callback, ask_permission, allowed)); | 522 base::Bind(callback, ask_permission, allowed)); |
| 523 } | 523 } |
| 524 | 524 |
| 525 SpeechRecognitionBubbleController* | 525 SpeechRecognitionBubbleController* |
| 526 ChromeSpeechRecognitionManagerDelegate::GetBubbleController() { | 526 ChromeSpeechRecognitionManagerDelegate::GetBubbleController() { |
| 527 if (!bubble_controller_.get()) | 527 if (!bubble_controller_.get()) |
| 528 bubble_controller_ = new SpeechRecognitionBubbleController(this); | 528 bubble_controller_ = new SpeechRecognitionBubbleController(this); |
| 529 return bubble_controller_.get(); | 529 return bubble_controller_.get(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 } // namespace speech | 532 } // namespace speech |
| OLD | NEW |