diff options
author | dcheng <dcheng@chromium.org> | 2016-02-02 09:42:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-02 17:44:21 +0000 |
commit | 2588941279b28a6cf205896b955402e36535af6d (patch) | |
tree | c8229e5d0687ea7ae66e0eed4692275d3bda51ef /extensions/browser/guest_view | |
parent | 2b31885ad9eba1308c8ff908166624a12aaa3fd6 (diff) | |
download | chromium_src-2588941279b28a6cf205896b955402e36535af6d.zip chromium_src-2588941279b28a6cf205896b955402e36535af6d.tar.gz chromium_src-2588941279b28a6cf205896b955402e36535af6d.tar.bz2 |
Remove linked_ptr usage in //base.
And clean up some code that didn't IWYU.
BUG=556939
Review URL: https://codereview.chromium.org/1641563002
Cr-Commit-Position: refs/heads/master@{#372977}
Diffstat (limited to 'extensions/browser/guest_view')
8 files changed, 73 insertions, 84 deletions
diff --git a/extensions/browser/guest_view/extension_options/extension_options_guest.cc b/extensions/browser/guest_view/extension_options/extension_options_guest.cc index f594ade..9f3c07a 100644 --- a/extensions/browser/guest_view/extension_options/extension_options_guest.cc +++ b/extensions/browser/guest_view/extension_options/extension_options_guest.cc @@ -127,8 +127,8 @@ void ExtensionOptionsGuest::DidInitialize( void ExtensionOptionsGuest::GuestViewDidStopLoading() { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); - DispatchEventToView(new GuestViewEvent( - extension_options_internal::OnLoad::kEventName, std::move(args))); + DispatchEventToView(make_scoped_ptr(new GuestViewEvent( + extension_options_internal::OnLoad::kEventName, std::move(args)))); } const char* ExtensionOptionsGuest::GetAPINamespace() const { @@ -148,9 +148,9 @@ void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) { // Convert the size from physical pixels to logical pixels. options.width = PhysicalPixelsToLogicalPixels(pref_size.width()); options.height = PhysicalPixelsToLogicalPixels(pref_size.height()); - DispatchEventToView(new GuestViewEvent( + DispatchEventToView(make_scoped_ptr(new GuestViewEvent( extension_options_internal::OnPreferredSizeChanged::kEventName, - options.ToValue())); + options.ToValue()))); } bool ExtensionOptionsGuest::ShouldHandleFindRequestsForEmbedder() const { @@ -180,9 +180,9 @@ WebContents* ExtensionOptionsGuest::OpenURLFromTab( } void ExtensionOptionsGuest::CloseContents(WebContents* source) { - DispatchEventToView( + DispatchEventToView(make_scoped_ptr( new GuestViewEvent(extension_options_internal::OnClose::kEventName, - make_scoped_ptr(new base::DictionaryValue()))); + make_scoped_ptr(new base::DictionaryValue())))); } bool ExtensionOptionsGuest::HandleContextMenu( diff --git a/extensions/browser/guest_view/extension_view/extension_view_guest.cc b/extensions/browser/guest_view/extension_view/extension_view_guest.cc index d2db41e..cb2f60e 100644 --- a/extensions/browser/guest_view/extension_view/extension_view_guest.cc +++ b/extensions/browser/guest_view/extension_view/extension_view_guest.cc @@ -128,8 +128,8 @@ void ExtensionViewGuest::DidCommitProvisionalLoadForFrame( scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(guest_view::kUrl, url_.spec()); - DispatchEventToView( - new GuestViewEvent(extensionview::kEventLoadCommit, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(extensionview::kEventLoadCommit, std::move(args)))); } void ExtensionViewGuest::DidNavigateMainFrame( diff --git a/extensions/browser/guest_view/web_view/web_view_find_helper.cc b/extensions/browser/guest_view/web_view/web_view_find_helper.cc index 725326a..f9a315f 100644 --- a/extensions/browser/guest_view/web_view/web_view_find_helper.cc +++ b/extensions/browser/guest_view/web_view/web_view_find_helper.cc @@ -22,12 +22,12 @@ WebViewFindHelper::~WebViewFindHelper() { } void WebViewFindHelper::CancelAllFindSessions() { - current_find_session_ = linked_ptr<WebViewFindHelper::FindInfo>(); + current_find_session_ = nullptr; while (!find_info_map_.empty()) { find_info_map_.begin()->second->SendResponse(true /* canceled */); find_info_map_.erase(find_info_map_.begin()); } - if (find_update_event_.get()) + if (find_update_event_) DispatchFindUpdateEvent(true /* canceled */, true /* final_update */); find_update_event_.reset(); } @@ -40,8 +40,8 @@ void WebViewFindHelper::DispatchFindUpdateEvent(bool canceled, args->SetBoolean(webview::kFindCanceled, canceled); args->SetBoolean(webview::kFindFinalUpdate, final_update); DCHECK(webview_guest_); - webview_guest_->DispatchEventToView( - new GuestViewEvent(webview::kEventFindReply, std::move(args))); + webview_guest_->DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventFindReply, std::move(args)))); } void WebViewFindHelper::EndFindSession(int session_request_id, bool canceled) { @@ -100,9 +100,8 @@ void WebViewFindHelper::Find( std::pair<FindInfoMap::iterator, bool> insert_result = find_info_map_.insert(std::make_pair( current_find_request_id_, - linked_ptr< - WebViewFindHelper::FindInfo>(new WebViewFindHelper::FindInfo( - current_find_request_id_, search_text, options, find_function)))); + make_scoped_refptr(new FindInfo(current_find_request_id_, search_text, + options, find_function)))); // No duplicate insertions. DCHECK(insert_result.second); @@ -110,7 +109,7 @@ void WebViewFindHelper::Find( blink::WebFindOptions* full_options = insert_result.first->second->options(); // Set |findNext| implicitly. - if (current_find_session_.get()) { + if (current_find_session_) { const base::string16& current_search_text = current_find_session_->search_text(); bool current_match_case = current_find_session_->options()->matchCase; @@ -122,7 +121,7 @@ void WebViewFindHelper::Find( } // Link find requests that are a part of the same find session. - if (full_options->findNext && current_find_session_.get()) { + if (full_options->findNext && current_find_session_) { DCHECK(current_find_request_id_ != current_find_session_->request_id()); current_find_session_->AddFindNextRequest( insert_result.first->second->AsWeakPtr()); @@ -155,7 +154,7 @@ void WebViewFindHelper::FindReply(int request_id, return; // This find request must be a part of an existing find session. - DCHECK(current_find_session_.get()); + DCHECK(current_find_session_); WebViewFindHelper::FindInfo* find_info = find_iterator->second.get(); @@ -260,9 +259,6 @@ WebViewFindHelper::FindInfo::FindInfo( weak_ptr_factory_(this) { } -WebViewFindHelper::FindInfo::~FindInfo() { -} - void WebViewFindHelper::FindInfo::AggregateResults( int number_of_matches, const gfx::Rect& selection_rect, @@ -289,4 +285,6 @@ void WebViewFindHelper::FindInfo::SendResponse(bool canceled) { find_function_->SendResponse(true); } +WebViewFindHelper::FindInfo::~FindInfo() {} + } // namespace extensions diff --git a/extensions/browser/guest_view/web_view/web_view_find_helper.h b/extensions/browser/guest_view/web_view/web_view_find_helper.h index 0c622d0..6ec34e0 100644 --- a/extensions/browser/guest_view/web_view/web_view_find_helper.h +++ b/extensions/browser/guest_view/web_view/web_view_find_helper.h @@ -9,6 +9,7 @@ #include <vector> #include "base/macros.h" +#include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/values.h" #include "content/public/browser/web_contents.h" @@ -99,13 +100,12 @@ class WebViewFindHelper { }; // Handles all information about a find request and its results. - class FindInfo { + class FindInfo : public base::RefCounted<FindInfo> { public: FindInfo(int request_id, const base::string16& search_text, const blink::WebFindOptions& options, scoped_refptr<WebViewInternalFindFunction> find_function); - ~FindInfo(); // Add another request to |find_next_requests_|. void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) { @@ -141,6 +141,10 @@ class WebViewFindHelper { void SendResponse(bool canceled); private: + friend class base::RefCounted<FindInfo>; + + ~FindInfo(); + const int request_id_; const base::string16 search_text_; blink::WebFindOptions options_; @@ -172,12 +176,13 @@ class WebViewFindHelper { // Stores aggregated find results and other info for the |findupdate| event. scoped_ptr<FindUpdateEvent> find_update_event_; - // Pointer to the first request of the current find session. - linked_ptr<FindInfo> current_find_session_; + // Pointer to the first request of the current find session. find_info_map_ + // retains ownership. + scoped_refptr<FindInfo> current_find_session_; // Stores each find request's information by request_id so that its callback // function can be called when its find results are available. - typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap; + using FindInfoMap = std::map<int, scoped_refptr<FindInfo>>; FindInfoMap find_info_map_; DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper); diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc index db585b3..b1ae0a5 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.cc +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc @@ -371,8 +371,8 @@ void WebViewGuest::DidAttachToEmbedder() { void WebViewGuest::DidDropLink(const GURL& url) { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(guest_view::kUrl, url.spec()); - DispatchEventToView( - new GuestViewEvent(webview::kEventDropLink, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventDropLink, std::move(args)))); } void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) { @@ -426,8 +426,8 @@ void WebViewGuest::ClearDataInternal(base::Time remove_since, void WebViewGuest::GuestViewDidStopLoading() { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadStop, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadStop, std::move(args)))); } void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { @@ -481,8 +481,8 @@ void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, args->SetInteger(webview::kOldWidth, old_size.width()); args->SetInteger(webview::kNewHeight, new_size.height()); args->SetInteger(webview::kNewWidth, new_size.width()); - DispatchEventToView( - new GuestViewEvent(webview::kEventSizeChanged, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventSizeChanged, std::move(args)))); } bool WebViewGuest::IsAutoSizeSupported() const { @@ -497,8 +497,8 @@ void WebViewGuest::GuestZoomChanged(double old_zoom_level, scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetDouble(webview::kOldZoomFactor, old_zoom_factor); args->SetDouble(webview::kNewZoomFactor, new_zoom_factor); - DispatchEventToView( - new GuestViewEvent(webview::kEventZoomChange, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventZoomChange, std::move(args)))); } void WebViewGuest::WillDestroy() { @@ -517,15 +517,15 @@ bool WebViewGuest::AddMessageToConsole(WebContents* source, args->SetString(webview::kMessage, message); args->SetInteger(webview::kLine, line_no); args->SetString(webview::kSourceId, source_id); - DispatchEventToView( - new GuestViewEvent(webview::kEventConsoleMessage, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventConsoleMessage, std::move(args)))); return true; } void WebViewGuest::CloseContents(WebContents* source) { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); - DispatchEventToView( - new GuestViewEvent(webview::kEventClose, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventClose, std::move(args)))); } void WebViewGuest::FindReply(WebContents* source, @@ -575,8 +575,8 @@ void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(guest_view::kUrl, web_contents()->GetURL().spec()); args->SetDouble(webview::kProgress, progress); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadProgress, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadProgress, std::move(args)))); } void WebViewGuest::LoadAbort(bool is_top_level, @@ -588,8 +588,8 @@ void WebViewGuest::LoadAbort(bool is_top_level, args->SetString(guest_view::kUrl, url.possibly_invalid_spec()); args->SetInteger(guest_view::kCode, error_code); args->SetString(guest_view::kReason, error_type); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadAbort, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadAbort, std::move(args)))); } void WebViewGuest::SetContextMenuPosition(const gfx::Point& position) { @@ -640,16 +640,16 @@ void WebViewGuest::RendererResponsive(WebContents* source) { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetInteger(webview::kProcessId, web_contents()->GetRenderProcessHost()->GetID()); - DispatchEventToView( - new GuestViewEvent(webview::kEventResponsive, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventResponsive, std::move(args)))); } void WebViewGuest::RendererUnresponsive(WebContents* source) { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetInteger(webview::kProcessId, web_contents()->GetRenderProcessHost()->GetID()); - DispatchEventToView( - new GuestViewEvent(webview::kEventUnresponsive, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventUnresponsive, std::move(args)))); } void WebViewGuest::Observe(int type, @@ -816,8 +816,8 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame( web_contents()->GetController().GetEntryCount()); args->SetInteger(webview::kInternalProcessId, web_contents()->GetRenderProcessHost()->GetID()); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadCommit, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadCommit, std::move(args)))); find_helper_.CancelAllFindSessions(); } @@ -844,8 +844,8 @@ void WebViewGuest::DidStartProvisionalLoadForFrame( scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(guest_view::kUrl, validated_url.spec()); args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadStart, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadStart, std::move(args)))); } void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { @@ -856,7 +856,8 @@ void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { args->SetInteger(webview::kProcessId, web_contents()->GetRenderProcessHost()->GetID()); args->SetString(webview::kReason, TerminationStatusToString(status)); - DispatchEventToView(new GuestViewEvent(webview::kEventExit, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventExit, std::move(args)))); } void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { @@ -883,14 +884,14 @@ void WebViewGuest::ReportFrameNameChange(const std::string& name) { name_ = name; scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(webview::kName, name); - DispatchEventToView( - new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args)))); } void WebViewGuest::LoadHandlerCalled() { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); - DispatchEventToView( - new GuestViewEvent(webview::kEventContentLoad, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventContentLoad, std::move(args)))); } void WebViewGuest::LoadRedirect(const GURL& old_url, @@ -900,8 +901,8 @@ void WebViewGuest::LoadRedirect(const GURL& old_url, args->SetBoolean(guest_view::kIsTopLevel, is_top_level); args->SetString(webview::kNewURL, new_url.spec()); args->SetString(webview::kOldURL, old_url.spec()); - DispatchEventToView( - new GuestViewEvent(webview::kEventLoadRedirect, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventLoadRedirect, std::move(args)))); } void WebViewGuest::PushWebViewStateToIOThread() { @@ -1138,11 +1139,9 @@ void WebViewGuest::ApplyAttributes(const base::DictionaryValue& params) { } } -void WebViewGuest::ShowContextMenu( - int request_id, - const WebViewGuestDelegate::MenuItemVector* items) { +void WebViewGuest::ShowContextMenu(int request_id) { if (web_view_guest_delegate_) - web_view_guest_delegate_->OnShowContextMenu(request_id, items); + web_view_guest_delegate_->OnShowContextMenu(request_id); } void WebViewGuest::SetName(const std::string& name) { @@ -1496,8 +1495,8 @@ void WebViewGuest::SetFullscreenState(bool is_fullscreen) { // Dispatch a message so we can call document.webkitCancelFullscreen() // on the embedder. scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); - DispatchEventToView( - new GuestViewEvent(webview::kEventExitFullscreen, std::move(args))); + DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); } // Since we changed fullscreen state, sending a Resize message ensures that // renderer/ sees the change. diff --git a/extensions/browser/guest_view/web_view/web_view_guest.h b/extensions/browser/guest_view/web_view/web_view_guest.h index fa01df8..d1baac5 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.h +++ b/extensions/browser/guest_view/web_view/web_view_guest.h @@ -87,12 +87,7 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>, void NavigateGuest(const std::string& src, bool force_navigation); // Shows the context menu for the guest. - // |items| acts as a filter. This restricts the current context's default - // menu items to contain only the items from |items|. - // |items| == NULL means no filtering will be applied. - void ShowContextMenu( - int request_id, - const WebViewGuestDelegate::MenuItemVector* items); + void ShowContextMenu(int request_id); // Sets the frame name of the guest. void SetName(const std::string& name); diff --git a/extensions/browser/guest_view/web_view/web_view_guest_delegate.h b/extensions/browser/guest_view/web_view/web_view_guest_delegate.h index afee259..7ea61ca 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest_delegate.h +++ b/extensions/browser/guest_view/web_view/web_view_guest_delegate.h @@ -29,9 +29,6 @@ class WebViewGuestDelegate { public : virtual ~WebViewGuestDelegate() {} - typedef std::vector<linked_ptr<api::web_view_internal::ContextMenuItem> > - MenuItemVector; - // Called when context menu operation was handled. virtual bool HandleContextMenu(const content::ContextMenuParams& params) = 0; @@ -39,12 +36,7 @@ class WebViewGuestDelegate { virtual void OnDidInitialize() = 0; // Shows the context menu for the guest. - // |items| acts as a filter. This restricts the current context's default - // menu items to contain only the items from |items|. - // |items| == NULL means no filtering will be applied. - virtual void OnShowContextMenu( - int request_id, - const MenuItemVector* items) = 0; + virtual void OnShowContextMenu(int request_id) = 0; // Returns true if the WebViewGuest should handle find requests for its // embedder. diff --git a/extensions/browser/guest_view/web_view/web_view_permission_helper.cc b/extensions/browser/guest_view/web_view/web_view_permission_helper.cc index d8c7806..3ce5dd9 100644 --- a/extensions/browser/guest_view/web_view/web_view_permission_helper.cc +++ b/extensions/browser/guest_view/web_view/web_view_permission_helper.cc @@ -334,20 +334,20 @@ int WebViewPermissionHelper::RequestPermission( args->SetInteger(webview::kRequestId, request_id); switch (permission_type) { case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: { - web_view_guest_->DispatchEventToView( - new GuestViewEvent(webview::kEventNewWindow, std::move(args))); + web_view_guest_->DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventNewWindow, std::move(args)))); break; } case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { - web_view_guest_->DispatchEventToView( - new GuestViewEvent(webview::kEventDialog, std::move(args))); + web_view_guest_->DispatchEventToView(make_scoped_ptr( + new GuestViewEvent(webview::kEventDialog, std::move(args)))); break; } default: { args->SetString(webview::kPermission, PermissionTypeToString(permission_type)); - web_view_guest_->DispatchEventToView(new GuestViewEvent( - webview::kEventPermissionRequest, std::move(args))); + web_view_guest_->DispatchEventToView(make_scoped_ptr(new GuestViewEvent( + webview::kEventPermissionRequest, std::move(args)))); break; } } |