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

Side by Side Diff: ios/web/ui_web_view_util.mm

Issue 1043243003: Upstream most of ios/web/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove accidentally-added clients Created 5 years, 8 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
« no previous file with comments | « ios/web/ui_web_view_util.h ('k') | ios/web/ui_web_view_util_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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/web/ui_web_view_util.h"
6
7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "ios/web/net/request_group_util.h"
11 #include "ios/web/public/web_client.h"
12
13 namespace {
14 // Returns true if given Request Group ID string contains only decimal digits.
15 BOOL IsValidRequestGroupID(NSString* request_group_id) {
16 return [[NSCharacterSet decimalDigitCharacterSet] isSupersetOfSet:
17 [NSCharacterSet characterSetWithCharactersInString:request_group_id]];
18 }
19 } // namespace
20
21 namespace web {
22
23 void BuildAndRegisterUserAgentForUIWebView(NSString* request_group_id,
24 BOOL use_desktop_user_agent) {
25 DCHECK(!request_group_id || IsValidRequestGroupID(request_group_id));
26 DCHECK(web::GetWebClient());
27 std::string baseUserAgent = web::GetWebClient()->GetUserAgent(
28 use_desktop_user_agent);
29 web::RegisterUserAgentForUIWebView(
30 web::AddRequestGroupIDToUserAgent(base::SysUTF8ToNSString(baseUserAgent),
31 request_group_id));
32 }
33
34 void RegisterUserAgentForUIWebView(NSString* user_agent) {
35 [[NSUserDefaults standardUserDefaults] registerDefaults:@{
36 @"UserAgent" : user_agent
37 }];
38 }
39
40 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/ui_web_view_util.h ('k') | ios/web/ui_web_view_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698