| 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/history/history_types.h" | 8 #include "chrome/browser/history/history_types.h" |
| 9 #include "chrome/browser/instant/instant_loader_delegate.h" | 9 #include "chrome/browser/instant/instant_loader_delegate.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 virtual void DidFinishLoad( | 67 virtual void DidFinishLoad( |
| 68 int64 frame_id, | 68 int64 frame_id, |
| 69 const GURL& validated_url, | 69 const GURL& validated_url, |
| 70 bool is_main_frame, | 70 bool is_main_frame, |
| 71 content::RenderViewHost* render_view_host) OVERRIDE; | 71 content::RenderViewHost* render_view_host) OVERRIDE; |
| 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 // Message from renderer indicating the page has suggestions. | 75 // Message from renderer indicating the page has suggestions. |
| 76 void OnSetSuggestions(int page_id, | 76 void OnSetSuggestions(int page_id, |
| 77 const std::vector<string16>& suggestions, | 77 const std::vector<InstantSuggestion>& suggestions); |
| 78 InstantCompleteBehavior behavior); | |
| 79 | 78 |
| 80 // Message from the renderer determining whether it supports the Instant API. | 79 // Message from the renderer determining whether it supports the Instant API. |
| 81 void OnInstantSupportDetermined(int page_id, bool result); | 80 void OnInstantSupportDetermined(int page_id, bool result); |
| 82 | 81 |
| 83 void CommitFromPointerReleaseIfNecessary(); | 82 void CommitFromPointerReleaseIfNecessary(); |
| 84 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); | 83 void MaybeSetAndNotifyInstantSupportDetermined(bool supports_instant); |
| 85 | 84 |
| 86 InstantLoader* const loader_; | 85 InstantLoader* const loader_; |
| 87 | 86 |
| 88 // True if the mouse or a touch pointer is down from an activate. | 87 // True if the mouse or a touch pointer is down from an activate. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) | 190 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) |
| 192 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 191 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 193 OnInstantSupportDetermined) | 192 OnInstantSupportDetermined) |
| 194 IPC_MESSAGE_UNHANDLED(handled = false) | 193 IPC_MESSAGE_UNHANDLED(handled = false) |
| 195 IPC_END_MESSAGE_MAP() | 194 IPC_END_MESSAGE_MAP() |
| 196 return handled; | 195 return handled; |
| 197 } | 196 } |
| 198 | 197 |
| 199 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( | 198 void InstantLoader::WebContentsDelegateImpl::OnSetSuggestions( |
| 200 int page_id, | 199 int page_id, |
| 201 const std::vector<string16>& suggestions, | 200 const std::vector<InstantSuggestion>& suggestions) { |
| 202 InstantCompleteBehavior behavior) { | |
| 203 DCHECK(loader_->preview_contents() && | 201 DCHECK(loader_->preview_contents() && |
| 204 loader_->preview_contents_->web_contents()); | 202 loader_->preview_contents_->web_contents()); |
| 205 // TODO(sreeram): Remove this 'if' bandaid once bug 141875 is confirmed fixed. | 203 // TODO(sreeram): Remove this 'if' bandaid once bug 141875 is confirmed fixed. |
| 206 if (!loader_->preview_contents() || | 204 if (!loader_->preview_contents() || |
| 207 !loader_->preview_contents_->web_contents()) { | 205 !loader_->preview_contents_->web_contents()) { |
| 208 return; | 206 return; |
| 209 } | 207 } |
| 210 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> | 208 content::NavigationEntry* entry = loader_->preview_contents_->web_contents()-> |
| 211 GetController().GetActiveEntry(); | 209 GetController().GetActiveEntry(); |
| 212 if (entry && page_id == entry->GetPageID()) { | 210 if (entry && page_id == entry->GetPageID()) { |
| 213 MaybeSetAndNotifyInstantSupportDetermined(true); | 211 MaybeSetAndNotifyInstantSupportDetermined(true); |
| 214 loader_->loader_delegate_->SetSuggestions(loader_, suggestions, behavior); | 212 loader_->loader_delegate_->SetSuggestions(loader_, suggestions); |
| 215 } | 213 } |
| 216 } | 214 } |
| 217 | 215 |
| 218 void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined( | 216 void InstantLoader::WebContentsDelegateImpl::OnInstantSupportDetermined( |
| 219 int page_id, | 217 int page_id, |
| 220 bool result) { | 218 bool result) { |
| 221 DCHECK(loader_->preview_contents() && | 219 DCHECK(loader_->preview_contents() && |
| 222 loader_->preview_contents_->web_contents()); | 220 loader_->preview_contents_->web_contents()); |
| 223 // TODO(sreeram): Remove this 'if' bandaid once bug 141875 is confirmed fixed. | 221 // TODO(sreeram): Remove this 'if' bandaid once bug 141875 is confirmed fixed. |
| 224 if (!loader_->preview_contents() || | 222 if (!loader_->preview_contents() || |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 TabContents* new_tc) { | 390 TabContents* new_tc) { |
| 393 DCHECK(old_tc == preview_contents_); | 391 DCHECK(old_tc == preview_contents_); |
| 394 CleanupPreviewContents(); | 392 CleanupPreviewContents(); |
| 395 // We release here without deleting so that the caller still has the | 393 // We release here without deleting so that the caller still has the |
| 396 // responsibility for deleting the TabContents. | 394 // responsibility for deleting the TabContents. |
| 397 ignore_result(preview_contents_.release()); | 395 ignore_result(preview_contents_.release()); |
| 398 preview_contents_.reset(new_tc); | 396 preview_contents_.reset(new_tc); |
| 399 SetupPreviewContents(); | 397 SetupPreviewContents(); |
| 400 loader_delegate_->SwappedTabContents(this); | 398 loader_delegate_->SwappedTabContents(this); |
| 401 } | 399 } |
| OLD | NEW |