| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 CommitFromPointerReleaseIfNecessary(); | 165 CommitFromPointerReleaseIfNecessary(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { | 168 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool InstantLoader::WebContentsDelegateImpl::ShouldAddNavigationToHistory( | 172 bool InstantLoader::WebContentsDelegateImpl::ShouldAddNavigationToHistory( |
| 173 const history::HistoryAddPageArgs& add_page_args, | 173 const history::HistoryAddPageArgs& add_page_args, |
| 174 content::NavigationType navigation_type) { | 174 content::NavigationType navigation_type) { |
| 175 loader_->last_navigation_ = add_page_args.Clone(); | 175 loader_->last_navigation_ = add_page_args; |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void InstantLoader::WebContentsDelegateImpl::DidFinishLoad( | 179 void InstantLoader::WebContentsDelegateImpl::DidFinishLoad( |
| 180 int64 frame_id, | 180 int64 frame_id, |
| 181 const GURL& validated_url, | 181 const GURL& validated_url, |
| 182 bool is_main_frame, | 182 bool is_main_frame, |
| 183 content::RenderViewHost* render_view_host) { | 183 content::RenderViewHost* render_view_host) { |
| 184 if (is_main_frame) { | 184 if (is_main_frame) { |
| 185 if (!loader_->supports_instant_) | 185 if (!loader_->supports_instant_) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 SetupPreviewContents(); | 305 SetupPreviewContents(); |
| 306 // This HTTP header and value are set on loads that originate from instant. | 306 // This HTTP header and value are set on loads that originate from instant. |
| 307 const char* const kInstantHeader = "X-Purpose: Instant"; | 307 const char* const kInstantHeader = "X-Purpose: Instant"; |
| 308 preview_contents_->web_contents()->GetController().LoadURL(GURL(instant_url_), | 308 preview_contents_->web_contents()->GetController().LoadURL(GURL(instant_url_), |
| 309 content::Referrer(), content::PAGE_TRANSITION_GENERATED, kInstantHeader); | 309 content::Referrer(), content::PAGE_TRANSITION_GENERATED, kInstantHeader); |
| 310 preview_contents_->web_contents()->WasHidden(); | 310 preview_contents_->web_contents()->WasHidden(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void InstantLoader::Update(const string16& user_text, bool verbatim) { | 313 void InstantLoader::Update(const string16& user_text, bool verbatim) { |
| 314 // TODO: Support real cursor position. | 314 // TODO: Support real cursor position. |
| 315 last_navigation_ = NULL; | 315 last_navigation_ = history::HistoryAddPageArgs(); |
| 316 content::RenderViewHost* rvh = | 316 content::RenderViewHost* rvh = |
| 317 preview_contents_->web_contents()->GetRenderViewHost(); | 317 preview_contents_->web_contents()->GetRenderViewHost(); |
| 318 rvh->Send(new ChromeViewMsg_SearchBoxChange(rvh->GetRoutingID(), user_text, | 318 rvh->Send(new ChromeViewMsg_SearchBoxChange(rvh->GetRoutingID(), user_text, |
| 319 verbatim, user_text.size(), user_text.size())); | 319 verbatim, user_text.size(), user_text.size())); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { | 322 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { |
| 323 content::RenderViewHost* rvh = | 323 content::RenderViewHost* rvh = |
| 324 preview_contents_->web_contents()->GetRenderViewHost(); | 324 preview_contents_->web_contents()->GetRenderViewHost(); |
| 325 rvh->Send(new ChromeViewMsg_SearchBoxResize(rvh->GetRoutingID(), bounds)); | 325 rvh->Send(new ChromeViewMsg_SearchBoxResize(rvh->GetRoutingID(), bounds)); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 content::WebContents* new_contents) { | 425 content::WebContents* new_contents) { |
| 426 DCHECK(old_contents == preview_contents_->web_contents()); | 426 DCHECK(old_contents == preview_contents_->web_contents()); |
| 427 CleanupPreviewContents(); | 427 CleanupPreviewContents(); |
| 428 // We release here without deleting so that the caller still has the | 428 // We release here without deleting so that the caller still has the |
| 429 // responsibility for deleting the TabContents. | 429 // responsibility for deleting the TabContents. |
| 430 ignore_result(preview_contents_.release()); | 430 ignore_result(preview_contents_.release()); |
| 431 preview_contents_.reset(TabContents::FromWebContents(new_contents)); | 431 preview_contents_.reset(TabContents::FromWebContents(new_contents)); |
| 432 SetupPreviewContents(); | 432 SetupPreviewContents(); |
| 433 loader_delegate_->SwappedTabContents(this); | 433 loader_delegate_->SwappedTabContents(this); |
| 434 } | 434 } |
| OLD | NEW |