| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 12 #include "chrome/browser/instant/instant_delegate.h" | 12 #include "chrome/browser/instant/instant_delegate.h" |
| 13 #include "chrome/browser/instant/instant_loader.h" | 13 #include "chrome/browser/instant/instant_loader.h" |
| 14 #include "chrome/browser/instant/instant_loader_manager.h" | 14 #include "chrome/browser/instant/instant_loader_manager.h" |
| 15 #include "chrome/browser/instant/promo_counter.h" | 15 #include "chrome/browser/instant/promo_counter.h" |
| 16 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/search_engines/template_url.h" | 19 #include "chrome/browser/search_engines/template_url.h" |
| 20 #include "chrome/browser/search_engines/template_url_model.h" | 20 #include "chrome/browser/search_engines/template_url_model.h" |
| 21 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 25 #include "content/browser/renderer_host/render_widget_host_view.h" | 26 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 26 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 27 #include "content/common/notification_service.h" | 28 #include "content/common/notification_service.h" |
| 28 | 29 |
| 29 // Number of ms to delay between loading urls. | 30 // Number of ms to delay between loading urls. |
| 30 static const int kUpdateDelayMS = 200; | 31 static const int kUpdateDelayMS = 200; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // If the loader was showing an instant page then it's navigation stack is | 254 // If the loader was showing an instant page then it's navigation stack is |
| 254 // something like: search-engine-home-page (eg google.com) search-term1 | 255 // something like: search-engine-home-page (eg google.com) search-term1 |
| 255 // search-term2 .... Each search-term navigation corresponds to the page | 256 // search-term2 .... Each search-term navigation corresponds to the page |
| 256 // deciding enough time has passed to commit a navigation. We don't want the | 257 // deciding enough time has passed to commit a navigation. We don't want the |
| 257 // searche-engine-home-page navigation in this case so we pass true to | 258 // searche-engine-home-page navigation in this case so we pass true to |
| 258 // CopyStateFromAndPrune to have the search-engine-home-page navigation | 259 // CopyStateFromAndPrune to have the search-engine-home-page navigation |
| 259 // removed. | 260 // removed. |
| 260 tab->controller().CopyStateFromAndPrune( | 261 tab->controller().CopyStateFromAndPrune( |
| 261 &tab_contents_->controller(), showing_instant); | 262 &tab_contents_->controller(), showing_instant); |
| 262 delegate_->CommitInstant(tab); | 263 delegate_->CommitInstant(tab); |
| 263 CompleteRelease(tab->tab_contents()); | 264 CompleteRelease(tab); |
| 264 } | 265 } |
| 265 | 266 |
| 266 void InstantController::SetCommitOnMouseUp() { | 267 void InstantController::SetCommitOnMouseUp() { |
| 267 commit_on_mouse_up_ = true; | 268 commit_on_mouse_up_ = true; |
| 268 } | 269 } |
| 269 | 270 |
| 270 bool InstantController::IsMouseDownFromActivate() { | 271 bool InstantController::IsMouseDownFromActivate() { |
| 271 DCHECK(loader_manager_.get()); | 272 DCHECK(loader_manager_.get()); |
| 272 DCHECK(loader_manager_->current_loader()); | 273 DCHECK(loader_manager_->current_loader()); |
| 273 return loader_manager_->current_loader()->IsMouseDownFromActivate(); | 274 return loader_manager_->current_loader()->IsMouseDownFromActivate(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 is_active_ = false; | 376 is_active_ = false; |
| 376 displayable_loader_ = NULL; | 377 displayable_loader_ = NULL; |
| 377 commit_on_mouse_up_ = false; | 378 commit_on_mouse_up_ = false; |
| 378 omnibox_bounds_ = gfx::Rect(); | 379 omnibox_bounds_ = gfx::Rect(); |
| 379 loader_manager_.reset(); | 380 loader_manager_.reset(); |
| 380 update_timer_.Stop(); | 381 update_timer_.Stop(); |
| 381 show_timer_.Stop(); | 382 show_timer_.Stop(); |
| 382 return tab; | 383 return tab; |
| 383 } | 384 } |
| 384 | 385 |
| 385 void InstantController::CompleteRelease(TabContents* tab) { | 386 void InstantController::CompleteRelease(TabContentsWrapper* tab) { |
| 386 tab->SetAllContentsBlocked(false); | 387 tab->blocked_content_tab_helper()->SetAllContentsBlocked(false); |
| 387 } | 388 } |
| 388 | 389 |
| 389 TabContentsWrapper* InstantController::GetPreviewContents() { | 390 TabContentsWrapper* InstantController::GetPreviewContents() { |
| 390 return loader_manager_.get() && loader_manager_->current_loader() ? | 391 return loader_manager_.get() && loader_manager_->current_loader() ? |
| 391 loader_manager_->current_loader()->preview_contents() : NULL; | 392 loader_manager_->current_loader()->preview_contents() : NULL; |
| 392 } | 393 } |
| 393 | 394 |
| 394 bool InstantController::IsShowingInstant() { | 395 bool InstantController::IsShowingInstant() { |
| 395 return loader_manager_.get() && loader_manager_->current_loader() && | 396 return loader_manager_.get() && loader_manager_->current_loader() && |
| 396 loader_manager_->current_loader()->is_showing_instant(); | 397 loader_manager_->current_loader()->is_showing_instant(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 const AutocompleteMatch& match) { | 677 const AutocompleteMatch& match) { |
| 677 const TemplateURL* template_url = match.template_url; | 678 const TemplateURL* template_url = match.template_url; |
| 678 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || | 679 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || |
| 679 match.type == AutocompleteMatch::SEARCH_HISTORY || | 680 match.type == AutocompleteMatch::SEARCH_HISTORY || |
| 680 match.type == AutocompleteMatch::SEARCH_SUGGEST) { | 681 match.type == AutocompleteMatch::SEARCH_SUGGEST) { |
| 681 TemplateURLModel* model = tab_contents_->profile()->GetTemplateURLModel(); | 682 TemplateURLModel* model = tab_contents_->profile()->GetTemplateURLModel(); |
| 682 template_url = model ? model->GetDefaultSearchProvider() : NULL; | 683 template_url = model ? model->GetDefaultSearchProvider() : NULL; |
| 683 } | 684 } |
| 684 return template_url; | 685 return template_url; |
| 685 } | 686 } |
| OLD | NEW |