#ifndef CHROME_BROWSER_ANDROID_CUSTOMTABS_TEXT_FRAGMENT_LOOKUP_STATE_TRACKER_H_
#define CHROME_BROWSER_ANDROID_CUSTOMTABS_TEXT_FRAGMENT_LOOKUP_STATE_TRACKER_H_
#include "base/gtest_prod_util.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
namespace customtabs {
class TextFragmentLookupStateTracker
: public content::WebContentsObserver,
public content::WebContentsUserData<TextFragmentLookupStateTracker> {
public:
~TextFragmentLookupStateTracker() override;
using OnResultCallback = base::OnceCallback<void(
const std::string& state_key,
const std::vector<std::pair<std::string, bool>>& lookup_results)>;
void LookupTextFragment(const std::string& state_key,
const std::vector<std::string>& text_directives,
OnResultCallback on_result_callback);
void FindScrollAndHighlight(const std::string& text_directive) const;
private:
friend class content::WebContentsUserData<TextFragmentLookupStateTracker>;
FRIEND_TEST_ALL_PREFIXES(TextFragmentLookupStateTrackerTest,
ExtractAllowedTextDirectives);
explicit TextFragmentLookupStateTracker(content::WebContents* web_contents);
std::vector<std::string> ExtractAllowedTextDirectives(
const std::vector<std::string>& text_directives) const;
void PrimaryPageChanged(content::Page& page) override;
WEB_CONTENTS_USER_DATA_KEY_DECL();
size_t lookup_count_ = 0;
};
}
#endif