| 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 "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "views/widget/widget.h" | 35 #include "views/widget/widget.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 InstantController::InstantController(Profile* profile, | 38 InstantController::InstantController(Profile* profile, |
| 39 InstantDelegate* delegate) | 39 InstantDelegate* delegate) |
| 40 : delegate_(delegate), | 40 : delegate_(delegate), |
| 41 tab_contents_(NULL), | 41 tab_contents_(NULL), |
| 42 is_active_(false), | 42 is_active_(false), |
| 43 is_displayable_(false), | 43 is_displayable_(false), |
| 44 commit_on_mouse_up_(false), | 44 commit_on_mouse_up_(false), |
| 45 last_transition_type_(PageTransition::LINK), | 45 last_transition_type_(content::PAGE_TRANSITION_LINK), |
| 46 ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) { | 46 ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) { |
| 47 PrefService* service = profile->GetPrefs(); | 47 PrefService* service = profile->GetPrefs(); |
| 48 if (service && | 48 if (service && |
| 49 InstantFieldTrial::GetGroup(profile) == InstantFieldTrial::INACTIVE) { | 49 InstantFieldTrial::GetGroup(profile) == InstantFieldTrial::INACTIVE) { |
| 50 // kInstantEnabledOnce was added after instant, set it now to make sure it | 50 // kInstantEnabledOnce was added after instant, set it now to make sure it |
| 51 // is correctly set. | 51 // is correctly set. |
| 52 service->SetBoolean(prefs::kInstantEnabledOnce, true); | 52 service->SetBoolean(prefs::kInstantEnabledOnce, true); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 delegate_->ShowInstant(loader_->preview_contents()); | 440 delegate_->ShowInstant(loader_->preview_contents()); |
| 441 NotificationService::current()->Notify( | 441 NotificationService::current()->Notify( |
| 442 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN, | 442 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN, |
| 443 Source<InstantController>(this), | 443 Source<InstantController>(this), |
| 444 NotificationService::NoDetails()); | 444 NotificationService::NoDetails()); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 void InstantController::UpdateLoader(const TemplateURL* template_url, | 448 void InstantController::UpdateLoader(const TemplateURL* template_url, |
| 449 const GURL& url, | 449 const GURL& url, |
| 450 PageTransition::Type transition_type, | 450 content::PageTransition transition_type, |
| 451 const string16& user_text, | 451 const string16& user_text, |
| 452 bool verbatim, | 452 bool verbatim, |
| 453 string16* suggested_text) { | 453 string16* suggested_text) { |
| 454 loader_->SetOmniboxBounds(omnibox_bounds_); | 454 loader_->SetOmniboxBounds(omnibox_bounds_); |
| 455 loader_->Update(tab_contents_, template_url, url, transition_type, user_text, | 455 loader_->Update(tab_contents_, template_url, url, transition_type, user_text, |
| 456 verbatim, suggested_text); | 456 verbatim, suggested_text); |
| 457 UpdateIsDisplayable(); | 457 UpdateIsDisplayable(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 bool InstantController::ShouldUseInstant(const AutocompleteMatch& match) { | 460 bool InstantController::ShouldUseInstant(const AutocompleteMatch& match) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (destroy_factory_.empty()) { | 503 if (destroy_factory_.empty()) { |
| 504 MessageLoop::current()->PostTask( | 504 MessageLoop::current()->PostTask( |
| 505 FROM_HERE, destroy_factory_.NewRunnableMethod( | 505 FROM_HERE, destroy_factory_.NewRunnableMethod( |
| 506 &InstantController::DestroyLoaders)); | 506 &InstantController::DestroyLoaders)); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 void InstantController::DestroyLoaders() { | 510 void InstantController::DestroyLoaders() { |
| 511 loaders_to_destroy_.reset(); | 511 loaders_to_destroy_.reset(); |
| 512 } | 512 } |
| OLD | NEW |