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" | 10 #include "chrome/browser/ui/search/instant_ipc_sender.h" |
| 11 #include "chrome/browser/ui/search/instant_ntp.h" |
11 #include "chrome/browser/ui/search/search_model.h" | 12 #include "chrome/browser/ui/search/search_model.h" |
12 #include "chrome/browser/ui/search/search_tab_helper.h" | 13 #include "chrome/browser/ui/search/search_tab_helper.h" |
13 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
17 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return false; | 137 return false; |
137 | 138 |
138 bool handled = true; | 139 bool handled = true; |
139 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 140 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
140 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 141 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
141 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, | 142 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, |
142 OnShowInstantOverlay) | 143 OnShowInstantOverlay) |
143 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 144 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
144 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 145 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
145 OnSearchBoxNavigate); | 146 OnSearchBoxNavigate); |
| 147 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); |
146 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
147 OnDeleteMostVisitedItem); | 149 OnDeleteMostVisitedItem); |
148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
149 OnUndoMostVisitedDeletion); | 151 OnUndoMostVisitedDeletion); |
150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 152 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
151 OnUndoAllMostVisitedDeletions); | 153 OnUndoAllMostVisitedDeletions); |
152 IPC_MESSAGE_UNHANDLED(handled = false) | 154 IPC_MESSAGE_UNHANDLED(handled = false) |
153 IPC_END_MESSAGE_MAP() | 155 IPC_END_MESSAGE_MAP() |
154 return handled; | 156 return handled; |
155 } | 157 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 return; | 253 return; |
252 | 254 |
253 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 255 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
254 if (!ShouldProcessNavigateToURL()) | 256 if (!ShouldProcessNavigateToURL()) |
255 return; | 257 return; |
256 | 258 |
257 delegate_->NavigateToURL( | 259 delegate_->NavigateToURL( |
258 contents(), url, transition, disposition, is_search_type); | 260 contents(), url, transition, disposition, is_search_type); |
259 } | 261 } |
260 | 262 |
| 263 void InstantPage::OnCountMouseover(int page_id) { |
| 264 if (!contents()->IsActiveEntry(page_id)) |
| 265 return; |
| 266 |
| 267 InstantNTP::CountMouseover(contents()); |
| 268 } |
| 269 |
261 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { | 270 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { |
262 if (!contents()->IsActiveEntry(page_id)) | 271 if (!contents()->IsActiveEntry(page_id)) |
263 return; | 272 return; |
264 | 273 |
265 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 274 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
266 if (!ShouldProcessDeleteMostVisitedItem()) | 275 if (!ShouldProcessDeleteMostVisitedItem()) |
267 return; | 276 return; |
268 | 277 |
269 delegate_->DeleteMostVisitedItem(url); | 278 delegate_->DeleteMostVisitedItem(url); |
270 } | 279 } |
(...skipping 20 matching lines...) Expand all Loading... |
291 delegate_->UndoAllMostVisitedDeletions(); | 300 delegate_->UndoAllMostVisitedDeletions(); |
292 } | 301 } |
293 | 302 |
294 void InstantPage::ClearContents() { | 303 void InstantPage::ClearContents() { |
295 if (contents()) | 304 if (contents()) |
296 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); | 305 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); |
297 | 306 |
298 sender()->SetContents(NULL); | 307 sender()->SetContents(NULL); |
299 Observe(NULL); | 308 Observe(NULL); |
300 } | 309 } |
OLD | NEW |