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

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

Issue 2126873003: Change WebBluetooth chooser title to "pair with" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@support_chrome_extension_chooser_title
Patch Set: address comment 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" 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" 13 #include "ui/base/l10n/l10n_util.h"
15 #include "url/origin.h" 14 #include "url/origin.h"
16 15
17 ChooserController::ChooserController(content::RenderFrameHost* owner) 16 ChooserController::ChooserController(content::RenderFrameHost* owner,
18 : owning_frame_(owner) {} 17 int title_string_id_origin,
18 int title_string_id_extension)
19 : owning_frame_(owner),
20 title_string_id_origin_(title_string_id_origin),
21 title_string_id_extension_(title_string_id_extension) {}
19 22
20 ChooserController::~ChooserController() {} 23 ChooserController::~ChooserController() {}
21 24
22 base::string16 ChooserController::GetTitle() const { 25 base::string16 ChooserController::GetTitle() const {
23 if (!owning_frame_) 26 if (!owning_frame_)
24 return base::string16(); 27 return base::string16();
25 28
26 url::Origin origin = owning_frame_->GetLastCommittedOrigin(); 29 url::Origin origin = owning_frame_->GetLastCommittedOrigin();
27 30
28 if (origin.scheme() == extensions::kExtensionScheme) { 31 if (origin.scheme() == extensions::kExtensionScheme) {
29 content::WebContents* web_contents = 32 content::WebContents* web_contents =
30 content::WebContents::FromRenderFrameHost(owning_frame_); 33 content::WebContents::FromRenderFrameHost(owning_frame_);
31 content::BrowserContext* browser_context = 34 content::BrowserContext* browser_context =
32 web_contents->GetBrowserContext(); 35 web_contents->GetBrowserContext();
33 extensions::ExtensionRegistry* extension_registry = 36 extensions::ExtensionRegistry* extension_registry =
34 extensions::ExtensionRegistry::Get(browser_context); 37 extensions::ExtensionRegistry::Get(browser_context);
35 if (extension_registry) { 38 if (extension_registry) {
36 const extensions::Extension* extension = 39 const extensions::Extension* extension =
37 extension_registry->enabled_extensions().GetByID(origin.host()); 40 extension_registry->enabled_extensions().GetByID(origin.host());
38 if (extension) { 41 if (extension) {
39 return l10n_util::GetStringFUTF16( 42 return l10n_util::GetStringFUTF16(title_string_id_extension_,
40 IDS_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME, 43 base::UTF8ToUTF16(extension->name()));
41 base::UTF8ToUTF16(extension->name()));
42 } 44 }
43 } 45 }
44 } 46 }
45 47
46 return l10n_util::GetStringFUTF16( 48 return l10n_util::GetStringFUTF16(
47 IDS_DEVICE_CHOOSER_PROMPT_ORIGIN, 49 title_string_id_origin_,
48 url_formatter::FormatOriginForSecurityDisplay( 50 url_formatter::FormatOriginForSecurityDisplay(
49 origin, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); 51 origin, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
50 } 52 }
OLDNEW
« no previous file with comments | « chrome/browser/chooser_controller/chooser_controller.h ('k') | chrome/browser/chooser_controller/mock_chooser_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698