diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2015-06-16 13:02:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-16 20:04:29 +0000 |
commit | fccacdca58722bee1497fcb7f5cfc2780732a4e0 (patch) | |
tree | f72ec4547e53ae76cf4bca8ddbf0854f6b3cf3c6 /chrome/browser/extensions | |
parent | 92afd41b1d86710bc430d1647ab5ad1ecb6551b4 (diff) | |
download | chromium_src-fccacdca58722bee1497fcb7f5cfc2780732a4e0.zip chromium_src-fccacdca58722bee1497fcb7f5cfc2780732a4e0.tar.gz chromium_src-fccacdca58722bee1497fcb7f5cfc2780732a4e0.tar.bz2 |
[Extensions OOPI] Update extension functions to use RFH pt 3
Continue updating extension functions to use RenderFrameHost instead of
RenderViewHost.
This removes all remaining uses of the RenderViewHost except for:
- IPC messages
- RenderViewHost::Zoom
- GetMediaFileSystemsForExtension
Update ExtensionFunction::render_view_host() to be
render_view_host_do_not_use() to help prevent future uses.
BUG=455776
Review URL: https://codereview.chromium.org/1180073005
Cr-Commit-Position: refs/heads/master@{#334671}
Diffstat (limited to 'chrome/browser/extensions')
7 files changed, 58 insertions, 68 deletions
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index 0b167f0..3290a68 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -956,7 +956,7 @@ bool DownloadsDownloadFunction::RunAsync() { scoped_ptr<content::DownloadUrlParameters> download_params( new content::DownloadUrlParameters( download_url, render_frame_host()->GetProcess()->GetID(), - render_view_host()->GetRoutingID(), + render_view_host_do_not_use()->GetRoutingID(), current_profile->GetResourceContext())); base::FilePath creator_suggested_filename; diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc index d5f033d..f8136bc 100644 --- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc +++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc @@ -41,6 +41,7 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -147,10 +148,10 @@ bool GetGalleryFilePathAndId(const std::string& gallery_id, return true; } -WebContents* GetWebContents(content::RenderViewHost* rvh, +WebContents* GetWebContents(content::RenderFrameHost* rfh, Profile* profile, const std::string& app_id) { - WebContents* contents = WebContents::FromRenderViewHost(rvh); + WebContents* contents = WebContents::FromRenderFrameHost(rfh); WebContentsModalDialogManager* web_contents_modal_dialog_manager = WebContentsModalDialogManager::FromWebContents(contents); if (!web_contents_modal_dialog_manager) { @@ -159,16 +160,16 @@ WebContents* GetWebContents(content::RenderViewHost* rvh, // host the dialog. AppWindow* window = AppWindowRegistry::Get(profile) ->GetCurrentAppWindowForApp(app_id); - contents = window ? window->web_contents() : NULL; + contents = window ? window->web_contents() : nullptr; } return contents; } base::ListValue* ConstructFileSystemList( - content::RenderViewHost* rvh, + content::RenderFrameHost* rfh, const Extension* extension, const std::vector<MediaFileSystemInfo>& filesystems) { - if (!rvh) + if (!rfh) return NULL; MediaGalleriesPermission::CheckParam read_param( @@ -185,7 +186,7 @@ base::ListValue* ConstructFileSystemList( bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam( APIPermission::kMediaGalleries, &delete_param); - const int child_id = rvh->GetProcess()->GetID(); + const int child_id = rfh->GetProcess()->GetID(); scoped_ptr<base::ListValue> list(new base::ListValue()); for (size_t i = 0; i < filesystems.size(); ++i) { scoped_ptr<base::DictionaryValue> file_system_dict_value( @@ -523,7 +524,7 @@ void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( const std::vector<MediaFileSystemInfo>& filesystems) { scoped_ptr<base::ListValue> list( - ConstructFileSystemList(render_view_host(), extension(), filesystems)); + ConstructFileSystemList(render_frame_host(), extension(), filesystems)); if (!list.get()) { SendResponse(false); return; @@ -537,7 +538,7 @@ void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() { media_galleries::UsageCount(media_galleries::SHOW_DIALOG); WebContents* contents = - GetWebContents(render_view_host(), GetProfile(), extension()->id()); + GetWebContents(render_frame_host(), GetProfile(), extension()->id()); if (!contents) { SendResponse(false); return; @@ -551,14 +552,14 @@ void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() { void MediaGalleriesGetMediaFileSystemsFunction::GetMediaFileSystemsForExtension( const MediaFileSystemsCallback& cb) { - if (!render_view_host()) { + if (!render_frame_host()) { cb.Run(std::vector<MediaFileSystemInfo>()); return; } MediaFileSystemRegistry* registry = media_file_system_registry(); DCHECK(registry->GetPreferences(GetProfile())->IsInitialized()); - registry->GetMediaFileSystemsForExtension( - render_view_host(), extension(), cb); + registry->GetMediaFileSystemsForExtension(render_view_host_do_not_use(), + extension(), cb); } @@ -642,7 +643,7 @@ bool MediaGalleriesAddUserSelectedFolderFunction::RunAsync() { void MediaGalleriesAddUserSelectedFolderFunction::OnPreferencesInit() { Profile* profile = GetProfile(); const std::string& app_id = extension()->id(); - WebContents* contents = GetWebContents(render_view_host(), profile, app_id); + WebContents* contents = GetWebContents(render_frame_host(), profile, app_id); if (!contents) { // When the request originated from a background page, but there is no app // window open, check to see if it originated from a tab and display the @@ -704,7 +705,7 @@ void MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId( MediaGalleryPrefId pref_id, const std::vector<MediaFileSystemInfo>& filesystems) { scoped_ptr<base::ListValue> list( - ConstructFileSystemList(render_view_host(), extension(), filesystems)); + ConstructFileSystemList(render_frame_host(), extension(), filesystems)); if (!list.get()) { SendResponse(false); return; @@ -729,14 +730,14 @@ void MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId( void MediaGalleriesAddUserSelectedFolderFunction::GetMediaFileSystemsForExtension( const MediaFileSystemsCallback& cb) { - if (!render_view_host()) { + if (!render_frame_host()) { cb.Run(std::vector<MediaFileSystemInfo>()); return; } MediaFileSystemRegistry* registry = media_file_system_registry(); DCHECK(registry->GetPreferences(GetProfile())->IsInitialized()); - registry->GetMediaFileSystemsForExtension( - render_view_host(), extension(), cb); + registry->GetMediaFileSystemsForExtension(render_view_host_do_not_use(), + extension(), cb); } /////////////////////////////////////////////////////////////////////////////// @@ -877,7 +878,7 @@ void MediaGalleriesAddScanResultsFunction::OnPreferencesInit() { } WebContents* contents = - GetWebContents(render_view_host(), GetProfile(), extension()->id()); + GetWebContents(render_frame_host(), GetProfile(), extension()->id()); if (!contents) { SendResponse(false); return; @@ -889,22 +890,21 @@ void MediaGalleriesAddScanResultsFunction::OnPreferencesInit() { } void MediaGalleriesAddScanResultsFunction::GetAndReturnGalleries() { - if (!render_view_host()) { + if (!render_frame_host()) { ReturnGalleries(std::vector<MediaFileSystemInfo>()); return; } MediaFileSystemRegistry* registry = media_file_system_registry(); DCHECK(registry->GetPreferences(GetProfile())->IsInitialized()); registry->GetMediaFileSystemsForExtension( - render_view_host(), - extension(), + render_view_host_do_not_use(), extension(), base::Bind(&MediaGalleriesAddScanResultsFunction::ReturnGalleries, this)); } void MediaGalleriesAddScanResultsFunction::ReturnGalleries( const std::vector<MediaFileSystemInfo>& filesystems) { scoped_ptr<base::ListValue> list( - ConstructFileSystemList(render_view_host(), extension(), filesystems)); + ConstructFileSystemList(render_frame_host(), extension(), filesystems)); if (!list.get()) { SendResponse(false); return; @@ -1059,10 +1059,9 @@ void MediaGalleriesGetMetadataFunction::ConstructNextBlob( attached_images_list->Append(attached_image); blob_uuids->push_back(current_blob->GetUUID()); - WebContents* contents = WebContents::FromRenderViewHost(render_view_host()); extensions::BlobHolder* holder = extensions::BlobHolder::FromRenderProcessHost( - contents->GetRenderProcessHost()); + render_frame_host()->GetProcess()); holder->HoldBlobReference(current_blob.Pass()); // Construct the next Blob if necessary. @@ -1095,7 +1094,7 @@ MediaGalleriesAddGalleryWatchFunction:: bool MediaGalleriesAddGalleryWatchFunction::RunAsync() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(GetProfile()); - if (!render_view_host() || !render_view_host()->GetProcess()) + if (!render_frame_host() || !render_frame_host()->GetProcess()) return false; scoped_ptr<AddGalleryWatch::Params> params( @@ -1179,7 +1178,7 @@ MediaGalleriesRemoveGalleryWatchFunction:: bool MediaGalleriesRemoveGalleryWatchFunction::RunAsync() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (!render_view_host() || !render_view_host()->GetProcess()) + if (!render_frame_host() || !render_frame_host()->GetProcess()) return false; scoped_ptr<RemoveGalleryWatch::Params> params( @@ -1225,7 +1224,7 @@ MediaGalleriesGetAllGalleryWatchFunction:: bool MediaGalleriesGetAllGalleryWatchFunction::RunAsync() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (!render_view_host() || !render_view_host()->GetProcess()) + if (!render_frame_host() || !render_frame_host()->GetProcess()) return false; MediaGalleriesPreferences* preferences = @@ -1259,7 +1258,7 @@ MediaGalleriesRemoveAllGalleryWatchFunction:: bool MediaGalleriesRemoveAllGalleryWatchFunction::RunAsync() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (!render_view_host() || !render_view_host()->GetProcess()) + if (!render_frame_host() || !render_frame_host()->GetProcess()) return false; MediaGalleriesPreferences* preferences = diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc index 11f4926..64f67f2 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc @@ -84,10 +84,9 @@ ExtensionFunction::ResponseAction PasswordsPrivateDelegate* delegate = PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); - delegate->RequestShowPassword( - parameters->login_pair.origin_url, - parameters->login_pair.username, - render_view_host()); + delegate->RequestShowPassword(parameters->login_pair.origin_url, + parameters->login_pair.username, + GetSenderWebContents()); // No response given from this API function; instead, listeners wait for the // chrome.passwordsPrivate.onPlaintextPasswordRetrieved event to fire. diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_apitest.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_apitest.cc index 7c462fa..2373a24 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_apitest.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_apitest.cc @@ -91,10 +91,9 @@ class TestDelegate : public PasswordsPrivateDelegate { SendPasswordExceptionsList(); } - void RequestShowPassword( - const std::string& origin_url, - const std::string& username, - const content::RenderViewHost* render_view_host) override { + void RequestShowPassword(const std::string& origin_url, + const std::string& username, + content::WebContents* web_contents) override { // Return a mocked password value. std::string plaintext_password(kPlaintextPassword); observers_->Notify( diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h index 4683e28..3701724 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h @@ -26,7 +26,7 @@ class Value; } namespace content { -class RenderViewHost; +class WebContents; } namespace extensions { @@ -84,10 +84,9 @@ class PasswordsPrivateDelegate : public KeyedService { // |username| The username used in conjunction with the saved password. // |native_window| The Chrome host window; will be used to show an OS-level // authentication dialog if necessary. - virtual void RequestShowPassword( - const std::string& origin_url, - const std::string& username, - const content::RenderViewHost* render_view_host) = 0; + virtual void RequestShowPassword(const std::string& origin_url, + const std::string& username, + content::WebContents* web_contents) = 0; }; } // namespace extensions diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc index d6ae163..d786adb 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc @@ -33,7 +33,7 @@ PasswordsPrivateDelegateImpl::PasswordsPrivateDelegateImpl(Profile* profile) set_password_exception_list_called_(false), is_initialized_(false), languages_(profile->GetPrefs()->GetString(prefs::kAcceptLanguages)), - render_view_host_(nullptr), + web_contents_(nullptr), observers_(new base::ObserverListThreadSafe<Observer>()) { password_manager_presenter_->Initialize(); password_manager_presenter_->UpdatePasswordLists(); @@ -101,32 +101,29 @@ void PasswordsPrivateDelegateImpl::RemovePasswordExceptionInternal( void PasswordsPrivateDelegateImpl::RequestShowPassword( const std::string& origin_url, const std::string& username, - const content::RenderViewHost* render_view_host) { - ExecuteFunction(base::Bind( - &PasswordsPrivateDelegateImpl::RequestShowPasswordInternal, - base::Unretained(this), - origin_url, - username, - render_view_host)); + content::WebContents* web_contents) { + ExecuteFunction( + base::Bind(&PasswordsPrivateDelegateImpl::RequestShowPasswordInternal, + base::Unretained(this), origin_url, username, web_contents)); } void PasswordsPrivateDelegateImpl::RequestShowPasswordInternal( const std::string& origin_url, const std::string& username, - const content::RenderViewHost* render_view_host) { + content::WebContents* web_contents) { std::string key = LoginPairToMapKey(origin_url, username); if (login_pair_to_index_map_.find(key) == login_pair_to_index_map_.end()) { // If the URL/username pair does not exist in the map, do nothing. return; } - // Save |render_view_host| so that the call to RequestShowPassword() below can - // call use this value by calling GetNativeWindow(). Note: This is safe - // because GetNativeWindow() will only be called immediately from + // Save |web_contents| so that the call to RequestShowPassword() below + // can use this value by calling GetNativeWindow(). Note: This is safe because + // GetNativeWindow() will only be called immediately from // RequestShowPassword(). // TODO(stevenjb): Pass this directly to RequestShowPassword(); see // crbug.com/495290. - render_view_host_ = render_view_host; + web_contents_ = web_contents; // Request the password. When it is retrieved, ShowPassword() will be called. password_manager_presenter_->RequestShowPassword( @@ -227,9 +224,8 @@ void PasswordsPrivateDelegateImpl::SendPasswordExceptionsList() { #if !defined(OS_ANDROID) gfx::NativeWindow PasswordsPrivateDelegateImpl::GetNativeWindow() const { - DCHECK(render_view_host_); - return content::WebContents::FromRenderViewHost(render_view_host_) - ->GetTopLevelNativeWindow(); + DCHECK(web_contents_); + return web_contents_->GetTopLevelNativeWindow(); } #endif diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h index 5d94a63..63207cb 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.h @@ -23,7 +23,7 @@ class Profile; namespace content { -class RenderViewHost; +class WebContents; } namespace extensions { @@ -41,10 +41,9 @@ class PasswordsPrivateDelegateImpl : public PasswordsPrivateDelegate, void RemoveSavedPassword( const std::string& origin_url, const std::string& username) override; void RemovePasswordException(const std::string& exception_url) override; - void RequestShowPassword( - const std::string& origin_url, - const std::string& username, - const content::RenderViewHost* render_view_host) override; + void RequestShowPassword(const std::string& origin_url, + const std::string& username, + content::WebContents* web_contents) override; // PasswordUIView implementation. Profile* GetProfile() override; @@ -78,10 +77,9 @@ class PasswordsPrivateDelegateImpl : public PasswordsPrivateDelegate, void RemoveSavedPasswordInternal( const std::string& origin_url, const std::string& username); void RemovePasswordExceptionInternal(const std::string& exception_url); - void RequestShowPasswordInternal( - const std::string& origin_url, - const std::string& username, - const content::RenderViewHost* render_view_host); + void RequestShowPasswordInternal(const std::string& origin_url, + const std::string& username, + content::WebContents* web_contents); void SendSavedPasswordsList(); void SendPasswordExceptionsList(); @@ -113,9 +111,9 @@ class PasswordsPrivateDelegateImpl : public PasswordsPrivateDelegate, // User pref for storing accept languages. std::string languages_; - // The RenderViewHost used when invoking this API. Used to fetch the + // The WebContents used when invoking this API. Used to fetch the // NativeWindow for the window where the API was called. - const content::RenderViewHost* render_view_host_; + content::WebContents* web_contents_; // The observers. scoped_refptr<base::ObserverListThreadSafe<Observer>> observers_; |