chooser_title_util.cc 879 B

12345678910111213141516171819202122232425
  1. // Copyright 2021 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. #include "components/permissions/chooser_title_util.h"
  5. #include "components/url_formatter/elide_url.h"
  6. #include "content/public/browser/render_frame_host.h"
  7. #include "ui/base/l10n/l10n_util.h"
  8. #include "url/origin.h"
  9. namespace permissions {
  10. std::u16string CreateChooserTitle(content::RenderFrameHost* render_frame_host,
  11. int title_string_id_origin) {
  12. if (!render_frame_host)
  13. return u"";
  14. return l10n_util::GetStringFUTF16(
  15. title_string_id_origin,
  16. url_formatter::FormatOriginForSecurityDisplay(
  17. render_frame_host->GetMainFrame()->GetLastCommittedOrigin(),
  18. url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
  19. }
  20. } // namespace permissions