OLD | NEW |
---|---|
(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); | |
rohitrao (ping after 24h)
2017/06/23 11:10:27
Is this guaranteed to exist before the TabIDTabHel
edchin
2017/06/23 16:24:21
The class comment says this:
"// Returns the Seria
| |
26 NSString* unique_id = base::mac::ObjCCast<NSString>( | |
27 user_data_manager->GetValueForSerializationKey(kTabIDKey)); | |
28 if (!unique_id || ![unique_id length]) { | |
29 unique_id = [[NSUUID UUID] UUIDString]; | |
30 user_data_manager->AddSerializableData(unique_id, kTabIDKey); | |
31 } | |
32 tab_id_ = base::SysNSStringToUTF8(unique_id); | |
33 } | |
34 | |
35 TabIDTabHelper::~TabIDTabHelper() = default; | |
OLD | NEW |