| Index: components/password_manager/core/browser/password_ui_utils.cc
|
| diff --git a/components/password_manager/core/browser/password_ui_utils.cc b/components/password_manager/core/browser/password_ui_utils.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2b9d99dc1048b03a4b7c5760c026e6d8bfaaf708
|
| --- /dev/null
|
| +++ b/components/password_manager/core/browser/password_ui_utils.cc
|
| @@ -0,0 +1,38 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <components/password_manager/core/browser/password_ui_utils.h>
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/strings/string_util.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "components/url_formatter/elide_url.h"
|
| +
|
| +namespace password_manager {
|
| +
|
| +namespace {
|
| +
|
| +// The URL prefixes that are removed from shown origin.
|
| +const char* const kRemovedPrefixes[] = {"m.", "mobile.", "www."};
|
| +
|
| +} // namespace
|
| +
|
| +std::string GetShownOrigin(const GURL& url, const std::string& languages) {
|
| + std::string original = base::UTF16ToUTF8(
|
| + url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages));
|
| + base::StringPiece result = original;
|
| + for (base::StringPiece prefix : kRemovedPrefixes) {
|
| + if (base::StartsWith(result, prefix,
|
| + base::CompareCase::INSENSITIVE_ASCII)) {
|
| + result.remove_prefix(prefix.length());
|
| + break; // Remove only one prefix (e.g. www.mobile.de).
|
| + }
|
| + }
|
| +
|
| + return result.find('.') != base::StringPiece::npos ? result.as_string()
|
| + : original;
|
| +}
|
| +
|
| +} // namespace password_manager
|
|
|