| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_service.h" | 5 #include "chrome/browser/search/instant_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 InstantService::InstantService(Profile* profile) | 66 InstantService::InstantService(Profile* profile) |
| 67 : profile_(profile), | 67 : profile_(profile), |
| 68 ntp_prerenderer_(profile, this, profile->GetPrefs()), | 68 ntp_prerenderer_(profile, this, profile->GetPrefs()), |
| 69 browser_instant_controller_object_count_(0), | 69 browser_instant_controller_object_count_(0), |
| 70 weak_ptr_factory_(this) { | 70 weak_ptr_factory_(this) { |
| 71 // Stub for unit tests. | 71 // Stub for unit tests. |
| 72 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) | 72 if (!BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 73 base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) |
| 73 return; | 74 return; |
| 74 | 75 |
| 75 registrar_.Add(this, | 76 registrar_.Add(this, |
| 76 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 77 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 77 content::NotificationService::AllSources()); | 78 content::NotificationService::AllSources()); |
| 78 | 79 |
| 79 history::TopSites* top_sites = profile_->GetTopSites(); | 80 history::TopSites* top_sites = profile_->GetTopSites(); |
| 80 if (top_sites) { | 81 if (top_sites) { |
| 81 registrar_.Add(this, | 82 registrar_.Add(this, |
| 82 chrome::NOTIFICATION_TOP_SITES_CHANGED, | 83 chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // could cause that, neither of which we support. | 450 // could cause that, neither of which we support. |
| 450 return; | 451 return; |
| 451 } | 452 } |
| 452 FOR_EACH_OBSERVER( | 453 FOR_EACH_OBSERVER( |
| 453 InstantServiceObserver, observers_, DefaultSearchProviderChanged()); | 454 InstantServiceObserver, observers_, DefaultSearchProviderChanged()); |
| 454 } | 455 } |
| 455 | 456 |
| 456 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { | 457 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { |
| 457 return &ntp_prerenderer_; | 458 return &ntp_prerenderer_; |
| 458 } | 459 } |
| OLD | NEW |