cr: Make sure gn isn't enabled automatically
[chromium-blink-merge.git] / ios / web / string_util.cc
bloba00d023e35e68bd6b50e46eb1d5d00dedf93eb26
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.
5 #include "ios/web/public/string_util.h"
7 #include "base/strings/string_util.h"
9 namespace web {
11 base::string16 GetStringByClippingLastWord(const base::string16& contents,
12 size_t length) {
13 if (contents.size() < length)
14 return contents;
16 base::string16 clipped_contents = contents.substr(0, length);
17 size_t last_space_index =
18 clipped_contents.find_last_of(base::kWhitespaceUTF16);
19 // TODO(droger): Check if we should return the empty string instead.
20 // See http://crbug.com/324304
21 if (last_space_index != base::string16::npos)
22 clipped_contents.resize(last_space_index);
23 return clipped_contents;
26 } // namespace web