| 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool InstantPage::ShouldProcessShowInstantOverlay() { | 136 bool InstantPage::ShouldProcessShowInstantOverlay() { |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool InstantPage::ShouldProcessFocusOmnibox() { | 140 bool InstantPage::ShouldProcessFocusOmnibox() { |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool InstantPage::ShouldProcessStartCapturingKeyStrokes() { | |
| 145 return false; | |
| 146 } | |
| 147 | |
| 148 bool InstantPage::ShouldProcessStopCapturingKeyStrokes() { | |
| 149 return false; | |
| 150 } | |
| 151 | |
| 152 bool InstantPage::ShouldProcessNavigateToURL() { | 144 bool InstantPage::ShouldProcessNavigateToURL() { |
| 153 return false; | 145 return false; |
| 154 } | 146 } |
| 155 | 147 |
| 156 void InstantPage::RenderViewCreated(content::RenderViewHost* render_view_host) { | 148 void InstantPage::RenderViewCreated(content::RenderViewHost* render_view_host) { |
| 157 if (ShouldProcessRenderViewCreated()) | 149 if (ShouldProcessRenderViewCreated()) |
| 158 delegate_->InstantPageRenderViewCreated(contents()); | 150 delegate_->InstantPageRenderViewCreated(contents()); |
| 159 } | 151 } |
| 160 | 152 |
| 161 void InstantPage::DidFinishLoad( | 153 void InstantPage::DidFinishLoad( |
| 162 int64 /* frame_id */, | 154 int64 /* frame_id */, |
| 163 const GURL& /* validated_url */, | 155 const GURL& /* validated_url */, |
| 164 bool is_main_frame, | 156 bool is_main_frame, |
| 165 content::RenderViewHost* /* render_view_host */) { | 157 content::RenderViewHost* /* render_view_host */) { |
| 166 if (is_main_frame && !supports_instant_) | 158 if (is_main_frame && !supports_instant_) |
| 167 DetermineIfPageSupportsInstant(); | 159 DetermineIfPageSupportsInstant(); |
| 168 } | 160 } |
| 169 | 161 |
| 170 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 162 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
| 171 bool handled = true; | 163 bool handled = true; |
| 172 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 164 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
| 173 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
| 174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 175 OnInstantSupportDetermined) | 167 OnInstantSupportDetermined) |
| 176 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, | 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, |
| 177 OnShowInstantOverlay) | 169 OnShowInstantOverlay) |
| 178 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
| 179 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StartCapturingKeyStrokes, | |
| 180 OnStartCapturingKeyStrokes); | |
| 181 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StopCapturingKeyStrokes, | |
| 182 OnStopCapturingKeyStrokes); | |
| 183 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 171 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 184 OnSearchBoxNavigate); | 172 OnSearchBoxNavigate); |
| 185 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 173 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| 186 OnDeleteMostVisitedItem); | 174 OnDeleteMostVisitedItem); |
| 187 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 175 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
| 188 OnUndoMostVisitedDeletion); | 176 OnUndoMostVisitedDeletion); |
| 189 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 177 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
| 190 OnUndoAllMostVisitedDeletions); | 178 OnUndoAllMostVisitedDeletions); |
| 191 IPC_MESSAGE_UNHANDLED(handled = false) | 179 IPC_MESSAGE_UNHANDLED(handled = false) |
| 192 IPC_END_MESSAGE_MAP() | 180 IPC_END_MESSAGE_MAP() |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void InstantPage::OnShowInstantOverlay(int page_id, | 224 void InstantPage::OnShowInstantOverlay(int page_id, |
| 237 int height, | 225 int height, |
| 238 InstantSizeUnits units) { | 226 InstantSizeUnits units) { |
| 239 if (contents()->IsActiveEntry(page_id)) { | 227 if (contents()->IsActiveEntry(page_id)) { |
| 240 OnInstantSupportDetermined(page_id, true); | 228 OnInstantSupportDetermined(page_id, true); |
| 241 if (ShouldProcessShowInstantOverlay()) | 229 if (ShouldProcessShowInstantOverlay()) |
| 242 delegate_->ShowInstantOverlay(contents(), height, units); | 230 delegate_->ShowInstantOverlay(contents(), height, units); |
| 243 } | 231 } |
| 244 } | 232 } |
| 245 | 233 |
| 246 void InstantPage::OnFocusOmnibox(int page_id) { | 234 void InstantPage::OnFocusOmnibox(int page_id, OmniboxFocusState state) { |
| 247 if (contents()->IsActiveEntry(page_id)) { | 235 if (contents()->IsActiveEntry(page_id)) { |
| 248 OnInstantSupportDetermined(page_id, true); | 236 OnInstantSupportDetermined(page_id, true); |
| 249 if (ShouldProcessFocusOmnibox()) | 237 if (ShouldProcessFocusOmnibox()) |
| 250 delegate_->FocusOmnibox(contents()); | 238 delegate_->FocusOmnibox(contents(), state); |
| 251 } | 239 } |
| 252 } | 240 } |
| 253 | 241 |
| 254 void InstantPage::OnStartCapturingKeyStrokes(int page_id) { | |
| 255 if (contents()->IsActiveEntry(page_id)) { | |
| 256 OnInstantSupportDetermined(page_id, true); | |
| 257 if (ShouldProcessStartCapturingKeyStrokes()) | |
| 258 delegate_->StartCapturingKeyStrokes(contents()); | |
| 259 } | |
| 260 } | |
| 261 | |
| 262 void InstantPage::OnStopCapturingKeyStrokes(int page_id) { | |
| 263 if (contents()->IsActiveEntry(page_id)) { | |
| 264 OnInstantSupportDetermined(page_id, true); | |
| 265 if (ShouldProcessStopCapturingKeyStrokes()) | |
| 266 delegate_->StopCapturingKeyStrokes(contents()); | |
| 267 } | |
| 268 } | |
| 269 | |
| 270 void InstantPage::OnSearchBoxNavigate(int page_id, | 242 void InstantPage::OnSearchBoxNavigate(int page_id, |
| 271 const GURL& url, | 243 const GURL& url, |
| 272 content::PageTransition transition, | 244 content::PageTransition transition, |
| 273 WindowOpenDisposition disposition) { | 245 WindowOpenDisposition disposition) { |
| 274 if (contents()->IsActiveEntry(page_id)) { | 246 if (contents()->IsActiveEntry(page_id)) { |
| 275 OnInstantSupportDetermined(page_id, true); | 247 OnInstantSupportDetermined(page_id, true); |
| 276 if (ShouldProcessNavigateToURL()) | 248 if (ShouldProcessNavigateToURL()) |
| 277 delegate_->NavigateToURL(contents(), url, transition, disposition); | 249 delegate_->NavigateToURL(contents(), url, transition, disposition); |
| 278 } | 250 } |
| 279 } | 251 } |
| 280 | 252 |
| 281 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) { | 253 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) { |
| 282 delegate_->DeleteMostVisitedItem(restricted_id); | 254 delegate_->DeleteMostVisitedItem(restricted_id); |
| 283 } | 255 } |
| 284 | 256 |
| 285 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { | 257 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { |
| 286 delegate_->UndoMostVisitedDeletion(restricted_id); | 258 delegate_->UndoMostVisitedDeletion(restricted_id); |
| 287 } | 259 } |
| 288 | 260 |
| 289 void InstantPage::OnUndoAllMostVisitedDeletions() { | 261 void InstantPage::OnUndoAllMostVisitedDeletions() { |
| 290 delegate_->UndoAllMostVisitedDeletions(); | 262 delegate_->UndoAllMostVisitedDeletions(); |
| 291 } | 263 } |
| OLD | NEW |