OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/ui/search/search_ipc_router.h" | 5 #include "chrome/browser/ui/search/search_ipc_router.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 9 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
10 #include "chrome/browser/ui/search/search_tab_helper.h" | 10 #include "chrome/browser/ui/search/search_tab_helper.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 106 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
107 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessHistorySyncCheck()); | 107 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessHistorySyncCheck()); |
108 } | 108 } |
109 | 109 |
110 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessHistorySyncCheck) { | 110 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessHistorySyncCheck) { |
111 // Process message only if the underlying page is an InstantNTP. | 111 // Process message only if the underlying page is an InstantNTP. |
112 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 112 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
113 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessHistorySyncCheck()); | 113 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessHistorySyncCheck()); |
114 } | 114 } |
115 | 115 |
116 TEST_F(SearchIPCRouterPolicyTest, ProcessNavigateToURL) { | |
117 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | |
118 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessNavigateToURL(true)); | |
119 } | |
120 | |
121 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessNavigateToURL) { | |
122 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | |
123 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessNavigateToURL(true)); | |
124 | |
125 NavigateAndCommitActiveTab(GURL("file://foo/bar")); | |
126 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessNavigateToURL(true)); | |
127 } | |
128 | |
129 TEST_F(SearchIPCRouterPolicyTest, ProcessPasteIntoOmniboxMsg) { | 116 TEST_F(SearchIPCRouterPolicyTest, ProcessPasteIntoOmniboxMsg) { |
130 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 117 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
131 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessPasteIntoOmnibox(true)); | 118 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessPasteIntoOmnibox(true)); |
132 } | 119 } |
133 | 120 |
134 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessPasteIntoOmniboxMsg) { | 121 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessPasteIntoOmniboxMsg) { |
135 // Process message only if the current tab is an Instant NTP. | 122 // Process message only if the current tab is an Instant NTP. |
136 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 123 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
137 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessPasteIntoOmnibox(true)); | 124 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessPasteIntoOmnibox(true)); |
138 } | 125 } |
139 | 126 |
140 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessMessagesForIncognitoPage) { | 127 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessMessagesForIncognitoPage) { |
141 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 128 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
142 SetIncognitoProfile(); | 129 SetIncognitoProfile(); |
143 | 130 |
144 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); | 131 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); |
145 EXPECT_FALSE(router_policy->ShouldProcessFocusOmnibox(true)); | 132 EXPECT_FALSE(router_policy->ShouldProcessFocusOmnibox(true)); |
146 EXPECT_FALSE(router_policy->ShouldProcessNavigateToURL(true)); | |
147 EXPECT_FALSE(router_policy->ShouldProcessDeleteMostVisitedItem()); | 133 EXPECT_FALSE(router_policy->ShouldProcessDeleteMostVisitedItem()); |
148 EXPECT_FALSE(router_policy->ShouldProcessUndoMostVisitedDeletion()); | 134 EXPECT_FALSE(router_policy->ShouldProcessUndoMostVisitedDeletion()); |
149 EXPECT_FALSE(router_policy->ShouldProcessUndoAllMostVisitedDeletions()); | 135 EXPECT_FALSE(router_policy->ShouldProcessUndoAllMostVisitedDeletions()); |
150 EXPECT_FALSE(router_policy->ShouldProcessLogEvent()); | 136 EXPECT_FALSE(router_policy->ShouldProcessLogEvent()); |
151 EXPECT_FALSE(router_policy->ShouldProcessPasteIntoOmnibox(true)); | 137 EXPECT_FALSE(router_policy->ShouldProcessPasteIntoOmnibox(true)); |
152 } | 138 } |
153 | 139 |
154 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessMessagesForInactiveTab) { | 140 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessMessagesForInactiveTab) { |
155 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 141 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
156 | 142 |
157 // Assume the NTP is deactivated. | 143 // Assume the NTP is deactivated. |
158 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); | 144 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); |
159 EXPECT_FALSE(router_policy->ShouldProcessFocusOmnibox(false)); | 145 EXPECT_FALSE(router_policy->ShouldProcessFocusOmnibox(false)); |
160 EXPECT_FALSE(router_policy->ShouldProcessNavigateToURL(false)); | |
161 EXPECT_FALSE(router_policy->ShouldProcessPasteIntoOmnibox(false)); | 146 EXPECT_FALSE(router_policy->ShouldProcessPasteIntoOmnibox(false)); |
162 EXPECT_FALSE(router_policy->ShouldSendSetInputInProgress(false)); | 147 EXPECT_FALSE(router_policy->ShouldSendSetInputInProgress(false)); |
163 } | 148 } |
164 | 149 |
165 TEST_F(SearchIPCRouterPolicyTest, SendSetDisplayInstantResults) { | 150 TEST_F(SearchIPCRouterPolicyTest, SendSetDisplayInstantResults) { |
166 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 151 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
167 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendSetDisplayInstantResults()); | 152 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendSetDisplayInstantResults()); |
168 } | 153 } |
169 | 154 |
170 TEST_F(SearchIPCRouterPolicyTest, SendSetSuggestionToPrefetch) { | 155 TEST_F(SearchIPCRouterPolicyTest, SendSetSuggestionToPrefetch) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Send theme background information only if the current tab is an | 200 // Send theme background information only if the current tab is an |
216 // Instant NTP. | 201 // Instant NTP. |
217 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 202 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
218 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); | 203 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); |
219 } | 204 } |
220 | 205 |
221 TEST_F(SearchIPCRouterPolicyTest, SubmitQuery) { | 206 TEST_F(SearchIPCRouterPolicyTest, SubmitQuery) { |
222 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 207 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
223 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSubmitQuery()); | 208 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSubmitQuery()); |
224 } | 209 } |
OLD | NEW |