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/instant_page.h" | 5 #include "chrome/browser/ui/search/instant_page.h" |
6 | 6 |
7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/ui/search/instant_ipc_sender.h" |
| 11 #include "chrome/browser/ui/search/instant_ntp.h" |
10 #include "chrome/browser/ui/search/search_model.h" | 12 #include "chrome/browser/ui/search/search_model.h" |
11 #include "chrome/browser/ui/search/search_tab_helper.h" | 13 #include "chrome/browser/ui/search/search_tab_helper.h" |
12 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
13 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
16 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
19 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return false; | 124 return false; |
123 | 125 |
124 bool handled = true; | 126 bool handled = true; |
125 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 127 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
126 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 128 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
127 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, | 129 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, |
128 OnShowInstantOverlay) | 130 OnShowInstantOverlay) |
129 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 131 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
130 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 132 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
131 OnSearchBoxNavigate); | 133 OnSearchBoxNavigate); |
| 134 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); |
132 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 135 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
133 OnDeleteMostVisitedItem); | 136 OnDeleteMostVisitedItem); |
134 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 137 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
135 OnUndoMostVisitedDeletion); | 138 OnUndoMostVisitedDeletion); |
136 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 139 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
137 OnUndoAllMostVisitedDeletions); | 140 OnUndoAllMostVisitedDeletions); |
138 IPC_MESSAGE_UNHANDLED(handled = false) | 141 IPC_MESSAGE_UNHANDLED(handled = false) |
139 IPC_END_MESSAGE_MAP() | 142 IPC_END_MESSAGE_MAP() |
140 return handled; | 143 return handled; |
141 } | 144 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return; | 235 return; |
233 | 236 |
234 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 237 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
235 if (!ShouldProcessNavigateToURL()) | 238 if (!ShouldProcessNavigateToURL()) |
236 return; | 239 return; |
237 | 240 |
238 delegate_->NavigateToURL( | 241 delegate_->NavigateToURL( |
239 contents(), url, transition, disposition, is_search_type); | 242 contents(), url, transition, disposition, is_search_type); |
240 } | 243 } |
241 | 244 |
| 245 void InstantPage::OnCountMouseover(int page_id) { |
| 246 if (!contents()->IsActiveEntry(page_id)) |
| 247 return; |
| 248 |
| 249 InstantNTP::CountMouseover(contents()); |
| 250 } |
| 251 |
242 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { | 252 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { |
243 if (!contents()->IsActiveEntry(page_id)) | 253 if (!contents()->IsActiveEntry(page_id)) |
244 return; | 254 return; |
245 | 255 |
246 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 256 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
247 if (!ShouldProcessDeleteMostVisitedItem()) | 257 if (!ShouldProcessDeleteMostVisitedItem()) |
248 return; | 258 return; |
249 | 259 |
250 delegate_->DeleteMostVisitedItem(url); | 260 delegate_->DeleteMostVisitedItem(url); |
251 } | 261 } |
(...skipping 20 matching lines...) Expand all Loading... |
272 delegate_->UndoAllMostVisitedDeletions(); | 282 delegate_->UndoAllMostVisitedDeletions(); |
273 } | 283 } |
274 | 284 |
275 void InstantPage::ClearContents() { | 285 void InstantPage::ClearContents() { |
276 if (contents()) | 286 if (contents()) |
277 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); | 287 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); |
278 | 288 |
279 sender()->SetContents(NULL); | 289 sender()->SetContents(NULL); |
280 Observe(NULL); | 290 Observe(NULL); |
281 } | 291 } |
OLD | NEW |