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

Side by Side Diff: chrome/browser/profiles/profile_avatar_icon_util.cc

Issue 2131933002: Revert of Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 5 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
18 #include "base/values.h" 17 #include "base/values.h"
19 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
20 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
21 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
22 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
23 #include "skia/ext/image_operations.h" 22 #include "skia/ext/image_operations.h"
24 #include "third_party/skia/include/core/SkPaint.h" 23 #include "third_party/skia/include/core/SkPaint.h"
25 #include "third_party/skia/include/core/SkPath.h" 24 #include "third_party/skia/include/core/SkPath.h"
26 #include "third_party/skia/include/core/SkScalar.h" 25 #include "third_party/skia/include/core/SkScalar.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 CHECK_NE(index, kPlaceholderAvatarIndex); 480 CHECK_NE(index, kPlaceholderAvatarIndex);
482 return GetDefaultAvatarIconResourceInfo(index)->label_id; 481 return GetDefaultAvatarIconResourceInfo(index)->label_id;
483 } 482 }
484 483
485 bool IsDefaultAvatarIconIndex(size_t index) { 484 bool IsDefaultAvatarIconIndex(size_t index) {
486 return index < kDefaultAvatarIconsCount; 485 return index < kDefaultAvatarIconsCount;
487 } 486 }
488 487
489 bool IsDefaultAvatarIconUrl(const std::string& url, size_t* icon_index) { 488 bool IsDefaultAvatarIconUrl(const std::string& url, size_t* icon_index) {
490 DCHECK(icon_index); 489 DCHECK(icon_index);
491 if (!base::StartsWith(url, kDefaultUrlPrefix, base::CompareCase::SENSITIVE)) 490 if (url.find(kDefaultUrlPrefix) != 0)
492 return false; 491 return false;
493 492
494 int int_value = -1; 493 int int_value = -1;
495 if (base::StringToInt(base::StringPiece(url.begin() + 494 if (base::StringToInt(base::StringPiece(url.begin() +
496 strlen(kDefaultUrlPrefix), 495 strlen(kDefaultUrlPrefix),
497 url.end()), 496 url.end()),
498 &int_value)) { 497 &int_value)) {
499 if (int_value < 0 || 498 if (int_value < 0 ||
500 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) 499 int_value >= static_cast<int>(kDefaultAvatarIconsCount))
501 return false; 500 return false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 avatar_info->SetString( 563 avatar_info->SetString(
565 "label", l10n_util::GetStringUTF16( 564 "label", l10n_util::GetStringUTF16(
566 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); 565 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i)));
567 566
568 avatars->Append(std::move(avatar_info)); 567 avatars->Append(std::move(avatar_info));
569 } 568 }
570 return avatars; 569 return avatars;
571 } 570 }
572 571
573 } // namespace profiles 572 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_helpers.cc ('k') | chrome/browser/ui/browser_navigator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698