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

Side by Side Diff: chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc

Issue 10139002: Preventing our default handlers for ChromeOS to show up or confuse the user (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed 4th review Created 8 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_handlers/protocol_handler_registry.h" 5 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 void ReloadProtocolHandlerRegistry() { 222 void ReloadProtocolHandlerRegistry() {
223 delegate_ = new FakeDelegate(); 223 delegate_ = new FakeDelegate();
224 registry_->Finalize(); 224 registry_->Finalize();
225 registry_ = NULL; 225 registry_ = NULL;
226 registry_ = new ProtocolHandlerRegistry(profile(), delegate()); 226 registry_ = new ProtocolHandlerRegistry(profile(), delegate());
227 registry_->Load(); 227 registry_->Load();
228 } 228 }
229 229
230 void ReloadProtocolHandlerRegistryAndInstallDefaultHandler() {
231 delegate_ = new FakeDelegate();
232 registry_->Finalize();
233 registry_ = NULL;
234 registry_ = new ProtocolHandlerRegistry(profile(), delegate());
235 registry_->AddFixedHandler(CreateProtocolHandler(
236 "test", GURL("http://test.com/%s"), "Test"));
237 registry_->Load();
238 }
239
230 virtual void SetUp() { 240 virtual void SetUp() {
231 ui_message_loop_.reset(new MessageLoopForUI()); 241 ui_message_loop_.reset(new MessageLoopForUI());
232 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, 242 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI,
233 MessageLoop::current())); 243 MessageLoop::current()));
234 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); 244 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO));
235 io_thread_->StartIOThread(); 245 io_thread_->StartIOThread();
236 246
237 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE)); 247 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE));
238 file_thread_->Start(); 248 file_thread_->Start();
239 249
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 GURL("http://other.com/%s"), "test"); 797 GURL("http://other.com/%s"), "test");
788 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), 798 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(),
789 ph1.IsSameOrigin(ph2)); 799 ph1.IsSameOrigin(ph2));
790 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(), 800 ASSERT_EQ(ph1.url().GetOrigin() == ph2.url().GetOrigin(),
791 ph2.IsSameOrigin(ph1)); 801 ph2.IsSameOrigin(ph1));
792 ASSERT_EQ(ph2.url().GetOrigin() == ph3.url().GetOrigin(), 802 ASSERT_EQ(ph2.url().GetOrigin() == ph3.url().GetOrigin(),
793 ph2.IsSameOrigin(ph3)); 803 ph2.IsSameOrigin(ph3));
794 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(), 804 ASSERT_EQ(ph3.url().GetOrigin() == ph2.url().GetOrigin(),
795 ph3.IsSameOrigin(ph2)); 805 ph3.IsSameOrigin(ph2));
796 } 806 }
807
808 TEST_F(ProtocolHandlerRegistryTest, TestInstallFixedHandler) {
809 ReloadProtocolHandlerRegistryAndInstallDefaultHandler();
810 std::vector<std::string> protocols;
811 registry()->GetRegisteredProtocols(&protocols);
812 ASSERT_EQ(static_cast<size_t>(1), protocols.size());
813 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698