1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/renderer/searchbox/search_bouncer.h" 6 7 #include "chrome/common/render_messages.h" 8 #include "chrome/common/search_urls.h" 9 #include "content/public/renderer/render_process_observer.h" 10 #include "ipc/ipc_message_macros.h" 11 SearchBouncer()12SearchBouncer::SearchBouncer() { 13 } 14 ~SearchBouncer()15SearchBouncer::~SearchBouncer() { 16 } 17 ShouldFork(const GURL & url) const18bool SearchBouncer::ShouldFork(const GURL& url) const { 19 if (!url.is_valid()) 20 return false; 21 for (std::vector<GURL>::const_iterator it = search_urls_.begin(); 22 it != search_urls_.end(); ++it) { 23 if (search::MatchesOriginAndPath(url, *it)) { 24 return true; 25 } 26 } 27 return IsNewTabPage(url); 28 } 29 IsNewTabPage(const GURL & url) const30bool SearchBouncer::IsNewTabPage(const GURL& url) const { 31 return url.is_valid() && url == new_tab_page_url_; 32 } 33 OnControlMessageReceived(const IPC::Message & message)34bool SearchBouncer::OnControlMessageReceived(const IPC::Message& message) { 35 bool handled = true; 36 IPC_BEGIN_MESSAGE_MAP(SearchBouncer, message) 37 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetSearchURLs, OnSetSearchURLs) 38 IPC_MESSAGE_UNHANDLED(handled = false) 39 IPC_END_MESSAGE_MAP() 40 41 return handled; 42 } 43 OnSetSearchURLs(std::vector<GURL> search_urls,GURL new_tab_page_url)44void SearchBouncer::OnSetSearchURLs( 45 std::vector<GURL> search_urls, 46 GURL new_tab_page_url) { 47 search_urls_ = search_urls; 48 new_tab_page_url_ = new_tab_page_url; 49 } 50