OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 content::RenderViewHost* render_view_host) OVERRIDE; | 91 content::RenderViewHost* render_view_host) OVERRIDE; |
92 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 92 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
93 | 93 |
94 // Message from renderer indicating the page has suggestions. | 94 // Message from renderer indicating the page has suggestions. |
95 void OnSetSuggestions(int page_id, | 95 void OnSetSuggestions(int page_id, |
96 const std::vector<InstantSuggestion>& suggestions); | 96 const std::vector<InstantSuggestion>& suggestions); |
97 | 97 |
98 // Message from the renderer determining whether it supports the Instant API. | 98 // Message from the renderer determining whether it supports the Instant API. |
99 void OnInstantSupportDetermined(int page_id, bool result); | 99 void OnInstantSupportDetermined(int page_id, bool result); |
100 | 100 |
| 101 // Message from the renderer saying the web searchbox focus state changed. |
| 102 void OnWebSearchBoxFocusChange(int page_id, bool is_focused); |
| 103 |
101 // Message from the renderer requesting the preview be shown. | 104 // Message from the renderer requesting the preview be shown. |
102 void OnShowInstantPreview(int page_id, | 105 void OnShowInstantPreview(int page_id, |
103 InstantShownReason reason, | 106 InstantShownReason reason, |
104 int height, | 107 int height, |
105 InstantSizeUnits units); | 108 InstantSizeUnits units); |
106 | 109 |
107 void CommitFromPointerReleaseIfNecessary(); | 110 void CommitFromPointerReleaseIfNecessary(); |
108 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); | 111 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); |
109 | 112 |
110 InstantLoader* const loader_; | 113 InstantLoader* const loader_; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id())); | 206 Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id())); |
204 } | 207 } |
205 | 208 |
206 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( | 209 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( |
207 const IPC::Message& message) { | 210 const IPC::Message& message) { |
208 bool handled = true; | 211 bool handled = true; |
209 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) | 212 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) |
210 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 213 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
211 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 214 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
212 OnInstantSupportDetermined) | 215 OnInstantSupportDetermined) |
| 216 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OnWebSearchBoxFocusChange, |
| 217 OnWebSearchBoxFocusChange); |
213 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, | 218 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, |
214 OnShowInstantPreview); | 219 OnShowInstantPreview); |
215 IPC_MESSAGE_UNHANDLED(handled = false) | 220 IPC_MESSAGE_UNHANDLED(handled = false) |
216 IPC_END_MESSAGE_MAP() | 221 IPC_END_MESSAGE_MAP() |
217 return handled; | 222 return handled; |
218 } | 223 } |
219 | 224 |
220 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( | 225 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( |
221 int page_id, | 226 int page_id, |
222 const std::vector<InstantSuggestion>& suggestions) { | 227 const std::vector<InstantSuggestion>& suggestions) { |
(...skipping 11 matching lines...) Expand all Loading... |
234 int page_id, | 239 int page_id, |
235 bool result) { | 240 bool result) { |
236 DCHECK(loader_->preview_contents()); | 241 DCHECK(loader_->preview_contents()); |
237 DCHECK(loader_->preview_contents_->web_contents()); | 242 DCHECK(loader_->preview_contents_->web_contents()); |
238 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 243 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
239 GetController().GetActiveEntry(); | 244 GetController().GetActiveEntry(); |
240 if (entry && page_id == entry->GetPageID()) | 245 if (entry && page_id == entry->GetPageID()) |
241 MaybeSetAndNotifyInstantSupportDetermined(result); | 246 MaybeSetAndNotifyInstantSupportDetermined(result); |
242 } | 247 } |
243 | 248 |
| 249 void InstantLoader::WebContentsDelegateImpl::OnWebSearchBoxFocusChange( |
| 250 int page_id, |
| 251 bool is_focused) { |
| 252 DCHECK(loader_->preview_contents()); |
| 253 DCHECK(loader_->preview_contents_->web_contents()); |
| 254 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 255 GetController().GetActiveEntry(); |
| 256 if (entry && page_id == entry->GetPageID()) { |
| 257 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 258 loader_->controller_->OnWebSearchBoxFocusChange(loader_, is_focused); |
| 259 } |
| 260 } |
| 261 |
244 void InstantLoader::WebContentsDelegateImpl::OnShowInstantPreview( | 262 void InstantLoader::WebContentsDelegateImpl::OnShowInstantPreview( |
245 int page_id, | 263 int page_id, |
246 InstantShownReason reason, | 264 InstantShownReason reason, |
247 int height, | 265 int height, |
248 InstantSizeUnits units) { | 266 InstantSizeUnits units) { |
249 DCHECK(loader_->preview_contents()); | 267 DCHECK(loader_->preview_contents()); |
250 DCHECK(loader_->preview_contents_->web_contents()); | 268 DCHECK(loader_->preview_contents_->web_contents()); |
251 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 269 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
252 GetController().GetActiveEntry(); | 270 GetController().GetActiveEntry(); |
253 if (entry && page_id == entry->GetPageID()) { | 271 if (entry && page_id == entry->GetPageID()) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 content::WebContents* new_contents) { | 466 content::WebContents* new_contents) { |
449 DCHECK_EQ(old_contents, preview_contents_->web_contents()); | 467 DCHECK_EQ(old_contents, preview_contents_->web_contents()); |
450 CleanupPreviewContents(); | 468 CleanupPreviewContents(); |
451 // We release here without deleting so that the caller still has the | 469 // We release here without deleting so that the caller still has the |
452 // responsibility for deleting the TabContents. | 470 // responsibility for deleting the TabContents. |
453 ignore_result(preview_contents_.release()); | 471 ignore_result(preview_contents_.release()); |
454 preview_contents_.reset(TabContents::FromWebContents(new_contents)); | 472 preview_contents_.reset(TabContents::FromWebContents(new_contents)); |
455 SetupPreviewContents(); | 473 SetupPreviewContents(); |
456 controller_->SwappedTabContents(this); | 474 controller_->SwappedTabContents(this); |
457 } | 475 } |
OLD | NEW |