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

Unified Diff: ios/chrome/browser/web/tab_id_tab_helper.mm

Issue 2956483003: [ios] TabIdTabHelper (Closed)
Patch Set: Additional unit tests and other edits. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/web/tab_id_tab_helper.h ('k') | ios/chrome/browser/web/tab_id_tab_helper_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/tab_id_tab_helper.mm
diff --git a/ios/chrome/browser/web/tab_id_tab_helper.mm b/ios/chrome/browser/web/tab_id_tab_helper.mm
new file mode 100644
index 0000000000000000000000000000000000000000..8c06375f9fa20533d771e07e16fd0ec2d3a83c2b
--- /dev/null
+++ b/ios/chrome/browser/web/tab_id_tab_helper.mm
@@ -0,0 +1,35 @@
+// Copyright 2017 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.
+
+#import "ios/chrome/browser/web/tab_id_tab_helper.h"
+
+#include "base/mac/foundation_util.h"
+#include "base/strings/sys_string_conversions.h"
+#import "ios/web/public/serializable_user_data_manager.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+DEFINE_WEB_STATE_USER_DATA_KEY(TabIdTabHelper);
+
+namespace {
+// The key under which the tab ID is stored in the WebState's serializable user
+// data.
+NSString* const kTabIdKey = @"TabId";
+}
+
+TabIdTabHelper::TabIdTabHelper(web::WebState* web_state) {
+ web::SerializableUserDataManager* user_data_manager =
+ web::SerializableUserDataManager::FromWebState(web_state);
+ NSString* unique_id = base::mac::ObjCCast<NSString>(
+ user_data_manager->GetValueForSerializationKey(kTabIdKey));
+ if (![unique_id length]) {
+ unique_id = [[NSUUID UUID] UUIDString];
+ user_data_manager->AddSerializableData(unique_id, kTabIdKey);
+ }
+ tab_id_ = [unique_id copy];
+}
+
+TabIdTabHelper::~TabIdTabHelper() = default;
« no previous file with comments | « ios/chrome/browser/web/tab_id_tab_helper.h ('k') | ios/chrome/browser/web/tab_id_tab_helper_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698