From c125e533bf1242460089f62ac305a99e1f95f7a0 Mon Sep 17 00:00:00 2001 From: "meacer@chromium.org" Date: Sat, 10 May 2014 20:39:06 +0000 Subject: [PATCH] Ignore title parameter for navigator.registerProtocolHandler BUG=347720 Review URL: https://codereview.chromium.org/267103002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269630 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 18 +---- .../custom_handlers/protocol_handler_registry.cc | 6 +- .../protocol_handler_registry_browsertest.cc | 13 ++-- .../protocol_handler_registry_unittest.cc | 85 ++++++++++------------ .../register_protocol_handler_infobar_delegate.cc | 16 ++-- ...register_protocol_handler_permission_request.cc | 19 +++-- chrome/browser/prerender/prerender_contents.cc | 1 - .../render_view_context_menu.cc | 2 +- .../resources/options/handler_options_list.js | 16 ++-- chrome/browser/ui/browser.cc | 3 +- chrome/browser/ui/browser.h | 1 - .../content_setting_bubble_model.cc | 9 +-- .../content_setting_bubble_model_unittest.cc | 9 +-- .../content_setting_image_model_unittest.cc | 3 +- .../ui/webui/options/handler_options_handler.cc | 9 +-- chrome/common/custom_handlers/protocol_handler.cc | 27 +++---- chrome/common/custom_handlers/protocol_handler.h | 10 +-- content/browser/web_contents/web_contents_impl.cc | 2 +- content/public/browser/web_contents_delegate.h | 1 - 19 files changed, 103 insertions(+), 147 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 5ae2ccfb3bb2..cc61601be702 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -12175,20 +12175,10 @@ Some features may be unavailable. Please check that the profile exists and you https:////mail.google.com//mail//?extsrc=mailto&url=%s - - - Google.com Mail - - https:////www.google.com//calendar//render?cid=%s - - - - Google Calendar - @@ -13114,10 +13104,10 @@ Some features may be unavailable. Please check that the profile exists and you web calendar - Allow $1Google Search ($2google.com) to open all $3search links? + Allow $1google.com to open all $2search links? - Allow $1Google Search ($2google.com) to open all $3search links instead of $4Elgoog Search? + Allow $1google.com to open all $2search links instead of $3Elgoog Search? $3search links @@ -13126,10 +13116,10 @@ Some features may be unavailable. Please check that the profile exists and you $3search links instead of $4Elgoog Search - Use $1Google Search + Allow - No + Deny Ignore diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc index 333f3e53fdf9..3ceffb0e21e3 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc @@ -418,13 +418,11 @@ void ProtocolHandlerRegistry::InstallDefaultsForChromeOS() { AddPredefinedHandler( ProtocolHandler::CreateProtocolHandler( "mailto", - GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)), - l10n_util::GetStringUTF16(IDS_GOOGLE_MAILTO_HANDLER_NAME))); + GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_MAILTO_HANDLER_URL)))); AddPredefinedHandler( ProtocolHandler::CreateProtocolHandler( "webcal", - GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)), - l10n_util::GetStringUTF16(IDS_GOOGLE_WEBCAL_HANDLER_NAME))); + GURL(l10n_util::GetStringUTF8(IDS_GOOGLE_WEBCAL_HANDLER_URL)))); #else NOTREACHED(); // this method should only ever be called in chromeos. #endif diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc index ff797a7817b3..cd4f7919cfa4 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc @@ -46,10 +46,9 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest { } void AddProtocolHandler(const std::string& protocol, - const GURL& url, - const base::string16& title) { - ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler( - protocol, url, title); + const GURL& url) { + ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, + url); ProtocolHandlerRegistry* registry = ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); // Fake that this registration is happening on profile startup. Otherwise @@ -69,8 +68,7 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH)); AddProtocolHandler(std::string("web+search"), - GURL("http://www.google.com/%s"), - base::UTF8ToUTF16(std::string("Test handler"))); + GURL("http://www.google.com/%s")); GURL url("web+search:testing"); ProtocolHandlerRegistry* registry = ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); @@ -82,8 +80,7 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, CustomHandler) { ASSERT_TRUE(test_server()->Start()); GURL handler_url = test_server()->GetURL("files/custom_handler_foo.html"); - AddProtocolHandler("foo", handler_url, - base::UTF8ToUTF16(std::string("Test foo Handler"))); + AddProtocolHandler("foo", handler_url); ui_test_utils::NavigateToURL(browser(), GURL("foo:test")); diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc index a3783da9cd84..16d8fc79832a 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc @@ -320,16 +320,13 @@ class ProtocolHandlerRegistryTest : public testing::Test { } ProtocolHandler CreateProtocolHandler(const std::string& protocol, - const GURL& url, - const std::string& title) { - return ProtocolHandler::CreateProtocolHandler(protocol, url, - base::UTF8ToUTF16(title)); + const GURL& url) { + return ProtocolHandler::CreateProtocolHandler(protocol, url); } ProtocolHandler CreateProtocolHandler(const std::string& protocol, - const std::string& name) { - return CreateProtocolHandler(protocol, GURL("http://" + name + "/%s"), - name); + const std::string& name) { + return CreateProtocolHandler(protocol, GURL("http://" + name + "/%s")); } void RecreateRegistry(bool initialize) { @@ -356,7 +353,7 @@ class ProtocolHandlerRegistryTest : public testing::Test { CHECK(profile_->GetPrefs()); SetUpRegistry(true); test_protocol_handler_ = - CreateProtocolHandler("test", GURL("http://test.com/%s"), "Test"); + CreateProtocolHandler("test", GURL("http://test.com/%s")); } virtual void TearDown() { @@ -448,10 +445,8 @@ TEST_F(ProtocolHandlerRegistryTest, IgnoreProtocolHandler) { } TEST_F(ProtocolHandlerRegistryTest, IgnoreEquivalentProtocolHandler) { - ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test2"); + ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s")); + ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s")); registry()->OnIgnoreRegisterProtocolHandler(ph1); ASSERT_TRUE(registry()->IsIgnored(ph1)); @@ -588,10 +583,8 @@ TEST_F(ProtocolHandlerRegistryTest, TestIsRegistered) { } TEST_F(ProtocolHandlerRegistryTest, TestIsEquivalentRegistered) { - ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test2"); + ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s")); + ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s")); registry()->OnAcceptRegisterProtocolHandler(ph1); ASSERT_TRUE(registry()->IsRegistered(ph1)); @@ -599,14 +592,10 @@ TEST_F(ProtocolHandlerRegistryTest, TestIsEquivalentRegistered) { } TEST_F(ProtocolHandlerRegistryTest, TestSilentlyRegisterHandler) { - ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/%s"), - "test2"); - ProtocolHandler ph3 = CreateProtocolHandler("ignore", GURL("http://test/%s"), - "ignore1"); - ProtocolHandler ph4 = CreateProtocolHandler("ignore", GURL("http://test/%s"), - "ignore2"); + ProtocolHandler ph1 = CreateProtocolHandler("test", GURL("http://test/1/%s")); + ProtocolHandler ph2 = CreateProtocolHandler("test", GURL("http://test/2/%s")); + ProtocolHandler ph3 = CreateProtocolHandler("ignore", GURL("http://test/%s")); + ProtocolHandler ph4 = CreateProtocolHandler("ignore", GURL("http://test/%s")); ASSERT_FALSE(registry()->SilentlyHandleRegisterHandlerRequest(ph1)); ASSERT_FALSE(registry()->IsRegistered(ph1)); @@ -859,10 +848,10 @@ TEST_F(ProtocolHandlerRegistryTest, TestLoadEnabledGetsPropogatedToIO) { } TEST_F(ProtocolHandlerRegistryTest, TestReplaceHandler) { - ProtocolHandler ph1 = CreateProtocolHandler("mailto", - GURL("http://test.com/%s"), "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("mailto", - GURL("http://test.com/updated-url/%s"), "test2"); + ProtocolHandler ph1 = + CreateProtocolHandler("mailto", GURL("http://test.com/%s")); + ProtocolHandler ph2 = + CreateProtocolHandler("mailto", GURL("http://test.com/updated-url/%s")); registry()->OnAcceptRegisterProtocolHandler(ph1); ASSERT_TRUE(registry()->AttemptReplace(ph2)); const ProtocolHandler& handler(registry()->GetHandlerFor("mailto")); @@ -870,12 +859,12 @@ TEST_F(ProtocolHandlerRegistryTest, TestReplaceHandler) { } TEST_F(ProtocolHandlerRegistryTest, TestReplaceNonDefaultHandler) { - ProtocolHandler ph1 = CreateProtocolHandler("mailto", - GURL("http://test.com/%s"), "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("mailto", - GURL("http://test.com/updated-url/%s"), "test2"); - ProtocolHandler ph3 = CreateProtocolHandler("mailto", - GURL("http://else.com/%s"), "test3"); + ProtocolHandler ph1 = + CreateProtocolHandler("mailto", GURL("http://test.com/%s")); + ProtocolHandler ph2 = + CreateProtocolHandler("mailto", GURL("http://test.com/updated-url/%s")); + ProtocolHandler ph3 = + CreateProtocolHandler("mailto", GURL("http://else.com/%s")); registry()->OnAcceptRegisterProtocolHandler(ph1); registry()->OnAcceptRegisterProtocolHandler(ph3); ASSERT_TRUE(registry()->AttemptReplace(ph2)); @@ -884,12 +873,12 @@ TEST_F(ProtocolHandlerRegistryTest, TestReplaceNonDefaultHandler) { } TEST_F(ProtocolHandlerRegistryTest, TestReplaceRemovesStaleHandlers) { - ProtocolHandler ph1 = CreateProtocolHandler("mailto", - GURL("http://test.com/%s"), "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("mailto", - GURL("http://test.com/updated-url/%s"), "test2"); - ProtocolHandler ph3 = CreateProtocolHandler("mailto", - GURL("http://test.com/third/%s"), "test"); + ProtocolHandler ph1 = + CreateProtocolHandler("mailto", GURL("http://test.com/%s")); + ProtocolHandler ph2 = + CreateProtocolHandler("mailto", GURL("http://test.com/updated-url/%s")); + ProtocolHandler ph3 = + CreateProtocolHandler("mailto", GURL("http://test.com/third/%s")); registry()->OnAcceptRegisterProtocolHandler(ph1); registry()->OnAcceptRegisterProtocolHandler(ph2); @@ -902,12 +891,12 @@ TEST_F(ProtocolHandlerRegistryTest, TestReplaceRemovesStaleHandlers) { } TEST_F(ProtocolHandlerRegistryTest, TestIsSameOrigin) { - ProtocolHandler ph1 = CreateProtocolHandler("mailto", - GURL("http://test.com/%s"), "test1"); - ProtocolHandler ph2 = CreateProtocolHandler("mailto", - GURL("http://test.com/updated-url/%s"), "test2"); - ProtocolHandler ph3 = CreateProtocolHandler("mailto", - GURL("http://other.com/%s"), "test"); + ProtocolHandler ph1 = + CreateProtocolHandler("mailto", GURL("http://test.com/%s")); + ProtocolHandler ph2 = + CreateProtocolHandler("mailto", GURL("http://test.com/updated-url/%s")); + ProtocolHandler ph3 = + CreateProtocolHandler("mailto", GURL("http://other.com/%s")); ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), ph1.IsSameOrigin(ph2)); ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), @@ -920,8 +909,8 @@ TEST_F(ProtocolHandlerRegistryTest, TestIsSameOrigin) { TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestInstallDefaultHandler) { RecreateRegistry(false); - registry()->AddPredefinedHandler(CreateProtocolHandler( - "test", GURL("http://test.com/%s"), "Test")); + registry()->AddPredefinedHandler( + CreateProtocolHandler("test", GURL("http://test.com/%s"))); registry()->InitProtocolSettings(); std::vector protocols; registry()->GetRegisteredProtocols(&protocols); diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc index d37f9aee20d3..669a78316643 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc @@ -72,19 +72,21 @@ RegisterProtocolHandlerInfoBarDelegate* base::string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); return old_handler.IsEmpty() ? - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, - handler_.title(), base::UTF8ToUTF16(handler_.url().host()), + l10n_util::GetStringFUTF16( + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, + base::UTF8ToUTF16(handler_.url().host()), GetProtocolName(handler_)) : - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, - handler_.title(), base::UTF8ToUTF16(handler_.url().host()), - GetProtocolName(handler_), old_handler.title()); + l10n_util::GetStringFUTF16( + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, + base::UTF8ToUTF16(handler_.url().host()), + GetProtocolName(handler_), + base::UTF8ToUTF16(old_handler.url().host())); } base::string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel( InfoBarButton button) const { return (button == BUTTON_OK) ? - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, - handler_.title()) : + l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT) : l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); } diff --git a/chrome/browser/custom_handlers/register_protocol_handler_permission_request.cc b/chrome/browser/custom_handlers/register_protocol_handler_permission_request.cc index 11c206ffccbc..e12b0a2a0158 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_permission_request.cc +++ b/chrome/browser/custom_handlers/register_protocol_handler_permission_request.cc @@ -46,23 +46,28 @@ base::string16 RegisterProtocolHandlerPermissionRequest::GetMessageText() const { ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); return old_handler.IsEmpty() ? - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, - handler_.title(), base::UTF8ToUTF16(handler_.url().host()), + l10n_util::GetStringFUTF16( + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, + base::UTF8ToUTF16(handler_.url().host()), GetProtocolName(handler_)) : - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, - handler_.title(), base::UTF8ToUTF16(handler_.url().host()), - GetProtocolName(handler_), old_handler.title()); + l10n_util::GetStringFUTF16( + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, + base::UTF8ToUTF16(handler_.url().host()), + GetProtocolName(handler_), + base::UTF8ToUTF16(old_handler.url().host())); } base::string16 RegisterProtocolHandlerPermissionRequest::GetMessageTextFragment() const { ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); return old_handler.IsEmpty() ? - l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, + l10n_util::GetStringFUTF16( + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_FRAGMENT, GetProtocolName(handler_)) : l10n_util::GetStringFUTF16( IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE_FRAGMENT, - GetProtocolName(handler_), old_handler.title()); + GetProtocolName(handler_), + base::UTF8ToUTF16(old_handler.url().host())); } bool RegisterProtocolHandlerPermissionRequest::HasUserGesture() const { diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 25b6c0e3379e..35f45a4de882 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -178,7 +178,6 @@ class PrerenderContents::WebContentsDelegateImpl virtual void RegisterProtocolHandler(WebContents* web_contents, const std::string& protocol, const GURL& url, - const base::string16& title, bool user_gesture) OVERRIDE { // TODO(mmenke): Consider supporting this if it is a common case during // prerenders. diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc index 2669074312a9..8cb1649fbf27 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc @@ -1064,7 +1064,7 @@ void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { for (size_t i = 0; i < handlers.size() && i <= max; i++) { protocol_handler_submenu_model_.AddItem( IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i, - handlers[i].title()); + base::UTF8ToUTF16(handlers[i].url().host())); } protocol_handler_submenu_model_.AddSeparator(ui::NORMAL_SEPARATOR); protocol_handler_submenu_model_.AddItem( diff --git a/chrome/browser/resources/options/handler_options_list.js b/chrome/browser/resources/options/handler_options_list.js index fef1740de8bc..12129a89a255 100644 --- a/chrome/browser/resources/options/handler_options_list.js +++ b/chrome/browser/resources/options/handler_options_list.js @@ -13,7 +13,7 @@ cr.define('options', function() { * Creates a new ignored protocol / content handler list item. * * Accepts values in the form - * ['mailto', 'http://www.thesite.com/%s', 'The title of the protocol'], + * ['mailto', 'http://www.thesite.com/%s', 'www.thesite.com'], * @param {Object} entry A dictionary describing the handlers for a given * protocol. * @constructor @@ -40,12 +40,12 @@ cr.define('options', function() { protocolElement.className = 'handlers-type-column'; this.contentElement_.appendChild(protocolElement); - // Site title. - var titleElement = document.createElement('div'); - titleElement.textContent = this.dataItem[2]; - titleElement.className = 'handlers-site-column'; - titleElement.title = this.dataItem[1]; - this.contentElement_.appendChild(titleElement); + // Host name. + var hostElement = document.createElement('div'); + hostElement.textContent = this.dataItem[2]; + hostElement.className = 'handlers-site-column'; + hostElement.title = this.dataItem[1]; + this.contentElement_.appendChild(hostElement); }, }; @@ -90,7 +90,7 @@ cr.define('options', function() { * Accepts values in the form * { protocol: 'mailto', * handlers: [ - * ['mailto', 'http://www.thesite.com/%s', 'The title of the protocol'], + * ['mailto', 'http://www.thesite.com/%s', 'www.thesite.com'], * ..., * ], * } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 141171682af4..a06b09978ba0 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1617,7 +1617,6 @@ bool Browser::IsFullscreenForTabOrPending( void Browser::RegisterProtocolHandler(WebContents* web_contents, const std::string& protocol, const GURL& url, - const base::string16& title, bool user_gesture) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); @@ -1625,7 +1624,7 @@ void Browser::RegisterProtocolHandler(WebContents* web_contents, return; ProtocolHandler handler = - ProtocolHandler::CreateProtocolHandler(protocol, url, title); + ProtocolHandler::CreateProtocolHandler(protocol, url); ProtocolHandlerRegistry* registry = ProtocolHandlerRegistryFactory::GetForProfile(profile); diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 7172f5cb8250..beb3dddd95fe 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -616,7 +616,6 @@ class Browser : public TabStripModelObserver, virtual void RegisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, - const base::string16& title, bool user_gesture) OVERRIDE; virtual void UpdatePreferredSize(content::WebContents* source, const gfx::Size& pref_size) OVERRIDE; diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 9806d92861a3..2acc49698b1c 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -1031,23 +1031,22 @@ ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( protocol = base::UTF8ToUTF16(pending_handler_.protocol()); } + // Note that we ignore the |title| parameter. if (previous_handler_.IsEmpty()) { set_title(l10n_util::GetStringFUTF8( IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, - pending_handler_.title(), base::UTF8ToUTF16(pending_handler_.url().host()), protocol)); } else { set_title(l10n_util::GetStringFUTF8( IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, - pending_handler_.title(), base::UTF8ToUTF16(pending_handler_.url().host()), - protocol, previous_handler_.title())); + protocol, + base::UTF8ToUTF16(previous_handler_.url().host()))); } std::string radio_allow_label = - l10n_util::GetStringFUTF8(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, - pending_handler_.title()); + l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT); std::string radio_deny_label = l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_DENY); std::string radio_ignore_label = diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc index f6fe5f40d071..22fb50347929 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc @@ -559,8 +559,8 @@ TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(web_contents()); content_settings->set_pending_protocol_handler( - ProtocolHandler::CreateProtocolHandler("mailto", - GURL("http://www.toplevel.example/"), base::ASCIIToUTF16("Handler"))); + ProtocolHandler::CreateProtocolHandler( + "mailto", GURL("http://www.toplevel.example/"))); ContentSettingRPHBubbleModel content_setting_bubble_model( NULL, web_contents(), profile(), NULL, @@ -613,8 +613,7 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) { TabSpecificContentSettings* content_settings = TabSpecificContentSettings::FromWebContents(web_contents()); ProtocolHandler test_handler = ProtocolHandler::CreateProtocolHandler( - "mailto", GURL("http://www.toplevel.example/"), - base::ASCIIToUTF16("Handler")); + "mailto", GURL("http://www.toplevel.example/")); content_settings->set_pending_protocol_handler(test_handler); ContentSettingRPHBubbleModel content_setting_bubble_model( @@ -633,7 +632,6 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) { { ProtocolHandler handler = registry.GetHandlerFor("mailto"); ASSERT_FALSE(handler.IsEmpty()); - EXPECT_EQ(base::ASCIIToUTF16("Handler"), handler.title()); EXPECT_EQ(CONTENT_SETTING_ALLOW, content_settings->pending_protocol_handler_setting()); } @@ -662,7 +660,6 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) { { ProtocolHandler handler = registry.GetHandlerFor("mailto"); ASSERT_FALSE(handler.IsEmpty()); - EXPECT_EQ(base::ASCIIToUTF16("Handler"), handler.title()); EXPECT_EQ(CONTENT_SETTING_ALLOW, content_settings->pending_protocol_handler_setting()); EXPECT_FALSE(registry.IsIgnored(test_handler)); diff --git a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc index 3cf2aeb9ec23..6c75a57f9ddb 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc @@ -86,8 +86,7 @@ TEST_F(ContentSettingImageModelTest, RPHUpdateFromWebContents) { TabSpecificContentSettings::FromWebContents(web_contents()); content_settings->set_pending_protocol_handler( ProtocolHandler::CreateProtocolHandler( - "mailto", GURL("http://www.google.com/"), - base::ASCIIToUTF16("Handler"))); + "mailto", GURL("http://www.google.com/"))); content_setting_image_model->UpdateFromWebContents(web_contents()); EXPECT_TRUE(content_setting_image_model->is_visible()); } diff --git a/chrome/browser/ui/webui/options/handler_options_handler.cc b/chrome/browser/ui/webui/options/handler_options_handler.cc index 4c8dfc7c6dba..456f4694e2bb 100644 --- a/chrome/browser/ui/webui/options/handler_options_handler.cc +++ b/chrome/browser/ui/webui/options/handler_options_handler.cc @@ -99,7 +99,7 @@ static void GetHandlersAsListValue( base::ListValue* handlerValue = new base::ListValue(); handlerValue->Append(new base::StringValue(handler->protocol())); handlerValue->Append(new base::StringValue(handler->url().spec())); - handlerValue->Append(new base::StringValue(handler->title())); + handlerValue->Append(new base::StringValue(handler->url().host())); handler_list->Append(handlerValue); } } @@ -199,14 +199,11 @@ ProtocolHandler HandlerOptionsHandler::ParseHandlerFromArgs( const base::ListValue* args) const { base::string16 protocol; base::string16 url; - base::string16 title; - bool ok = args->GetString(0, &protocol) && args->GetString(1, &url) && - args->GetString(2, &title); + bool ok = args->GetString(0, &protocol) && args->GetString(1, &url); if (!ok) return ProtocolHandler::EmptyProtocolHandler(); return ProtocolHandler::CreateProtocolHandler(base::UTF16ToUTF8(protocol), - GURL(base::UTF16ToUTF8(url)), - title); + GURL(base::UTF16ToUTF8(url))); } void HandlerOptionsHandler::Observe( diff --git a/chrome/common/custom_handlers/protocol_handler.cc b/chrome/common/custom_handlers/protocol_handler.cc index 714feb117fcf..9b0278889e95 100644 --- a/chrome/common/custom_handlers/protocol_handler.cc +++ b/chrome/common/custom_handlers/protocol_handler.cc @@ -10,27 +10,24 @@ ProtocolHandler::ProtocolHandler(const std::string& protocol, - const GURL& url, - const base::string16& title) + const GURL& url) : protocol_(protocol), - url_(url), - title_(title) { + url_(url) { } ProtocolHandler ProtocolHandler::CreateProtocolHandler( const std::string& protocol, - const GURL& url, - const base::string16& title) { + const GURL& url) { std::string lower_protocol = StringToLowerASCII(protocol); - return ProtocolHandler(lower_protocol, url, title); + return ProtocolHandler(lower_protocol, url); } ProtocolHandler::ProtocolHandler() { } bool ProtocolHandler::IsValidDict(const base::DictionaryValue* value) { - return value->HasKey("protocol") && value->HasKey("url") && - value->HasKey("title"); + // Note that "title" parameter is ignored. + return value->HasKey("protocol") && value->HasKey("url"); } bool ProtocolHandler::IsSameOrigin( @@ -49,11 +46,9 @@ ProtocolHandler ProtocolHandler::CreateProtocolHandler( return EmptyProtocolHandler(); } std::string protocol, url; - base::string16 title; value->GetString("protocol", &protocol); value->GetString("url", &url); - value->GetString("title", &title); - return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url), title); + return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url)); } GURL ProtocolHandler::TranslateUrl(const GURL& url) const { @@ -67,7 +62,6 @@ base::DictionaryValue* ProtocolHandler::Encode() const { base::DictionaryValue* d = new base::DictionaryValue(); d->Set("protocol", new base::StringValue(protocol_)); d->Set("url", new base::StringValue(url_.spec())); - d->Set("title", new base::StringValue(title_)); return d; } @@ -75,15 +69,12 @@ base::DictionaryValue* ProtocolHandler::Encode() const { std::string ProtocolHandler::ToString() const { return "{ protocol=" + protocol_ + ", url=" + url_.spec() + - ", title=" + base::UTF16ToASCII(title_) + " }"; } #endif bool ProtocolHandler::operator==(const ProtocolHandler& other) const { - return protocol_ == other.protocol_ && - url_ == other.url_ && - title_ == other.title_; + return protocol_ == other.protocol_ && url_ == other.url_; } bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const { @@ -91,5 +82,5 @@ bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const { } bool ProtocolHandler::operator<(const ProtocolHandler& other) const { - return title_ < other.title_; + return url_ < other.url_; } diff --git a/chrome/common/custom_handlers/protocol_handler.h b/chrome/common/custom_handlers/protocol_handler.h index dc18be53e859..745a3f52d5a6 100644 --- a/chrome/common/custom_handlers/protocol_handler.h +++ b/chrome/common/custom_handlers/protocol_handler.h @@ -10,14 +10,13 @@ #include "base/values.h" #include "url/gurl.h" -// A single tuple of (protocol, url, title) that indicates how URLs of the +// A single tuple of (protocol, url) that indicates how URLs of the // given protocol should be rewritten to be handled. class ProtocolHandler { public: static ProtocolHandler CreateProtocolHandler(const std::string& protocol, - const GURL& url, - const base::string16& title); + const GURL& url); // Creates a ProtocolHandler with fields from the dictionary. Returns an // empty ProtocolHandler if the input is invalid. @@ -48,7 +47,6 @@ class ProtocolHandler { const std::string& protocol() const { return protocol_; } const GURL& url() const { return url_;} - const base::string16& title() const { return title_; } bool IsEmpty() const { return protocol_.empty(); @@ -65,13 +63,11 @@ class ProtocolHandler { private: ProtocolHandler(const std::string& protocol, - const GURL& url, - const base::string16& title); + const GURL& url); ProtocolHandler(); std::string protocol_; GURL url_; - base::string16 title_; }; #endif // CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 19fadd63ba4d..7d23e8d04d30 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -2657,7 +2657,7 @@ void WebContentsImpl::OnRegisterProtocolHandler(const std::string& protocol, if (policy->IsPseudoScheme(protocol)) return; - delegate_->RegisterProtocolHandler(this, protocol, url, title, user_gesture); + delegate_->RegisterProtocolHandler(this, protocol, url, user_gesture); } void WebContentsImpl::OnFindReply(int request_id, diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 0edb3bdcd93d..0193b06af211 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -377,7 +377,6 @@ class CONTENT_EXPORT WebContentsDelegate { virtual void RegisterProtocolHandler(WebContents* web_contents, const std::string& protocol, const GURL& url, - const base::string16& title, bool user_gesture) {} // Result of string search in the page. This includes the number of matches -- 2.11.4.GIT