Commit 1aeb1ea3 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

find_in_page: FindTabHelper need not be a WebContentsObserver.

It has not actually observed anything in over eight years, when it
stopped overriding TabContentsObserver::OnMessageReceived.
  https://codereview.chromium.org/7828025/diff/2005/chrome/browser/ui/find_bar/find_tab_helper.h

All it actually cares about is storing a WebContents*, which there are
simpler ways to do.

While here, remove two includes which no longer seem used.

Change-Id: Iabb87720cde91b5edf16a6039fe602cc2e6cb4ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2224028
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774461}
parent 1b2e9474
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/find_in_page/find_result_observer.h" #include "components/find_in_page/find_result_observer.h"
#include "components/find_in_page/find_types.h" #include "components/find_in_page/find_types.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/stop_find_action.h" #include "content/public/common/stop_find_action.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h" #include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
...@@ -27,7 +25,7 @@ namespace find_in_page { ...@@ -27,7 +25,7 @@ namespace find_in_page {
int FindTabHelper::find_request_id_counter_ = -1; int FindTabHelper::find_request_id_counter_ = -1;
FindTabHelper::FindTabHelper(WebContents* web_contents) FindTabHelper::FindTabHelper(WebContents* web_contents)
: content::WebContentsObserver(web_contents), : web_contents_(web_contents),
current_find_request_id_(find_request_id_counter_++), current_find_request_id_(find_request_id_counter_++),
current_find_session_id_(current_find_request_id_) {} current_find_session_id_(current_find_request_id_) {}
...@@ -93,8 +91,7 @@ void FindTabHelper::StartFinding(base::string16 search_string, ...@@ -93,8 +91,7 @@ void FindTabHelper::StartFinding(base::string16 search_string,
options->match_case = case_sensitive; options->match_case = case_sensitive;
options->find_next = find_next; options->find_next = find_next;
options->run_synchronously_for_testing = run_synchronously_for_testing; options->run_synchronously_for_testing = run_synchronously_for_testing;
web_contents()->Find(current_find_request_id_, find_text_, web_contents_->Find(current_find_request_id_, find_text_, std::move(options));
std::move(options));
} }
void FindTabHelper::StopFinding(SelectionAction selection_action) { void FindTabHelper::StopFinding(SelectionAction selection_action) {
...@@ -128,11 +125,11 @@ void FindTabHelper::StopFinding(SelectionAction selection_action) { ...@@ -128,11 +125,11 @@ void FindTabHelper::StopFinding(SelectionAction selection_action) {
NOTREACHED(); NOTREACHED();
action = content::STOP_FIND_ACTION_KEEP_SELECTION; action = content::STOP_FIND_ACTION_KEEP_SELECTION;
} }
web_contents()->StopFinding(action); web_contents_->StopFinding(action);
} }
void FindTabHelper::ActivateFindInPageResultForAccessibility() { void FindTabHelper::ActivateFindInPageResultForAccessibility() {
web_contents()->GetMainFrame()->ActivateFindInPageResultForAccessibility( web_contents_->GetMainFrame()->ActivateFindInPageResultForAccessibility(
current_find_request_id_); current_find_request_id_);
} }
...@@ -148,13 +145,13 @@ base::string16 FindTabHelper::GetInitialSearchText() { ...@@ -148,13 +145,13 @@ base::string16 FindTabHelper::GetInitialSearchText() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void FindTabHelper::ActivateNearestFindResult(float x, float y) { void FindTabHelper::ActivateNearestFindResult(float x, float y) {
if (!find_op_aborted_ && !find_text_.empty()) { if (!find_op_aborted_ && !find_text_.empty()) {
web_contents()->ActivateNearestFindResult(x, y); web_contents_->ActivateNearestFindResult(x, y);
} }
} }
void FindTabHelper::RequestFindMatchRects(int current_version) { void FindTabHelper::RequestFindMatchRects(int current_version) {
if (!find_op_aborted_ && !find_text_.empty()) if (!find_op_aborted_ && !find_text_.empty())
web_contents()->RequestFindMatchRects(current_version); web_contents_->RequestFindMatchRects(current_version);
} }
#endif #endif
...@@ -184,7 +181,7 @@ void FindTabHelper::HandleFindReply(int request_id, ...@@ -184,7 +181,7 @@ void FindTabHelper::HandleFindReply(int request_id,
FindNotificationDetails(request_id, number_of_matches, selection, FindNotificationDetails(request_id, number_of_matches, selection,
active_match_ordinal, final_update); active_match_ordinal, final_update);
for (auto& observer : observers_) for (auto& observer : observers_)
observer.OnFindResultAvailable(web_contents()); observer.OnFindResultAvailable(web_contents_);
} }
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/find_in_page/find_notification_details.h" #include "components/find_in_page/find_notification_details.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "ui/gfx/range/range.h" #include "ui/gfx/range/range.h"
...@@ -18,8 +17,7 @@ class FindResultObserver; ...@@ -18,8 +17,7 @@ class FindResultObserver;
enum class SelectionAction; enum class SelectionAction;
// Per-tab find manager. Handles dealing with the life cycle of find sessions. // Per-tab find manager. Handles dealing with the life cycle of find sessions.
class FindTabHelper : public content::WebContentsObserver, class FindTabHelper : public content::WebContentsUserData<FindTabHelper> {
public content::WebContentsUserData<FindTabHelper> {
public: public:
// The delegate tracks search text state. // The delegate tracks search text state.
class Delegate { class Delegate {
...@@ -126,6 +124,9 @@ class FindTabHelper : public content::WebContentsObserver, ...@@ -126,6 +124,9 @@ class FindTabHelper : public content::WebContentsObserver,
// the user has issued a new search). // the user has issued a new search).
static int find_request_id_counter_; static int find_request_id_counter_;
// The WebContents which owns this helper.
content::WebContents* web_contents_ = nullptr;
// True if the Find UI is active for this Tab. // True if the Find UI is active for this Tab.
bool find_ui_active_ = false; bool find_ui_active_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment