OLD | NEW |
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_view_host.h" |
10 #include "content/public/browser/speech_recognition_manager.h" | 10 #include "content/public/browser/speech_recognition_manager.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_view_id) { |
107 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
108 const content::RenderViewHost* render_view_host = | 108 content::RenderViewHost* render_view_host = |
109 content::RenderViewHost::FromID(render_process_id, render_view_id); | 109 content::RenderViewHost::FromID(render_process_id, render_view_id); |
110 bool allowed = false; | 110 bool allowed = false; |
111 bool check_permission = false; | 111 bool check_permission = false; |
112 | 112 |
113 if (render_view_host) { | 113 if (render_view_host) { |
114 WebContents* web_contents = | 114 WebContents* web_contents = |
115 WebContents::FromRenderViewHost(render_view_host); | 115 WebContents::FromRenderViewHost(render_view_host); |
116 extensions::ViewType view_type = extensions::GetViewType(web_contents); | 116 extensions::ViewType view_type = extensions::GetViewType(web_contents); |
117 | 117 |
118 if (view_type == extensions::VIEW_TYPE_APP_WINDOW || | 118 if (view_type == extensions::VIEW_TYPE_APP_WINDOW || |
119 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { | 119 view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
120 allowed = true; | 120 allowed = true; |
121 check_permission = true; | 121 check_permission = true; |
122 } else { | 122 } else { |
123 LOG(WARNING) << "Speech recognition only supported in Apps."; | 123 LOG(WARNING) << "Speech recognition only supported in Apps."; |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 127 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
128 base::Bind(callback, check_permission, allowed)); | 128 base::Bind(callback, check_permission, allowed)); |
129 } | 129 } |
130 | 130 |
131 } // namespace speech | 131 } // namespace speech |
132 } // namespace extensions | 132 } // namespace extensions |
OLD | NEW |