| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chooser_controller/chooser_controller.h" | 5 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/grit/generated_resources.h" | |
| 9 #include "components/url_formatter/elide_url.h" | 8 #include "components/url_formatter/elide_url.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 #include "extensions/browser/extension_registry.h" | 11 #include "extensions/browser/extension_registry.h" |
| 13 #include "extensions/common/constants.h" | 12 #include "extensions/common/constants.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | |
| 15 #include "url/origin.h" | 13 #include "url/origin.h" |
| 16 | 14 |
| 17 ChooserController::ChooserController(content::RenderFrameHost* owner) | 15 ChooserController::ChooserController(content::RenderFrameHost* owner) |
| 18 : owning_frame_(owner) {} | 16 : owning_frame_(owner) {} |
| 19 | 17 |
| 20 ChooserController::~ChooserController() {} | 18 ChooserController::~ChooserController() {} |
| 21 | 19 |
| 22 base::string16 ChooserController::GetTitle() const { | 20 std::pair<base::string16, bool> ChooserController::GetTitlePrefix() const { |
| 23 if (!owning_frame_) | 21 if (!owning_frame_) |
| 24 return base::string16(); | 22 return std::make_pair(base::string16(), false /* otherwise */); |
| 25 | 23 |
| 26 url::Origin origin = owning_frame_->GetLastCommittedOrigin(); | 24 url::Origin origin = owning_frame_->GetLastCommittedOrigin(); |
| 27 | 25 |
| 28 if (origin.scheme() == extensions::kExtensionScheme) { | 26 if (origin.scheme() == extensions::kExtensionScheme) { |
| 29 content::WebContents* web_contents = | 27 content::WebContents* web_contents = |
| 30 content::WebContents::FromRenderFrameHost(owning_frame_); | 28 content::WebContents::FromRenderFrameHost(owning_frame_); |
| 31 content::BrowserContext* browser_context = | 29 content::BrowserContext* browser_context = |
| 32 web_contents->GetBrowserContext(); | 30 web_contents->GetBrowserContext(); |
| 33 extensions::ExtensionRegistry* extension_registry = | 31 extensions::ExtensionRegistry* extension_registry = |
| 34 extensions::ExtensionRegistry::Get(browser_context); | 32 extensions::ExtensionRegistry::Get(browser_context); |
| 35 if (extension_registry) { | 33 if (extension_registry) { |
| 36 const extensions::Extension* extension = | 34 const extensions::Extension* extension = |
| 37 extension_registry->enabled_extensions().GetByID(origin.host()); | 35 extension_registry->enabled_extensions().GetByID(origin.host()); |
| 38 if (extension) { | 36 if (extension) |
| 39 return l10n_util::GetStringFUTF16( | 37 return std::make_pair(base::UTF8ToUTF16(extension->name()), |
| 40 IDS_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME, | 38 false /* otherwise */); |
| 41 base::UTF8ToUTF16(extension->name())); | |
| 42 } | |
| 43 } | 39 } |
| 44 } | 40 } |
| 45 | 41 |
| 46 return l10n_util::GetStringFUTF16( | 42 return std::make_pair( |
| 47 IDS_DEVICE_CHOOSER_PROMPT_ORIGIN, | |
| 48 url_formatter::FormatOriginForSecurityDisplay( | 43 url_formatter::FormatOriginForSecurityDisplay( |
| 49 origin, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | 44 origin, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC), |
| 45 true /* URL origin */); |
| 50 } | 46 } |
| OLD | NEW |