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

Unified Diff: chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc

Issue 10409088: Get rid of the RenderViewType concept in content, since it was only used by Chrome. Store the enum… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
===================================================================
--- chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc (revision 138369)
+++ chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc (working copy)
@@ -14,15 +14,15 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/common/chrome_view_type.h"
+#include "chrome/browser/view_type_utils.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/speech_recognition_manager.h"
#include "content/public/browser/speech_recognition_session_config.h"
#include "content/public/browser/speech_recognition_session_context.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/common/speech_recognition_error.h"
#include "content/public/common/speech_recognition_result.h"
#include "grit/generated_resources.h"
@@ -35,6 +35,7 @@
using content::BrowserThread;
using content::SpeechRecognitionManager;
+using content::WebContents;
namespace {
const int kNoActiveBubble =
@@ -309,20 +310,22 @@
int render_process_id,
int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const content::RenderViewHost* render_view_host =
+ content::RenderViewHost* render_view_host =
Avi (use Gerrit) 2012/05/23 04:40:35 Since you fixed FromRenderViewHost you could leave
jam 2012/05/23 05:08:16 Done.
content::RenderViewHost::FromID(render_process_id, render_view_id);
-
- // For host delegates other than VIEW_TYPE_TAB_CONTENTS we can't reliably show
- // a popup, including the speech input bubble. In these cases for privacy
- // reasons we don't want to start recording if the user can't be properly
- // notified. An example of this is trying to show the speech input bubble
- // within an extension popup: http://crbug.com/92083. In these situations the
- // speech input extension API should be used instead.
-
- const bool allowed = (render_view_host != NULL &&
- render_view_host->GetDelegate() != NULL &&
- render_view_host->GetDelegate()->GetRenderViewType() ==
- chrome::VIEW_TYPE_TAB_CONTENTS);
+ bool allowed = false;
+ if (render_view_host) {
+ // For host delegates other than VIEW_TYPE_TAB_CONTENTS we can't reliably
+ // show a popup, including the speech input bubble. In these cases for
+ // privacy reasons we don't want to start recording if the user can't be
+ // properly notified. An example of this is trying to show the speech input
+ // bubble within an extension popup: http://crbug.com/92083. In these
+ // situations the speech input extension API should be used instead.
+ WebContents* web_contents =
+ WebContents::FromRenderViewHost(render_view_host);
+ chrome::ViewType view_type = chrome::GetViewType(web_contents);
+ if (view_type == chrome::VIEW_TYPE_TAB_CONTENTS)
+ allowed = true;
+ }
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(callback, session_id, allowed));
}

Powered by Google App Engine
This is Rietveld 408576698