| 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/extensions/api/web_navigation/web_navigation_api.h" | 8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 
| 10 #include "chrome/browser/history/history_tab_helper.h" | 10 #include "chrome/browser/history/history_tab_helper.h" | 
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 190 } | 190 } | 
| 191 | 191 | 
| 192 InstantLoader::InstantLoader(InstantController* controller, | 192 InstantLoader::InstantLoader(InstantController* controller, | 
| 193                              const std::string& instant_url) | 193                              const std::string& instant_url) | 
| 194     : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 194     : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 
| 195       controller_(controller), | 195       controller_(controller), | 
| 196       delegate_(new WebContentsDelegateImpl( | 196       delegate_(new WebContentsDelegateImpl( | 
| 197                         ALLOW_THIS_IN_INITIALIZER_LIST(this))), | 197                         ALLOW_THIS_IN_INITIALIZER_LIST(this))), | 
| 198       instant_url_(instant_url), | 198       instant_url_(instant_url), | 
| 199       supports_instant_(false), | 199       supports_instant_(false), | 
| 200       is_pointer_down_from_activate_(false) { | 200       is_pointer_down_from_activate_(false), | 
|  | 201       is_in_fallback_mode_(false) { | 
| 201 } | 202 } | 
| 202 | 203 | 
| 203 InstantLoader::~InstantLoader() { | 204 InstantLoader::~InstantLoader() { | 
| 204 } | 205 } | 
| 205 | 206 | 
| 206 void InstantLoader::InitContents(const content::WebContents* active_tab) { | 207 void InstantLoader::InitContents(const content::WebContents* active_tab) { | 
| 207   content::WebContents::CreateParams create_params( | 208   content::WebContents::CreateParams create_params( | 
| 208       active_tab->GetBrowserContext()); | 209       active_tab->GetBrowserContext()); | 
| 209   if (active_tab) | 210   if (active_tab) | 
| 210     create_params.initial_size = active_tab->GetView()->GetContainerSize(); | 211     create_params.initial_size = active_tab->GetView()->GetContainerSize(); | 
| 211   contents_.reset(content::WebContents::CreateWithSessionStorage( | 212   contents_.reset(content::WebContents::CreateWithSessionStorage( | 
| 212       create_params, | 213       create_params, | 
| 213       active_tab->GetController().GetSessionStorageNamespaceMap())); | 214       active_tab->GetController().GetSessionStorageNamespaceMap())); | 
| 214   SetupPreviewContents(); | 215   SetupPreviewContents(); | 
| 215 | 216 | 
| 216   // This HTTP header and value are set on loads that originate from Instant. | 217   // This HTTP header and value are set on loads that originate from Instant. | 
| 217   const char kInstantHeader[] = "X-Purpose: Instant"; | 218   const char kInstantHeader[] = "X-Purpose: Instant"; | 
| 218   DVLOG(1) << "LoadURL: " << instant_url_; | 219   DVLOG(1) << "LoadURL: " << instant_url_; | 
| 219   contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(), | 220   contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(), | 
| 220       content::PAGE_TRANSITION_GENERATED, kInstantHeader); | 221       content::PAGE_TRANSITION_GENERATED, kInstantHeader); | 
| 221   contents_->WasHidden(); | 222   contents_->WasHidden(); | 
| 222 } | 223 } | 
| 223 | 224 | 
| 224 content::WebContents* InstantLoader::ReleaseContents() { | 225 content::WebContents* InstantLoader::ReleaseContents() { | 
| 225   CleanupPreviewContents(); | 226   CleanupPreviewContents(); | 
| 226   return contents_.release(); | 227   return contents_.release(); | 
| 227 } | 228 } | 
| 228 | 229 | 
|  | 230 void InstantLoader::set_is_in_fallback_mode(bool value) { | 
|  | 231   is_in_fallback_mode_ = value; | 
|  | 232 } | 
|  | 233 | 
| 229 void InstantLoader::DidNavigate( | 234 void InstantLoader::DidNavigate( | 
| 230     const history::HistoryAddPageArgs& add_page_args) { | 235     const history::HistoryAddPageArgs& add_page_args) { | 
| 231   last_navigation_ = add_page_args; | 236   last_navigation_ = add_page_args; | 
| 232 } | 237 } | 
| 233 | 238 | 
| 234 bool InstantLoader::IsUsingLocalPreview() const { | 239 bool InstantLoader::IsUsingLocalPreview() const { | 
| 235   return instant_url_ == InstantController::kLocalOmniboxPopupURL; | 240   return instant_url_ == InstantController::kLocalOmniboxPopupURL; | 
| 236 } | 241 } | 
| 237 | 242 | 
| 238 void InstantLoader::Update(const string16& text, | 243 void InstantLoader::Update(const string16& text, | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 252 } | 257 } | 
| 253 | 258 | 
| 254 void InstantLoader::SetPopupBounds(const gfx::Rect& bounds) { | 259 void InstantLoader::SetPopupBounds(const gfx::Rect& bounds) { | 
| 255   client_.SetPopupBounds(bounds); | 260   client_.SetPopupBounds(bounds); | 
| 256 } | 261 } | 
| 257 | 262 | 
| 258 void InstantLoader::SetMarginSize(int start, int end) { | 263 void InstantLoader::SetMarginSize(int start, int end) { | 
| 259   client_.SetMarginSize(start, end); | 264   client_.SetMarginSize(start, end); | 
| 260 } | 265 } | 
| 261 | 266 | 
|  | 267 void InstantLoader::InitializeFonts() { | 
|  | 268   client_.InitializeFonts(); | 
|  | 269 } | 
|  | 270 | 
| 262 void InstantLoader::SendAutocompleteResults( | 271 void InstantLoader::SendAutocompleteResults( | 
| 263     const std::vector<InstantAutocompleteResult>& results) { | 272     const std::vector<InstantAutocompleteResult>& results) { | 
| 264   client_.SendAutocompleteResults(results); | 273   client_.SendAutocompleteResults(results); | 
| 265 } | 274 } | 
| 266 | 275 | 
| 267 void InstantLoader::UpOrDownKeyPressed(int count) { | 276 void InstantLoader::UpOrDownKeyPressed(int count) { | 
| 268   client_.UpOrDownKeyPressed(count); | 277   client_.UpOrDownKeyPressed(count); | 
| 269 } | 278 } | 
| 270 | 279 | 
| 271 void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) { | 280 void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) { | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 430                                            content::WebContents* new_contents) { | 439                                            content::WebContents* new_contents) { | 
| 431   DCHECK_EQ(old_contents, contents()); | 440   DCHECK_EQ(old_contents, contents()); | 
| 432   CleanupPreviewContents(); | 441   CleanupPreviewContents(); | 
| 433   // We release here without deleting so that the caller still has the | 442   // We release here without deleting so that the caller still has the | 
| 434   // responsibility for deleting the WebContents. | 443   // responsibility for deleting the WebContents. | 
| 435   ignore_result(contents_.release()); | 444   ignore_result(contents_.release()); | 
| 436   contents_.reset(new_contents); | 445   contents_.reset(new_contents); | 
| 437   SetupPreviewContents(); | 446   SetupPreviewContents(); | 
| 438   controller_->SwappedWebContents(); | 447   controller_->SwappedWebContents(); | 
| 439 } | 448 } | 
| OLD | NEW | 
|---|