diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 20:46:57 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-07 20:46:57 +0000 |
commit | 30e3e9a63cc47b765111a6a0091b455d4af446a0 (patch) | |
tree | 91c3a47b63081054f54e1463414e7da0a2431237 | |
parent | 90556dd639c154daa94142668f30aab0ac8de599 (diff) | |
download | chromium_src-30e3e9a63cc47b765111a6a0091b455d4af446a0.zip chromium_src-30e3e9a63cc47b765111a6a0091b455d4af446a0.tar.gz chromium_src-30e3e9a63cc47b765111a6a0091b455d4af446a0.tar.bz2 |
Support NULL geolocation and speech delegates to make embedding content easier.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/10542059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141074 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 29 insertions, 70 deletions
diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc index 4822286..6eb9c07 100644 --- a/content/browser/geolocation/geolocation_dispatcher_host.cc +++ b/content/browser/geolocation/geolocation_dispatcher_host.cc @@ -141,12 +141,17 @@ void GeolocationDispatcherHostImpl::OnRequestPermission( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; - geolocation_permission_context_->RequestGeolocationPermission( - render_process_id_, render_view_id, bridge_id, - requesting_frame, - base::Bind( - &SendGeolocationPermissionResponse, - render_process_id_, render_view_id, bridge_id)); + if (geolocation_permission_context_) { + geolocation_permission_context_->RequestGeolocationPermission( + render_process_id_, render_view_id, bridge_id, + requesting_frame, + base::Bind( + &SendGeolocationPermissionResponse, + render_process_id_, render_view_id, bridge_id)); + } else { + SendGeolocationPermissionResponse( + render_process_id_, render_view_id, bridge_id, true); + } } void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( @@ -156,6 +161,8 @@ void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; + if (!geolocation_permission_context_) + return; geolocation_permission_context_->CancelGeolocationPermissionRequest( render_process_id_, render_view_id, bridge_id, requesting_frame); diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.cc b/content/browser/speech/input_tag_speech_dispatcher_host.cc index 8907a01..8672c2b 100644 --- a/content/browser/speech/input_tag_speech_dispatcher_host.cc +++ b/content/browser/speech/input_tag_speech_dispatcher_host.cc @@ -80,8 +80,11 @@ void InputTagSpeechDispatcherHost::OnStartRecognition( config.origin_url = params.origin_url; config.initial_context = context; config.url_request_context_getter = url_request_context_getter_.get(); - DCHECK(recognition_preferences_.get()); - config.filter_profanities = recognition_preferences_->FilterProfanities(); + if (recognition_preferences_) { + config.filter_profanities = recognition_preferences_->FilterProfanities(); + } else { + config.filter_profanities = false; + } config.event_listener = this; int session_id = manager()->CreateSession(config); diff --git a/content/browser/speech/speech_recognition_dispatcher_host.cc b/content/browser/speech/speech_recognition_dispatcher_host.cc index 55d032e..3044cff 100644 --- a/content/browser/speech/speech_recognition_dispatcher_host.cc +++ b/content/browser/speech/speech_recognition_dispatcher_host.cc @@ -84,7 +84,11 @@ void SpeechRecognitionDispatcherHost::OnStartRequest( config.origin_url = params.origin_url; config.initial_context = context; config.url_request_context_getter = context_getter_.get(); - config.filter_profanities = recognition_preferences_->FilterProfanities(); + if (recognition_preferences_) { + config.filter_profanities = recognition_preferences_->FilterProfanities(); + } else { + config.filter_profanities = false; + } config.event_listener = this; int session_id = manager()->CreateSession(config); diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 72cbea8..487246aa 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -108,11 +108,13 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { // ensuring that it outlives DownloadManager. It's valid to return NULL. virtual DownloadManagerDelegate* GetDownloadManagerDelegate() = 0; - // Returns the geolocation permission context for this context. + // Returns the geolocation permission context for this context. It's valid to + // return NULL, in which case geolocation requests will always be allowed. virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0; // Returns the speech input preferences. SpeechRecognitionPreferences is a - // ref counted class, so callers should take a reference if needed. + // ref counted class, so callers should take a reference if needed. It's valid + // to return NULL. virtual SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() = 0; // Returns true if the last time this context was open it was exited cleanly. diff --git a/content/public/browser/speech_recognition_preferences.h b/content/public/browser/speech_recognition_preferences.h index 456029e..ffa64b0 100644 --- a/content/public/browser/speech_recognition_preferences.h +++ b/content/public/browser/speech_recognition_preferences.h @@ -16,7 +16,6 @@ class SpeechRecognitionPreferences virtual bool FilterProfanities() const = 0; protected: - SpeechRecognitionPreferences() {} virtual ~SpeechRecognitionPreferences() {} private: diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index 4deb540..ebeda20 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -10,10 +10,7 @@ #include "base/logging.h" #include "base/path_service.h" #include "base/threading/thread.h" -#include "content/public/browser/download_manager.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/geolocation_permission_context.h" -#include "content/public/browser/speech_recognition_preferences.h" #include "content/shell/shell_download_manager_delegate.h" #include "content/shell/shell_resource_context.h" #include "content/shell/shell_url_request_context_getter.h" @@ -37,51 +34,6 @@ const char kDotConfigDir[] = ".config"; const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; #endif -class ShellGeolocationPermissionContext : public GeolocationPermissionContext { - public: - ShellGeolocationPermissionContext() {} - - // GeolocationPermissionContext implementation). - virtual void RequestGeolocationPermission( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame, - base::Callback<void(bool)> callback) OVERRIDE { - NOTIMPLEMENTED(); - } - - virtual void CancelGeolocationPermissionRequest( - int render_process_id, - int render_view_id, - int bridge_id, - const GURL& requesting_frame) OVERRIDE { - NOTIMPLEMENTED(); - } - - protected: - virtual ~ShellGeolocationPermissionContext() {}; - - private: - DISALLOW_COPY_AND_ASSIGN(ShellGeolocationPermissionContext); -}; - -class ShellSpeechRecognitionPreferences : public SpeechRecognitionPreferences { - public: - ShellSpeechRecognitionPreferences() {} - - // Overridden from SpeechRecognitionPreferences: - virtual bool FilterProfanities() const OVERRIDE { - return false; - } - - protected: - virtual ~ShellSpeechRecognitionPreferences() {} - - private: - DISALLOW_COPY_AND_ASSIGN(ShellSpeechRecognitionPreferences); -}; - } // namespace ShellBrowserContext::ShellBrowserContext() { @@ -160,18 +112,12 @@ ResourceContext* ShellBrowserContext::GetResourceContext() { GeolocationPermissionContext* ShellBrowserContext::GetGeolocationPermissionContext() { - if (!geolocation_permission_context_) { - geolocation_permission_context_ = - new ShellGeolocationPermissionContext(); - } - return geolocation_permission_context_; + return NULL; } SpeechRecognitionPreferences* ShellBrowserContext::GetSpeechRecognitionPreferences() { - if (!speech_recognition_preferences_.get()) - speech_recognition_preferences_ = new ShellSpeechRecognitionPreferences(); - return speech_recognition_preferences_.get(); + return NULL; } bool ShellBrowserContext::DidLastSessionExitCleanly() { diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index d363d3e..b4e3899 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -49,8 +49,6 @@ class ShellBrowserContext : public BrowserContext { scoped_ptr<ResourceContext> resource_context_; scoped_refptr<ShellDownloadManagerDelegate> download_manager_delegate_; scoped_refptr<net::URLRequestContextGetter> url_request_getter_; - scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; - scoped_refptr<SpeechRecognitionPreferences> speech_recognition_preferences_; DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); }; |