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

Side by Side Diff: ios/chrome/browser/web/tab_id_tab_helper.mm

Issue 2956483003: [ios] TabIdTabHelper (Closed)
Patch Set: Address comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/web/tab_id_tab_helper.h"
6
7 #include "base/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h"
9 #import "ios/web/public/serializable_user_data_manager.h"
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
15 DEFINE_WEB_STATE_USER_DATA_KEY(TabIDTabHelper);
16
17 namespace {
18 // The key under which the TabID is stored in the WebState's serializable user
19 // data.
20 NSString* const kTabIDKey = @"TabID";
21 }
22
23 TabIDTabHelper::TabIDTabHelper(web::WebState* web_state) {
24 web::SerializableUserDataManager* user_data_manager =
25 web::SerializableUserDataManager::FromWebState(web_state);
26 NSString* unique_id = base::mac::ObjCCast<NSString>(
27 user_data_manager->GetValueForSerializationKey(kTabIDKey));
28 if (!unique_id || ![unique_id length]) {
Eugene But (OOO till 7-30) 2017/06/23 22:44:56 No need for |!unique_id || | check. |[unique_id le
edchin 2017/06/26 16:20:57 Done.
29 unique_id = [[NSUUID UUID] UUIDString];
30 user_data_manager->AddSerializableData(unique_id, kTabIDKey);
31 }
32 tab_id_ = [unique_id copy];
33 }
34
35 TabIDTabHelper::~TabIDTabHelper() = default;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698