OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
6 | 6 |
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
8 #include "chrome/browser/instant/instant_controller.h" | 8 #include "chrome/browser/instant/instant_controller.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" | 10 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
88 | 88 |
89 private: | 89 private: |
90 // Message from renderer indicating the page has suggestions. | 90 // Message from renderer indicating the page has suggestions. |
91 void OnSetSuggestions(int page_id, | 91 void OnSetSuggestions(int page_id, |
92 const std::vector<InstantSuggestion>& suggestions); | 92 const std::vector<InstantSuggestion>& suggestions); |
93 | 93 |
94 // Message from the renderer determining whether it supports the Instant API. | 94 // Message from the renderer determining whether it supports the Instant API. |
95 void OnInstantSupportDetermined(int page_id, bool result); | 95 void OnInstantSupportDetermined(int page_id, bool result); |
96 | 96 |
| 97 // Message from the renderer saying the web searchbox lost focus. |
| 98 void OnWebSearchBoxBlur(int page_id); |
| 99 |
| 100 // Message from the renderer saying the web searchbox received focus. |
| 101 void OnWebSearchBoxFocus(int page_id); |
| 102 |
97 // Message from the renderer requesting the preview be shown. | 103 // Message from the renderer requesting the preview be shown. |
98 void OnShowInstantPreview(int page_id, | 104 void OnShowInstantPreview(int page_id, |
99 InstantShownReason reason, | 105 InstantShownReason reason, |
100 int height, | 106 int height, |
101 InstantSizeUnits units); | 107 InstantSizeUnits units); |
102 | 108 |
103 void CommitFromPointerReleaseIfNecessary(); | 109 void CommitFromPointerReleaseIfNecessary(); |
104 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); | 110 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); |
105 | 111 |
106 InstantLoader* const loader_; | 112 InstantLoader* const loader_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 207 } |
202 } | 208 } |
203 | 209 |
204 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( | 210 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( |
205 const IPC::Message& message) { | 211 const IPC::Message& message) { |
206 bool handled = true; | 212 bool handled = true; |
207 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) | 213 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) |
208 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 214 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
209 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 215 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
210 OnInstantSupportDetermined) | 216 OnInstantSupportDetermined) |
| 217 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OnWebSearchBoxBlur, |
| 218 OnWebSearchBoxBlur); |
| 219 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OnWebSearchBoxFocus, |
| 220 OnWebSearchBoxFocus); |
211 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, | 221 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, |
212 OnShowInstantPreview); | 222 OnShowInstantPreview); |
213 IPC_MESSAGE_UNHANDLED(handled = false) | 223 IPC_MESSAGE_UNHANDLED(handled = false) |
214 IPC_END_MESSAGE_MAP() | 224 IPC_END_MESSAGE_MAP() |
215 return handled; | 225 return handled; |
216 } | 226 } |
217 | 227 |
218 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( | 228 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( |
219 int page_id, | 229 int page_id, |
220 const std::vector<InstantSuggestion>& suggestions) { | 230 const std::vector<InstantSuggestion>& suggestions) { |
(...skipping 11 matching lines...) Expand all Loading... |
232 int page_id, | 242 int page_id, |
233 bool result) { | 243 bool result) { |
234 DCHECK(loader_->preview_contents()); | 244 DCHECK(loader_->preview_contents()); |
235 DCHECK(loader_->preview_contents_->web_contents()); | 245 DCHECK(loader_->preview_contents_->web_contents()); |
236 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 246 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
237 GetController().GetActiveEntry(); | 247 GetController().GetActiveEntry(); |
238 if (entry && page_id == entry->GetPageID()) | 248 if (entry && page_id == entry->GetPageID()) |
239 MaybeSetAndNotifyInstantSupportDetermined(result); | 249 MaybeSetAndNotifyInstantSupportDetermined(result); |
240 } | 250 } |
241 | 251 |
| 252 void InstantLoader::WebContentsDelegateImpl::OnWebSearchBoxBlur(int page_id) { |
| 253 DCHECK(loader_->preview_contents()); |
| 254 DCHECK(loader_->preview_contents_->web_contents()); |
| 255 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 256 GetController().GetActiveEntry(); |
| 257 if (entry && page_id == entry->GetPageID()) { |
| 258 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 259 loader_->controller_->OnWebSearchBoxBlur(loader_); |
| 260 } |
| 261 } |
| 262 |
| 263 void InstantLoader::WebContentsDelegateImpl::OnWebSearchBoxFocus(int page_id) { |
| 264 DCHECK(loader_->preview_contents()); |
| 265 DCHECK(loader_->preview_contents_->web_contents()); |
| 266 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 267 GetController().GetActiveEntry(); |
| 268 if (entry && page_id == entry->GetPageID()) { |
| 269 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 270 loader_->controller_->OnWebSearchBoxFocus(loader_); |
| 271 } |
| 272 } |
| 273 |
242 void InstantLoader::WebContentsDelegateImpl::OnShowInstantPreview( | 274 void InstantLoader::WebContentsDelegateImpl::OnShowInstantPreview( |
243 int page_id, | 275 int page_id, |
244 InstantShownReason reason, | 276 InstantShownReason reason, |
245 int height, | 277 int height, |
246 InstantSizeUnits units) { | 278 InstantSizeUnits units) { |
247 DCHECK(loader_->preview_contents()); | 279 DCHECK(loader_->preview_contents()); |
248 DCHECK(loader_->preview_contents_->web_contents()); | 280 DCHECK(loader_->preview_contents_->web_contents()); |
249 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 281 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
250 GetController().GetActiveEntry(); | 282 GetController().GetActiveEntry(); |
251 if (entry && page_id == entry->GetPageID()) { | 283 if (entry && page_id == entry->GetPageID()) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 content::WebContents* new_contents) { | 500 content::WebContents* new_contents) { |
469 DCHECK_EQ(old_contents, preview_contents_->web_contents()); | 501 DCHECK_EQ(old_contents, preview_contents_->web_contents()); |
470 CleanupPreviewContents(); | 502 CleanupPreviewContents(); |
471 // We release here without deleting so that the caller still has the | 503 // We release here without deleting so that the caller still has the |
472 // responsibility for deleting the TabContents. | 504 // responsibility for deleting the TabContents. |
473 ignore_result(preview_contents_.release()); | 505 ignore_result(preview_contents_.release()); |
474 preview_contents_.reset(TabContents::FromWebContents(new_contents)); | 506 preview_contents_.reset(TabContents::FromWebContents(new_contents)); |
475 SetupPreviewContents(); | 507 SetupPreviewContents(); |
476 controller_->SwappedTabContents(this); | 508 controller_->SwappedTabContents(this); |
477 } | 509 } |
OLD | NEW |