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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_find_helper.h

Issue 1641563002: Remove linked_ptr usage in //base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase, really Created 4 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "third_party/WebKit/public/web/WebFindOptions.h" 16 #include "third_party/WebKit/public/web/WebFindOptions.h"
16 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 class WebViewInternalFindFunction; 20 class WebViewInternalFindFunction;
20 class WebViewGuest; 21 class WebViewGuest;
21 22
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void PrepareResults(base::DictionaryValue* results); 93 void PrepareResults(base::DictionaryValue* results);
93 94
94 private: 95 private:
95 const base::string16 search_text_; 96 const base::string16 search_text_;
96 FindResults find_results_; 97 FindResults find_results_;
97 98
98 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent); 99 DISALLOW_COPY_AND_ASSIGN(FindUpdateEvent);
99 }; 100 };
100 101
101 // Handles all information about a find request and its results. 102 // Handles all information about a find request and its results.
102 class FindInfo { 103 class FindInfo : public base::RefCounted<FindInfo> {
103 public: 104 public:
104 FindInfo(int request_id, 105 FindInfo(int request_id,
105 const base::string16& search_text, 106 const base::string16& search_text,
106 const blink::WebFindOptions& options, 107 const blink::WebFindOptions& options,
107 scoped_refptr<WebViewInternalFindFunction> find_function); 108 scoped_refptr<WebViewInternalFindFunction> find_function);
108 ~FindInfo();
109 109
110 // Add another request to |find_next_requests_|. 110 // Add another request to |find_next_requests_|.
111 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) { 111 void AddFindNextRequest(const base::WeakPtr<FindInfo>& request) {
112 find_next_requests_.push_back(request); 112 find_next_requests_.push_back(request);
113 } 113 }
114 114
115 // Aggregate the find results. 115 // Aggregate the find results.
116 void AggregateResults(int number_of_matches, 116 void AggregateResults(int number_of_matches,
117 const gfx::Rect& selection_rect, 117 const gfx::Rect& selection_rect,
118 int active_match_ordinal, 118 int active_match_ordinal,
(...skipping 15 matching lines...) Expand all
134 134
135 const base::string16& search_text() { 135 const base::string16& search_text() {
136 return search_text_; 136 return search_text_;
137 } 137 }
138 138
139 // Calls the callback function within |find_function_| with the find results 139 // Calls the callback function within |find_function_| with the find results
140 // from within |find_results_|. 140 // from within |find_results_|.
141 void SendResponse(bool canceled); 141 void SendResponse(bool canceled);
142 142
143 private: 143 private:
144 friend class base::RefCounted<FindInfo>;
145
146 ~FindInfo();
147
144 const int request_id_; 148 const int request_id_;
145 const base::string16 search_text_; 149 const base::string16 search_text_;
146 blink::WebFindOptions options_; 150 blink::WebFindOptions options_;
147 scoped_refptr<WebViewInternalFindFunction> find_function_; 151 scoped_refptr<WebViewInternalFindFunction> find_function_;
148 FindResults find_results_; 152 FindResults find_results_;
149 153
150 // A find reply has been received for this find request. 154 // A find reply has been received for this find request.
151 bool replied_; 155 bool replied_;
152 156
153 // Stores pointers to all the find next requests if this is the first 157 // Stores pointers to all the find next requests if this is the first
(...skipping 11 matching lines...) Expand all
165 // Pointer to the webview that is being helped. 169 // Pointer to the webview that is being helped.
166 WebViewGuest* const webview_guest_; 170 WebViewGuest* const webview_guest_;
167 171
168 // A counter to generate a unique request id for a find request. 172 // A counter to generate a unique request id for a find request.
169 // We only need the ids to be unique for a given WebViewGuest. 173 // We only need the ids to be unique for a given WebViewGuest.
170 int current_find_request_id_; 174 int current_find_request_id_;
171 175
172 // Stores aggregated find results and other info for the |findupdate| event. 176 // Stores aggregated find results and other info for the |findupdate| event.
173 scoped_ptr<FindUpdateEvent> find_update_event_; 177 scoped_ptr<FindUpdateEvent> find_update_event_;
174 178
175 // Pointer to the first request of the current find session. 179 // Pointer to the first request of the current find session. find_info_map_
176 linked_ptr<FindInfo> current_find_session_; 180 // retains ownership.
181 scoped_refptr<FindInfo> current_find_session_;
177 182
178 // Stores each find request's information by request_id so that its callback 183 // Stores each find request's information by request_id so that its callback
179 // function can be called when its find results are available. 184 // function can be called when its find results are available.
180 typedef std::map<int, linked_ptr<FindInfo> > FindInfoMap; 185 using FindInfoMap = std::map<int, scoped_refptr<FindInfo>>;
181 FindInfoMap find_info_map_; 186 FindInfoMap find_info_map_;
182 187
183 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper); 188 DISALLOW_COPY_AND_ASSIGN(WebViewFindHelper);
184 }; 189 };
185 190
186 } // namespace extensions 191 } // namespace extensions
187 192
188 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_ 193 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698