blob: 4401f8d77661aec44ece3bbe1df4adbc266b0978 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_COMPLEX_TASKS_IOS_TASK_TAB_HELPER_H_
#define IOS_CHROME_BROWSER_COMPLEX_TASKS_IOS_TASK_TAB_HELPER_H_
#include <map>
#import "ios/chrome/browser/complex_tasks/ios_content_record_task_id.h"
#include "ios/web/public/web_state_observer.h"
#import "ios/web/public/web_state_user_data.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// This class tracks Task IDs - navigations and relationships between
// navigations. Task IDs have applications in navigation clustering
// and assist in grouping together and organizing the user's history.
class IOSTaskTabHelper : public web::WebStateObserver,
public web::WebStateUserData<IOSTaskTabHelper> {
public:
explicit IOSTaskTabHelper(web::WebState* web_state);
~IOSTaskTabHelper() override;
// web::WebStateObserver
void DidStartNavigation(web::WebState* web_state,
web::NavigationContext* navigation_context) override;
void DidFinishNavigation(web::WebState* web_state,
web::NavigationContext* navigation_context) override;
void WebStateDestroyed(web::WebState* web_state) override;
const IOSContentRecordTaskId* GetContextRecordTaskId(int nav_id) const;
private:
friend class web::WebStateUserData<IOSTaskTabHelper>;
std::unordered_map<int, IOSContentRecordTaskId>
ios_content_record_task_id_map_;
web::WebState* web_state_ = nullptr;
int prev_item_unique_id_ = -1;
WEB_STATE_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(IOSTaskTabHelper);
};
#endif // IOS_CHROME_BROWSER_COMPLEX_TASKS_IOS_TASK_TAB_HELPER_H_