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

Side by Side Diff: chrome/browser/chooser_controller/chooser_controller.cc

Issue 2122073004: Display extension name on device chooser title (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_chooser_controller_to_chrome_browser
Patch Set: removed unused variable 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 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"
8 #include "chrome/grit/generated_resources.h"
9 #include "components/url_formatter/elide_url.h"
7 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/web_contents.h"
12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/common/constants.h"
14 #include "ui/base/l10n/l10n_util.h"
8 #include "url/origin.h" 15 #include "url/origin.h"
9 16
10 ChooserController::ChooserController(content::RenderFrameHost* owner) 17 ChooserController::ChooserController(content::RenderFrameHost* owner)
11 : owning_frame_(owner) {} 18 : owning_frame_(owner) {}
12 19
13 ChooserController::~ChooserController() {} 20 ChooserController::~ChooserController() {}
14 21
15 url::Origin ChooserController::GetOrigin() const { 22 base::string16 ChooserController::GetTitle() const {
16 return owning_frame_ ? owning_frame_->GetLastCommittedOrigin() 23 if (!owning_frame_)
17 : url::Origin(); 24 return base::string16();
25
26 url::Origin origin = owning_frame_->GetLastCommittedOrigin();
27
28 if (origin.scheme() == extensions::kExtensionScheme) {
29 content::WebContents* web_contents =
30 content::WebContents::FromRenderFrameHost(owning_frame_);
31 content::BrowserContext* browser_context =
32 web_contents->GetBrowserContext();
33 extensions::ExtensionRegistry* extension_registry =
34 extensions::ExtensionRegistry::Get(browser_context);
35 if (extension_registry) {
36 const extensions::Extension* extension =
37 extension_registry->enabled_extensions().GetByID(origin.host());
38 if (extension) {
39 return l10n_util::GetStringFUTF16(
40 IDS_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME,
41 base::UTF8ToUTF16(extension->name()));
42 }
43 }
44 }
45
46 return l10n_util::GetStringFUTF16(
47 IDS_DEVICE_CHOOSER_PROMPT_ORIGIN,
48 url_formatter::FormatOriginForSecurityDisplay(
49 origin, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
18 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698