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_ntp.h" |
10 #include "chrome/browser/ui/search/search_model.h" | 11 #include "chrome/browser/ui/search/search_model.h" |
11 #include "chrome/browser/ui/search/search_tab_helper.h" | 12 #include "chrome/browser/ui/search/search_tab_helper.h" |
12 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/frame_navigate_params.h" | 19 #include "content/public/common/frame_navigate_params.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 112 |
112 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 113 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
113 if (is_incognito_) | 114 if (is_incognito_) |
114 return false; | 115 return false; |
115 | 116 |
116 bool handled = true; | 117 bool handled = true; |
117 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 118 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
118 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 119 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
119 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 120 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
120 OnSearchBoxNavigate); | 121 OnSearchBoxNavigate); |
| 122 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); |
121 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 123 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
122 OnDeleteMostVisitedItem); | 124 OnDeleteMostVisitedItem); |
123 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 125 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
124 OnUndoMostVisitedDeletion); | 126 OnUndoMostVisitedDeletion); |
125 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 127 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
126 OnUndoAllMostVisitedDeletions); | 128 OnUndoAllMostVisitedDeletions); |
127 IPC_MESSAGE_UNHANDLED(handled = false) | 129 IPC_MESSAGE_UNHANDLED(handled = false) |
128 IPC_END_MESSAGE_MAP() | 130 IPC_END_MESSAGE_MAP() |
129 return handled; | 131 return handled; |
130 } | 132 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return; | 196 return; |
195 | 197 |
196 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 198 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
197 if (!ShouldProcessNavigateToURL()) | 199 if (!ShouldProcessNavigateToURL()) |
198 return; | 200 return; |
199 | 201 |
200 delegate_->NavigateToURL( | 202 delegate_->NavigateToURL( |
201 contents(), url, transition, disposition, is_search_type); | 203 contents(), url, transition, disposition, is_search_type); |
202 } | 204 } |
203 | 205 |
| 206 void InstantPage::OnCountMouseover(int page_id) { |
| 207 if (!contents()->IsActiveEntry(page_id)) |
| 208 return; |
| 209 |
| 210 InstantNTP::CountMouseover(contents()); |
| 211 } |
| 212 |
204 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { | 213 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { |
205 if (!contents()->IsActiveEntry(page_id)) | 214 if (!contents()->IsActiveEntry(page_id)) |
206 return; | 215 return; |
207 | 216 |
208 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 217 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
209 if (!ShouldProcessDeleteMostVisitedItem()) | 218 if (!ShouldProcessDeleteMostVisitedItem()) |
210 return; | 219 return; |
211 | 220 |
212 delegate_->DeleteMostVisitedItem(url); | 221 delegate_->DeleteMostVisitedItem(url); |
213 } | 222 } |
(...skipping 20 matching lines...) Expand all Loading... |
234 delegate_->UndoAllMostVisitedDeletions(); | 243 delegate_->UndoAllMostVisitedDeletions(); |
235 } | 244 } |
236 | 245 |
237 void InstantPage::ClearContents() { | 246 void InstantPage::ClearContents() { |
238 if (contents()) | 247 if (contents()) |
239 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); | 248 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); |
240 | 249 |
241 sender()->SetContents(NULL); | 250 sender()->SetContents(NULL); |
242 Observe(NULL); | 251 Observe(NULL); |
243 } | 252 } |
OLD | NEW |