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

Unified Diff: chrome/browser/ui/browser_unittest.cc

Issue 2975593002: [vr] Deny permission requests in VR mode
Patch Set: . Created 3 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 | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_unittest.cc
diff --git a/chrome/browser/ui/browser_unittest.cc b/chrome/browser/ui/browser_unittest.cc
index 9e99d6882c5f533cbde1ac819092094f86640355..cdc30186c4ada8ac9c0255f78c1b3d906bc09322 100644
--- a/chrome/browser/ui/browser_unittest.cc
+++ b/chrome/browser/ui/browser_unittest.cc
@@ -6,15 +6,19 @@
#include "base/macros.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
+#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/zoom/zoom_controller.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
+#include "device/vr/features/features.h"
#include "third_party/skia/include/core/SkColor.h"
using content::SiteInstance;
@@ -149,6 +153,36 @@ TEST_F(BrowserUnitTest, DisableZoomOnCrashedTab) {
EXPECT_FALSE(chrome::CanZoomOut(contents));
}
+TEST_F(BrowserUnitTest, RegisterProtocolHandlerInVR) {
+ TabStripModel* tab_strip_model = browser()->tab_strip_model();
+
+ WebContents* contents = CreateTestWebContents();
+ vr::VrTabHelper::CreateForWebContents(contents);
+ tab_strip_model->AppendWebContents(contents, true);
+ WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank"));
+
+ ProtocolHandlerRegistry* registry =
+ ProtocolHandlerRegistryFactory::GetForBrowserContext(
+ contents->GetBrowserContext());
+
+ std::string protocol("mailto");
+ GURL gurl("http://www.toplevel.example/");
+ size_t num_handlers = registry->GetHandlersFor(protocol).size();
+
+ vr::VrTabHelper* vr_tab_helper = vr::VrTabHelper::FromWebContents(contents);
+ vr_tab_helper->SetIsInVr(true);
+
+ content::WebContentsDelegate* delegate =
+ static_cast<content::WebContentsDelegate*>(browser());
+ delegate->RegisterProtocolHandler(contents, protocol, gurl, false);
+ EXPECT_EQ(num_handlers, registry->GetHandlersFor(protocol).size());
+
+ vr_tab_helper->SetIsInVr(false);
+
+ delegate->RegisterProtocolHandler(contents, protocol, gurl, false);
+ EXPECT_EQ(num_handlers + 1, registry->GetHandlersFor(protocol).size());
+}
+
class BrowserBookmarkBarTest : public BrowserWithTestWindowTest {
public:
BrowserBookmarkBarTest() {}
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698