Chromium Code Reviews| 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 "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 | 154 |
| 155 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 155 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
| 156 bool handled = true; | 156 bool handled = true; |
| 157 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 157 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
| 158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
| 159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 160 OnInstantSupportDetermined) | 160 OnInstantSupportDetermined) |
| 161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, | 161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, |
| 162 OnShowInstantOverlay) | 162 OnShowInstantOverlay) |
| 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
| 164 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StartCapturingKeyStrokes, | |
| 165 OnStartCapturingKeyStrokes); | |
| 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StopCapturingKeyStrokes, | |
| 167 OnStopCapturingKeyStrokes); | |
| 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 164 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 169 OnSearchBoxNavigate); | 165 OnSearchBoxNavigate); |
| 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| 171 OnDeleteMostVisitedItem); | 167 OnDeleteMostVisitedItem); |
| 172 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
| 173 OnUndoMostVisitedDeletion); | 169 OnUndoMostVisitedDeletion); |
| 174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
| 175 OnUndoAllMostVisitedDeletions); | 171 OnUndoAllMostVisitedDeletions); |
| 176 IPC_MESSAGE_UNHANDLED(handled = false) | 172 IPC_MESSAGE_UNHANDLED(handled = false) |
| 177 IPC_END_MESSAGE_MAP() | 173 IPC_END_MESSAGE_MAP() |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 void InstantPage::OnShowInstantOverlay(int page_id, | 217 void InstantPage::OnShowInstantOverlay(int page_id, |
| 222 int height, | 218 int height, |
| 223 InstantSizeUnits units) { | 219 InstantSizeUnits units) { |
| 224 if (contents()->IsActiveEntry(page_id)) { | 220 if (contents()->IsActiveEntry(page_id)) { |
| 225 OnInstantSupportDetermined(page_id, true); | 221 OnInstantSupportDetermined(page_id, true); |
| 226 if (ShouldProcessShowInstantOverlay()) | 222 if (ShouldProcessShowInstantOverlay()) |
| 227 delegate_->ShowInstantOverlay(contents(), height, units); | 223 delegate_->ShowInstantOverlay(contents(), height, units); |
| 228 } | 224 } |
| 229 } | 225 } |
| 230 | 226 |
| 231 void InstantPage::OnFocusOmnibox(int page_id) { | 227 void InstantPage::OnFocusOmnibox(int page_id, OmniboxFocusState state) { |
| 232 if (contents()->IsActiveEntry(page_id)) { | 228 if (contents()->IsActiveEntry(page_id)) { |
| 233 OnInstantSupportDetermined(page_id, true); | 229 OnInstantSupportDetermined(page_id, true); |
| 234 if (ShouldProcessFocusOmnibox()) | 230 switch (state) { |
| 235 delegate_->FocusOmnibox(contents()); | 231 case OMNIBOX_FOCUS_VISIBLE: |
| 232 if (ShouldProcessFocusOmnibox()) | |
| 233 delegate_->FocusOmnibox(contents()); | |
| 234 break; | |
| 235 case OMNIBOX_FOCUS_INVISIBLE: | |
| 236 if (ShouldProcessStartCapturingKeyStrokes()) | |
| 237 delegate_->StartCapturingKeyStrokes(contents()); | |
| 238 break; | |
| 239 case OMNIBOX_FOCUS_NONE: | |
| 240 if (ShouldProcessStopCapturingKeyStrokes()) | |
| 241 delegate_->StopCapturingKeyStrokes(contents()); | |
|
kmadhusu
2013/03/26 18:56:17
From my understanding of the bug report, we want t
sreeram
2013/03/26 19:01:24
Let's not. InstantPage should be a simple message
kmadhusu
2013/03/26 21:04:00
Done. Moved this logic to InstantController.
Can
| |
| 242 break; | |
| 243 default: | |
| 244 NOTREACHED(); | |
| 245 } | |
| 236 } | 246 } |
| 237 } | 247 } |
| 238 | 248 |
| 239 void InstantPage::OnStartCapturingKeyStrokes(int page_id) { | |
| 240 if (contents()->IsActiveEntry(page_id)) { | |
| 241 OnInstantSupportDetermined(page_id, true); | |
| 242 if (ShouldProcessStartCapturingKeyStrokes()) | |
| 243 delegate_->StartCapturingKeyStrokes(contents()); | |
| 244 } | |
| 245 } | |
| 246 | |
| 247 void InstantPage::OnStopCapturingKeyStrokes(int page_id) { | |
| 248 if (contents()->IsActiveEntry(page_id)) { | |
| 249 OnInstantSupportDetermined(page_id, true); | |
| 250 if (ShouldProcessStopCapturingKeyStrokes()) | |
| 251 delegate_->StopCapturingKeyStrokes(contents()); | |
| 252 } | |
| 253 } | |
| 254 | |
| 255 void InstantPage::OnSearchBoxNavigate(int page_id, | 249 void InstantPage::OnSearchBoxNavigate(int page_id, |
| 256 const GURL& url, | 250 const GURL& url, |
| 257 content::PageTransition transition, | 251 content::PageTransition transition, |
| 258 WindowOpenDisposition disposition) { | 252 WindowOpenDisposition disposition) { |
| 259 if (contents()->IsActiveEntry(page_id)) { | 253 if (contents()->IsActiveEntry(page_id)) { |
| 260 OnInstantSupportDetermined(page_id, true); | 254 OnInstantSupportDetermined(page_id, true); |
| 261 if (ShouldProcessNavigateToURL()) | 255 if (ShouldProcessNavigateToURL()) |
| 262 delegate_->NavigateToURL(contents(), url, transition, disposition); | 256 delegate_->NavigateToURL(contents(), url, transition, disposition); |
| 263 } | 257 } |
| 264 } | 258 } |
| 265 | 259 |
| 266 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) { | 260 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) { |
| 267 delegate_->DeleteMostVisitedItem(restricted_id); | 261 delegate_->DeleteMostVisitedItem(restricted_id); |
| 268 } | 262 } |
| 269 | 263 |
| 270 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { | 264 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { |
| 271 delegate_->UndoMostVisitedDeletion(restricted_id); | 265 delegate_->UndoMostVisitedDeletion(restricted_id); |
| 272 } | 266 } |
| 273 | 267 |
| 274 void InstantPage::OnUndoAllMostVisitedDeletions() { | 268 void InstantPage::OnUndoAllMostVisitedDeletions() { |
| 275 delegate_->UndoAllMostVisitedDeletions(); | 269 delegate_->UndoAllMostVisitedDeletions(); |
| 276 } | 270 } |
| OLD | NEW |