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

Unified Diff: chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc

Issue 368243009: Implement unregisterProtocolHandler() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
index cd4f7919cfa42a6f1492b67be52367fd40a5c7f0..96753dbd6fce2897e432bb9c1ffcc19f2f37ba72 100644
--- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
+++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc
@@ -59,6 +59,15 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest {
registry->is_loading_ = false;
ASSERT_TRUE(registry->IsHandledProtocol(protocol));
}
+ void RemoveProtocolHandler(const std::string& protocol,
+ const GURL& url) {
+ ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol,
+ url);
+ ProtocolHandlerRegistry* registry =
+ ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile());
+ registry->RemoveHandler(handler);
+ ASSERT_FALSE(registry->IsHandledProtocol(protocol));
+ }
};
IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest,
@@ -77,6 +86,27 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest,
ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
}
+IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest,
+ UnregisterProtocolHandler) {
+ scoped_ptr<TestRenderViewContextMenu> menu(
+ CreateContextMenu(GURL("http://www.google.com/")));
+ ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
+
+ AddProtocolHandler(std::string("web+search"),
+ GURL("http://www.google.com/%s"));
+ GURL url("web+search:testing");
+ ProtocolHandlerRegistry* registry =
+ ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile());
+ ASSERT_EQ(1u, registry->GetHandlersFor(url.scheme()).size());
+ menu.reset(CreateContextMenu(url));
+ ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
+ RemoveProtocolHandler(std::string("web+search"),
+ GURL("http://www.google.com/%s"));
+ ASSERT_EQ(0u, registry->GetHandlersFor(url.scheme()).size());
+ menu.reset(CreateContextMenu(url));
+ ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH));
+}
+
IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, CustomHandler) {
ASSERT_TRUE(test_server()->Start());
GURL handler_url = test_server()->GetURL("files/custom_handler_foo.html");
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698