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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 bool InstantPage::ShouldProcessFocusOmnibox() { | 112 bool InstantPage::ShouldProcessFocusOmnibox() { |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 bool InstantPage::ShouldProcessNavigateToURL() { | 116 bool InstantPage::ShouldProcessNavigateToURL() { |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
| 120 bool InstantPage::ShouldProcessPasteIntoOmnibox() { |
| 121 return false; |
| 122 } |
| 123 |
120 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { | 124 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { |
121 return false; | 125 return false; |
122 } | 126 } |
123 | 127 |
124 bool InstantPage::ShouldProcessUndoMostVisitedDeletion() { | 128 bool InstantPage::ShouldProcessUndoMostVisitedDeletion() { |
125 return false; | 129 return false; |
126 } | 130 } |
127 | 131 |
128 bool InstantPage::ShouldProcessUndoAllMostVisitedDeletions() { | 132 bool InstantPage::ShouldProcessUndoAllMostVisitedDeletions() { |
129 return false; | 133 return false; |
130 } | 134 } |
131 | 135 |
132 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 136 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
133 if (is_incognito_) | 137 if (is_incognito_) |
134 return false; | 138 return false; |
135 | 139 |
136 bool handled = true; | 140 bool handled = true; |
137 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 141 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
138 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 142 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
139 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 143 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
140 OnSearchBoxNavigate); | 144 OnSearchBoxNavigate); |
| 145 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxPaste, |
| 146 OnSearchBoxPaste); |
141 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); | 147 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); |
142 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
143 OnDeleteMostVisitedItem); | 149 OnDeleteMostVisitedItem); |
144 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
145 OnUndoMostVisitedDeletion); | 151 OnUndoMostVisitedDeletion); |
146 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 152 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
147 OnUndoAllMostVisitedDeletions); | 153 OnUndoAllMostVisitedDeletions); |
148 IPC_MESSAGE_UNHANDLED(handled = false) | 154 IPC_MESSAGE_UNHANDLED(handled = false) |
149 IPC_END_MESSAGE_MAP() | 155 IPC_END_MESSAGE_MAP() |
150 return handled; | 156 return handled; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return; | 235 return; |
230 | 236 |
231 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 237 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
232 if (!ShouldProcessNavigateToURL()) | 238 if (!ShouldProcessNavigateToURL()) |
233 return; | 239 return; |
234 | 240 |
235 delegate_->NavigateToURL( | 241 delegate_->NavigateToURL( |
236 contents(), url, transition, disposition, is_search_type); | 242 contents(), url, transition, disposition, is_search_type); |
237 } | 243 } |
238 | 244 |
| 245 void InstantPage::OnSearchBoxPaste(int page_id) { |
| 246 if (!contents()->IsActiveEntry(page_id)) |
| 247 return; |
| 248 |
| 249 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
| 250 if (!ShouldProcessPasteIntoOmnibox()) |
| 251 return; |
| 252 |
| 253 delegate_->PasteIntoOmnibox(contents()); |
| 254 } |
| 255 |
239 void InstantPage::OnCountMouseover(int page_id) { | 256 void InstantPage::OnCountMouseover(int page_id) { |
240 if (!contents()->IsActiveEntry(page_id)) | 257 if (!contents()->IsActiveEntry(page_id)) |
241 return; | 258 return; |
242 | 259 |
243 InstantTab::CountMouseover(contents()); | 260 InstantTab::CountMouseover(contents()); |
244 } | 261 } |
245 | 262 |
246 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { | 263 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { |
247 if (!contents()->IsActiveEntry(page_id)) | 264 if (!contents()->IsActiveEntry(page_id)) |
248 return; | 265 return; |
(...skipping 27 matching lines...) Expand all Loading... |
276 delegate_->UndoAllMostVisitedDeletions(); | 293 delegate_->UndoAllMostVisitedDeletions(); |
277 } | 294 } |
278 | 295 |
279 void InstantPage::ClearContents() { | 296 void InstantPage::ClearContents() { |
280 if (contents()) | 297 if (contents()) |
281 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); | 298 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); |
282 | 299 |
283 sender()->SetContents(NULL); | 300 sender()->SetContents(NULL); |
284 Observe(NULL); | 301 Observe(NULL); |
285 } | 302 } |
OLD | NEW |