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.
5 #include "chrome/renderer/searchbox/search_bouncer.h"
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"
12 SearchBouncer::SearchBouncer() {
15 SearchBouncer::~SearchBouncer() {
18 bool SearchBouncer::ShouldFork(const GURL
& url
) const {
21 for (std::vector
<GURL
>::const_iterator it
= search_urls_
.begin();
22 it
!= search_urls_
.end(); ++it
) {
23 if (search::MatchesOriginAndPath(url
, *it
)) {
27 return IsNewTabPage(url
);
30 bool SearchBouncer::IsNewTabPage(const GURL
& url
) const {
31 return url
.is_valid() && url
== new_tab_page_url_
;
34 bool SearchBouncer::OnControlMessageReceived(const IPC::Message
& message
) {
36 IPC_BEGIN_MESSAGE_MAP(SearchBouncer
, message
)
37 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetSearchURLs
, OnSetSearchURLs
)
38 IPC_MESSAGE_UNHANDLED(handled
= false)
44 void 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
;