Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/search/new_tab_page_interceptor_service.h" | |
| 6 | |
| 7 #include "chrome/browser/profiles/profile.h" | |
| 8 #include "chrome/browser/search/search.h" | |
| 9 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 10 #include "chrome/browser/ui/search/new_tab_page_interceptor.h" | |
| 11 #include "components/search_engines/template_url_service.h" | |
| 12 #include "content/public/browser/browser_thread.h" | |
| 13 | |
| 14 NewTabPageInterceptorService::NewTabPageInterceptorService(Profile* profile) | |
| 15 : profile_(profile), | |
| 16 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { | |
| 17 DCHECK(profile_); | |
| 18 if (template_url_service_) | |
| 19 template_url_service_->AddObserver(this); | |
| 20 } | |
| 21 | |
| 22 NewTabPageInterceptorService::~NewTabPageInterceptorService() { | |
| 23 if (template_url_service_) | |
| 24 template_url_service_->RemoveObserver(this); | |
| 25 } | |
| 26 | |
| 27 void NewTabPageInterceptorService::OnTemplateURLServiceChanged() { | |
| 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
|
Mathieu
2015/01/21 21:29:39
kmadhusu@: Do you think it's worth replicating the
kmadhusu
2015/01/22 20:06:30
I looked at the latest patch. These changes seems
kmadhusu
2015/01/23 00:59:32
Tested the latest patch. NTP interceptor works as
| |
| 29 GURL new_tab_page_url(chrome::GetNewTabPageURL(profile_)); | |
| 30 content::BrowserThread::PostTask( | |
| 31 content::BrowserThread::IO, FROM_HERE, | |
| 32 base::Bind(&NewTabPageInterceptor::SetNewTabPageURL, interceptor_, | |
| 33 new_tab_page_url)); | |
| 34 } | |
| 35 | |
| 36 scoped_ptr<net::URLRequestInterceptor> | |
| 37 NewTabPageInterceptorService::CreateInterceptor() { | |
| 38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 39 scoped_ptr<NewTabPageInterceptor> interceptor( | |
| 40 new NewTabPageInterceptor(chrome::GetNewTabPageURL(profile_))); | |
| 41 interceptor_ = interceptor->GetWeakPtr(); | |
| 42 return interceptor.Pass(); | |
| 43 } | |
| OLD | NEW |