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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 requesting the preview be shown. | 101 // Message from the renderer requesting the preview be shown. |
102 void OnShowInstantPreview(int page_id, | 102 void OnShowInstantPreview(int page_id, |
103 InstantShownReason reason, | 103 InstantShownReason reason, |
104 int height, | 104 int height, |
105 InstantSizeUnits units); | 105 InstantSizeUnits units); |
106 | 106 |
| 107 // Message from the renderer requesting the browser to start capturing user |
| 108 // key strokes. |
| 109 void OnStartCapturingKeyStrokes(int page_id); |
| 110 |
| 111 // Message from the renderer requesting the browser to stop capturing user |
| 112 // key strokes. |
| 113 void OnStopCapturingKeyStrokes(int page_id); |
| 114 |
107 void CommitFromPointerReleaseIfNecessary(); | 115 void CommitFromPointerReleaseIfNecessary(); |
108 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); | 116 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); |
109 | 117 |
110 InstantLoader* const loader_; | 118 InstantLoader* const loader_; |
111 | 119 |
112 // True if the mouse or a touch pointer is down from an activate. | 120 // True if the mouse or a touch pointer is down from an activate. |
113 bool is_pointer_down_from_activate_; | 121 bool is_pointer_down_from_activate_; |
114 | 122 |
115 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); | 123 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); |
116 }; | 124 }; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 213 |
206 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( | 214 bool InstantLoader::WebContentsDelegateImpl::OnMessageReceived( |
207 const IPC::Message& message) { | 215 const IPC::Message& message) { |
208 bool handled = true; | 216 bool handled = true; |
209 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) | 217 IPC_BEGIN_MESSAGE_MAP(WebContentsDelegateImpl, message) |
210 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 218 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
211 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 219 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
212 OnInstantSupportDetermined) | 220 OnInstantSupportDetermined) |
213 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, | 221 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantPreview, |
214 OnShowInstantPreview); | 222 OnShowInstantPreview); |
| 223 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StartCapturingKeyStrokes, |
| 224 OnStartCapturingKeyStrokes); |
| 225 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StopCapturingKeyStrokes, |
| 226 OnStopCapturingKeyStrokes); |
215 IPC_MESSAGE_UNHANDLED(handled = false) | 227 IPC_MESSAGE_UNHANDLED(handled = false) |
216 IPC_END_MESSAGE_MAP() | 228 IPC_END_MESSAGE_MAP() |
217 return handled; | 229 return handled; |
218 } | 230 } |
219 | 231 |
220 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( | 232 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( |
221 int page_id, | 233 int page_id, |
222 const std::vector<InstantSuggestion>& suggestions) { | 234 const std::vector<InstantSuggestion>& suggestions) { |
223 DCHECK(loader_->preview_contents()); | 235 DCHECK(loader_->preview_contents()); |
224 DCHECK(loader_->preview_contents_->web_contents()); | 236 DCHECK(loader_->preview_contents_->web_contents()); |
(...skipping 24 matching lines...) Expand all Loading... |
249 DCHECK(loader_->preview_contents()); | 261 DCHECK(loader_->preview_contents()); |
250 DCHECK(loader_->preview_contents_->web_contents()); | 262 DCHECK(loader_->preview_contents_->web_contents()); |
251 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 263 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
252 GetController().GetActiveEntry(); | 264 GetController().GetActiveEntry(); |
253 if (entry && page_id == entry->GetPageID()) { | 265 if (entry && page_id == entry->GetPageID()) { |
254 MaybeSetAndNotifyInstantSupportDetermined(true); | 266 MaybeSetAndNotifyInstantSupportDetermined(true); |
255 loader_->controller_->ShowInstantPreview(loader_, reason, height, units); | 267 loader_->controller_->ShowInstantPreview(loader_, reason, height, units); |
256 } | 268 } |
257 } | 269 } |
258 | 270 |
| 271 void InstantLoader::WebContentsDelegateImpl::OnStartCapturingKeyStrokes( |
| 272 int page_id) { |
| 273 DCHECK(loader_->preview_contents()); |
| 274 DCHECK(loader_->preview_contents_->web_contents()); |
| 275 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 276 GetController().GetActiveEntry(); |
| 277 if (entry && page_id == entry->GetPageID()) { |
| 278 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 279 loader_->controller_->StartCapturingKeyStrokes(loader_); |
| 280 } |
| 281 } |
| 282 |
| 283 void InstantLoader::WebContentsDelegateImpl::OnStopCapturingKeyStrokes( |
| 284 int page_id) { |
| 285 DCHECK(loader_->preview_contents()); |
| 286 DCHECK(loader_->preview_contents_->web_contents()); |
| 287 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 288 GetController().GetActiveEntry(); |
| 289 if (entry && page_id == entry->GetPageID()) { |
| 290 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 291 // NOTE(samarth): we don't do anything else yet in this case. |
| 292 } |
| 293 } |
| 294 |
259 void InstantLoader::WebContentsDelegateImpl | 295 void InstantLoader::WebContentsDelegateImpl |
260 ::CommitFromPointerReleaseIfNecessary() { | 296 ::CommitFromPointerReleaseIfNecessary() { |
261 if (is_pointer_down_from_activate_) { | 297 if (is_pointer_down_from_activate_) { |
262 is_pointer_down_from_activate_ = false; | 298 is_pointer_down_from_activate_ = false; |
263 loader_->controller_->CommitInstantLoader(loader_); | 299 loader_->controller_->CommitInstantLoader(loader_); |
264 } | 300 } |
265 } | 301 } |
266 | 302 |
267 void InstantLoader::WebContentsDelegateImpl | 303 void InstantLoader::WebContentsDelegateImpl |
268 ::MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant) { | 304 ::MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 content::WebContents* new_contents) { | 505 content::WebContents* new_contents) { |
470 DCHECK_EQ(old_contents, preview_contents_->web_contents()); | 506 DCHECK_EQ(old_contents, preview_contents_->web_contents()); |
471 CleanupPreviewContents(); | 507 CleanupPreviewContents(); |
472 // We release here without deleting so that the caller still has the | 508 // We release here without deleting so that the caller still has the |
473 // responsibility for deleting the TabContents. | 509 // responsibility for deleting the TabContents. |
474 ignore_result(preview_contents_.release()); | 510 ignore_result(preview_contents_.release()); |
475 preview_contents_.reset(TabContents::FromWebContents(new_contents)); | 511 preview_contents_.reset(TabContents::FromWebContents(new_contents)); |
476 SetupPreviewContents(); | 512 SetupPreviewContents(); |
477 controller_->SwappedTabContents(this); | 513 controller_->SwappedTabContents(this); |
478 } | 514 } |
OLD | NEW |