diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 14:36:41 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 14:36:41 +0000 |
commit | 057a9a96a6ab08df982136e2dbfbe6785b327e06 (patch) | |
tree | 12f9470cf63b8a7802031234161dc5815ce87355 /chrome/browser | |
parent | 9abfae34812add5e6bac420fcd4cc915686afe22 (diff) | |
download | chromium_src-057a9a96a6ab08df982136e2dbfbe6785b327e06.zip chromium_src-057a9a96a6ab08df982136e2dbfbe6785b327e06.tar.gz chromium_src-057a9a96a6ab08df982136e2dbfbe6785b327e06.tar.bz2 |
Enable AutocompleteTest, HistoryURLProviderTest,
HistoryContentsProviderTest, and KeywordProviderTest from
chrome/browser/autocomplete.
NOTIMPLEMENTED bits where HistoryURLProviderTest and AutocompleteTest
have UI dependencies, and ExternalProtocolHandler has OS dependencies.
Review URL: http://codereview.chromium.org/43034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11729 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 39 insertions, 24 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index d9c3143..3013638 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -14,6 +14,7 @@ #include "chrome/browser/autocomplete/search_provider.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/dom_ui/history_ui.h" +#include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profile.h" #include "chrome/common/gfx/text_elider.h" @@ -29,13 +30,6 @@ #include "net/base/registry_controlled_domain.h" #include "net/url_request/url_request.h" -// TODO(port): Port this file. -#if defined(OS_WIN) -#include "chrome/browser/external_protocol_handler.h" -#else -#include "chrome/common/temp_scaffolding_stubs.h" -#endif - using base::TimeDelta; // AutocompleteInput ---------------------------------------------------------- diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc index 53605f7..e798adf 100644 --- a/chrome/browser/autocomplete/autocomplete_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_unittest.cc @@ -16,7 +16,7 @@ namespace { -const int num_results_per_provider = 3; +const size_t num_results_per_provider = 3; // Autocomplete provider that provides known results. Note that this is // refcounted so that it can also be a task on the message loop. @@ -74,9 +74,7 @@ void TestProvider::AddResults(int start_at, int num) { AutocompleteMatch match(this, relevance_ - i, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); - wchar_t str[16]; - swprintf_s(str, L"%d", i); - match.fill_into_edit = prefix_ + str; + match.fill_into_edit = prefix_ + IntToWString(i); match.destination_url = GURL(WideToUTF8(match.fill_into_edit)); match.contents = match.fill_into_edit; @@ -170,8 +168,6 @@ void AutocompleteProviderTest::Observe(NotificationType type, } } -} // namespace - std::ostream& operator<<(std::ostream& os, const AutocompleteResult::const_iterator& iter) { return os << static_cast<const AutocompleteMatch*>(&(*iter)); @@ -232,14 +228,16 @@ TEST(AutocompleteTest, InputType) { // { L"mailto:abuse@foo.com", AutocompleteInput::URL }, { L"view-source:http://www.foo.com/", AutocompleteInput::URL }, { L"javascript:alert(\"Hey there!\");", AutocompleteInput::URL }, +#if defined(OS_WIN) { L"C:\\Program Files", AutocompleteInput::URL }, +#endif { L"\\\\Server\\Folder\\File", AutocompleteInput::URL }, { L"http://foo.com/", AutocompleteInput::URL }, { L"127.0.0.1", AutocompleteInput::URL }, { L"browser.tabs.closeButtons", AutocompleteInput::UNKNOWN }, }; - for (int i = 0; i < arraysize(input_cases); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { AutocompleteInput input(input_cases[i].input, std::wstring(), true, false, false); EXPECT_EQ(input_cases[i].type, input.type()) << "Input: " << @@ -266,10 +264,12 @@ TEST(AutocompleteMatch, MoreRelevant) { AutocompleteMatch m1(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); - for (int i = 0; i < arraysize(cases); ++i) { + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { m1.relevance = cases[i].r1; m2.relevance = cases[i].r2; EXPECT_EQ(cases[i].expected_result, AutocompleteMatch::MoreRelevant(m1, m2)); } } + +} // namespace diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc index 459230a..06270ec 100644 --- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc @@ -94,8 +94,6 @@ class HistoryContentsProviderTest : public testing::Test, scoped_refptr<HistoryContentsProvider> provider_; }; -} // namespace - TEST_F(HistoryContentsProviderTest, Body) { AutocompleteInput input(L"FOO", std::wstring(), true, false, false); RunQuery(input, false); @@ -182,3 +180,5 @@ TEST_F(HistoryContentsProviderTest, Bookmarks) { EXPECT_EQ("http://www.google.com/3", m3[0].destination_url.spec()); } } + +} // namespace diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index 6f12cc9..a178ac5 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -325,6 +325,7 @@ TEST_F(HistoryURLProviderTest, Fixup) { const std::string crash_1[] = {"http://%20/"}; RunTest(L"%20", std::wstring(), false, crash_1, arraysize(crash_1)); +#if defined(OS_WIN) // Fixing up "file:" should result in an inline autocomplete offset of just // after "file:", not just after "file://". const std::wstring input_1(L"file:"); @@ -347,4 +348,9 @@ TEST_F(HistoryURLProviderTest, Fixup) { // rather than "0.0.0.56.com". std::string fixup_3[] = {"http://www.56.com/"}; RunTest(L"56", L"com", true, fixup_3, arraysize(fixup_3)); +#elif defined(OS_POSIX) + // TODO(port): Fix this up once the dependencies have their UI bits + // extracted away. + NOTIMPLEMENTED(); +#endif } diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons index 52dada2..887acde 100644 --- a/chrome/browser/browser.scons +++ b/chrome/browser/browser.scons @@ -682,7 +682,6 @@ if not env.Bit('windows'): 'download/download_util.cc', 'drag_utils.cc', 'encoding_menu_controller_delegate.cc', - 'external_protocol_handler.cc', 'external_tab_container.cc', 'first_run.cc', 'hang_monitor/hung_plugin_action.cc', diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc index 98ab6f1..118f2fe 100644 --- a/chrome/browser/external_protocol_handler.cc +++ b/chrome/browser/external_protocol_handler.cc @@ -4,23 +4,29 @@ #include "chrome/browser/external_protocol_handler.h" +#if defined(OS_WIN) #include <windows.h> #include <shellapi.h> +#endif + #include <set> #include "base/logging.h" #include "base/message_loop.h" -#include "base/registry.h" #include "base/string_util.h" #include "base/thread.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_process_impl.h" -#include "chrome/browser/views/external_protocol_dialog.h" #include "chrome/common/pref_service.h" #include "chrome/common/pref_names.h" #include "googleurl/src/gurl.h" #include "net/base/escape.h" +#if defined(OS_WIN) +#include "base/registry.h" +#include "chrome/browser/views/external_protocol_dialog.h" +#endif + // static void ExternalProtocolHandler::PrepopulateDictionary(DictionaryValue* win_pref) { static bool is_warm = false; @@ -58,13 +64,13 @@ void ExternalProtocolHandler::PrepopulateDictionary(DictionaryValue* win_pref) { }; bool should_block; - for (int i = 0; i < arraysize(denied_schemes); ++i) { + for (size_t i = 0; i < arraysize(denied_schemes); ++i) { if (!win_pref->GetBoolean(denied_schemes[i], &should_block)) { win_pref->SetBoolean(denied_schemes[i], true); } } - for (int i = 0; i < arraysize(allowed_schemes); ++i) { + for (size_t i = 0; i < arraysize(allowed_schemes); ++i) { if (!win_pref->GetBoolean(allowed_schemes[i], &should_block)) { win_pref->SetBoolean(allowed_schemes[i], false); } @@ -105,6 +111,7 @@ ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState( void ExternalProtocolHandler::LaunchUrl(const GURL& url, int render_process_host_id, int tab_contents_id) { +#if defined(OS_WIN) // Escape the input scheme to be sure that the command does not // have parameters unexpected by the external program. std::string escaped_url_string = EscapeExternalHandlerValue(url.spec()); @@ -142,10 +149,15 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url, NewRunnableFunction( &ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck, escaped_url)); +#elif defined(OS_POSIX) + // TODO(port): Implement launching external handler. + NOTIMPLEMENTED(); +#endif } // static void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) { +#if defined(OS_WIN) // Quote the input scheme to be sure that the command does not have // parameters unexpected by the external program. This url should already // have been escaped. @@ -157,7 +169,7 @@ void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) { // "Some versions of windows (Win2k before SP3, Win XP before SP1) crash in // ShellExecute on long URLs (bug 161357 on bugzilla.mozilla.org). IE 5 and 6 // support URLS of 2083 chars in length, 2K is safe." - const int kMaxUrlLength = 2048; + const size_t kMaxUrlLength = 2048; if (escaped_url.length() > kMaxUrlLength) { NOTREACHED(); return; @@ -187,6 +199,10 @@ void ExternalProtocolHandler::LaunchUrlWithoutSecurityCheck(const GURL& url) { // bug 1136923. return; } +#elif defined(OS_POSIX) + // TODO(port): Implement launching external handler. + NOTIMPLEMENTED(); +#endif } // static diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 057343d..276693d 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -17,6 +17,7 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_request_manager.h" #include "chrome/browser/download/save_file_manager.h" +#include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/renderer_host/async_resource_handler.h" #include "chrome/browser/renderer_host/buffered_resource_handler.h" @@ -45,7 +46,6 @@ #if defined(OS_POSIX) #include "chrome/common/temp_scaffolding_stubs.h" #elif defined(OS_WIN) -#include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/login_prompt.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" |