| 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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool InstantPage::ShouldProcessRenderViewGone() { | 93 bool InstantPage::ShouldProcessRenderViewGone() { |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool InstantPage::ShouldProcessAboutToNavigateMainFrame() { | 97 bool InstantPage::ShouldProcessAboutToNavigateMainFrame() { |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool InstantPage::ShouldProcessSetSuggestions() { | |
| 102 return false; | |
| 103 } | |
| 104 | |
| 105 bool InstantPage::ShouldProcessShowInstantOverlay() { | |
| 106 return false; | |
| 107 } | |
| 108 | |
| 109 bool InstantPage::ShouldProcessFocusOmnibox() { | 101 bool InstantPage::ShouldProcessFocusOmnibox() { |
| 110 return false; | 102 return false; |
| 111 } | 103 } |
| 112 | 104 |
| 113 bool InstantPage::ShouldProcessNavigateToURL() { | 105 bool InstantPage::ShouldProcessNavigateToURL() { |
| 114 return false; | 106 return false; |
| 115 } | 107 } |
| 116 | 108 |
| 117 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { | 109 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { |
| 118 return false; | 110 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 130 if (ShouldProcessRenderViewCreated()) | 122 if (ShouldProcessRenderViewCreated()) |
| 131 delegate_->InstantPageRenderViewCreated(contents()); | 123 delegate_->InstantPageRenderViewCreated(contents()); |
| 132 } | 124 } |
| 133 | 125 |
| 134 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 126 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
| 135 if (is_incognito_) | 127 if (is_incognito_) |
| 136 return false; | 128 return false; |
| 137 | 129 |
| 138 bool handled = true; | 130 bool handled = true; |
| 139 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 131 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
| 140 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | |
| 141 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, | |
| 142 OnShowInstantOverlay) | |
| 143 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 132 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
| 144 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 133 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 145 OnSearchBoxNavigate); | 134 OnSearchBoxNavigate); |
| 146 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 135 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| 147 OnDeleteMostVisitedItem); | 136 OnDeleteMostVisitedItem); |
| 148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 137 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
| 149 OnUndoMostVisitedDeletion); | 138 OnUndoMostVisitedDeletion); |
| 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 139 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
| 151 OnUndoAllMostVisitedDeletions); | 140 OnUndoAllMostVisitedDeletions); |
| 152 IPC_MESSAGE_UNHANDLED(handled = false) | 141 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 186 } |
| 198 | 187 |
| 199 void InstantPage::InstantSupportDetermined(bool supports_instant) { | 188 void InstantPage::InstantSupportDetermined(bool supports_instant) { |
| 200 delegate_->InstantSupportDetermined(contents(), supports_instant); | 189 delegate_->InstantSupportDetermined(contents(), supports_instant); |
| 201 | 190 |
| 202 // If the page doesn't support Instant, stop listening to it. | 191 // If the page doesn't support Instant, stop listening to it. |
| 203 if (!supports_instant) | 192 if (!supports_instant) |
| 204 ClearContents(); | 193 ClearContents(); |
| 205 } | 194 } |
| 206 | 195 |
| 207 void InstantPage::OnSetSuggestions( | |
| 208 int page_id, | |
| 209 const std::vector<InstantSuggestion>& suggestions) { | |
| 210 if (!contents()->IsActiveEntry(page_id)) | |
| 211 return; | |
| 212 | |
| 213 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | |
| 214 if (!ShouldProcessSetSuggestions()) | |
| 215 return; | |
| 216 | |
| 217 delegate_->SetSuggestions(contents(), suggestions); | |
| 218 } | |
| 219 | |
| 220 void InstantPage::OnShowInstantOverlay(int page_id, | |
| 221 int height, | |
| 222 InstantSizeUnits units) { | |
| 223 if (!contents()->IsActiveEntry(page_id)) | |
| 224 return; | |
| 225 | |
| 226 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | |
| 227 delegate_->LogDropdownShown(); | |
| 228 if (!ShouldProcessShowInstantOverlay()) | |
| 229 return; | |
| 230 | |
| 231 delegate_->ShowInstantOverlay(contents(), height, units); | |
| 232 } | |
| 233 | |
| 234 void InstantPage::OnFocusOmnibox(int page_id, OmniboxFocusState state) { | 196 void InstantPage::OnFocusOmnibox(int page_id, OmniboxFocusState state) { |
| 235 if (!contents()->IsActiveEntry(page_id)) | 197 if (!contents()->IsActiveEntry(page_id)) |
| 236 return; | 198 return; |
| 237 | 199 |
| 238 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 200 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
| 239 if (!ShouldProcessFocusOmnibox()) | 201 if (!ShouldProcessFocusOmnibox()) |
| 240 return; | 202 return; |
| 241 | 203 |
| 242 delegate_->FocusOmnibox(contents(), state); | 204 delegate_->FocusOmnibox(contents(), state); |
| 243 } | 205 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 delegate_->UndoAllMostVisitedDeletions(); | 253 delegate_->UndoAllMostVisitedDeletions(); |
| 292 } | 254 } |
| 293 | 255 |
| 294 void InstantPage::ClearContents() { | 256 void InstantPage::ClearContents() { |
| 295 if (contents()) | 257 if (contents()) |
| 296 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); | 258 SearchTabHelper::FromWebContents(contents())->model()->RemoveObserver(this); |
| 297 | 259 |
| 298 sender()->SetContents(NULL); | 260 sender()->SetContents(NULL); |
| 299 Observe(NULL); | 261 Observe(NULL); |
| 300 } | 262 } |
| OLD | NEW |