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

Side by Side Diff: chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc

Issue 24292004: Allow webkitSpeechRecognition work from an app's background page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
OLDNEW
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"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host); 402 WebContents* web_contents = WebContents::FromRenderViewHost(render_view_host);
403 extensions::ViewType view_type = extensions::GetViewType(web_contents); 403 extensions::ViewType view_type = extensions::GetViewType(web_contents);
404 404
405 // TODO(kalman): Also enable speech bubble for extension popups 405 // TODO(kalman): Also enable speech bubble for extension popups
406 // (VIEW_TYPE_EXTENSION_POPUP) once popup-like control UI works properly in 406 // (VIEW_TYPE_EXTENSION_POPUP) once popup-like control UI works properly in
407 // extensions: http://crbug.com/163851. 407 // extensions: http://crbug.com/163851.
408 // Right now the extension popup closes and dismisses immediately on user 408 // Right now the extension popup closes and dismisses immediately on user
409 // click. 409 // click.
410 if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS || 410 if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS ||
411 view_type == extensions::VIEW_TYPE_APP_SHELL || 411 view_type == extensions::VIEW_TYPE_APP_SHELL ||
412 view_type == extensions::VIEW_TYPE_VIRTUAL_KEYBOARD) { 412 view_type == extensions::VIEW_TYPE_VIRTUAL_KEYBOARD ||
413 // Only allow requests through JavaScript API (|js_api| = true).
414 // Requests originating from html element (|js_api| = false) would want
415 // to show bubble which isn't quite intuitive from a background page. Also
416 // see todo above about issues with rendering such bubbles from extension
417 // popups.
418 (view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE &&
419 js_api)) {
413 // If it is a tab, we can show the speech input bubble or ask for 420 // If it is a tab, we can show the speech input bubble or ask for
414 // permission. 421 // permission.
415 422
416 allowed = true; 423 allowed = true;
417 if (js_api) 424 if (js_api)
418 ask_permission = true; 425 ask_permission = true;
not at google - send to devlin 2013/09/20 22:36:46 do you know how this ask_permission thing is suppo
lazyboy 2013/09/20 22:49:08 The |callback| carries |ask_permission|, which eve
not at google - send to devlin 2013/09/20 23:03:41 Yeah; "check_permission" would be better. "ask_per
lazyboy 2013/09/21 00:48:04 Done.
419 } 426 }
420 427
421 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 428 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
422 base::Bind(callback, ask_permission, allowed)); 429 base::Bind(callback, ask_permission, allowed));
423 } 430 }
424 431
425 } // namespace speech 432 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698