| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 12 #include "components/search_engines/template_url_service_observer.h" | 13 #include "components/search_engines/template_url_service_observer.h" |
| 13 | 14 |
| 14 class NewTabPageInterceptor; | 15 class NewTabPageInterceptor; |
| 15 class Profile; | 16 class Profile; |
| 16 class TemplateURLService; | 17 class TemplateURLService; |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 class URLRequestInterceptor; | 20 class URLRequestInterceptor; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // Owns a NewTabPageInterceptor. | 23 // Owns a NewTabPageInterceptor. |
| 23 class NewTabPageInterceptorService : public KeyedService, | 24 class NewTabPageInterceptorService : public KeyedService, |
| 24 public TemplateURLServiceObserver { | 25 public TemplateURLServiceObserver { |
| 25 public: | 26 public: |
| 26 explicit NewTabPageInterceptorService(Profile* profile); | 27 explicit NewTabPageInterceptorService(Profile* profile); |
| 27 ~NewTabPageInterceptorService() override; | 28 ~NewTabPageInterceptorService() override; |
| 28 | 29 |
| 29 // TemplateURLServiceObserver override. | 30 // TemplateURLServiceObserver override. |
| 30 void OnTemplateURLServiceChanged() override; | 31 void OnTemplateURLServiceChanged() override; |
| 31 | 32 |
| 32 scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); | 33 std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor(); |
| 33 | 34 |
| 34 private: | 35 private: |
| 35 Profile* profile_; | 36 Profile* profile_; |
| 36 base::WeakPtr<NewTabPageInterceptor> interceptor_; | 37 base::WeakPtr<NewTabPageInterceptor> interceptor_; |
| 37 // The TemplateURLService that we are observing. It will outlive this | 38 // The TemplateURLService that we are observing. It will outlive this |
| 38 // NewTabPageInterceptorService due to the dependency declared in | 39 // NewTabPageInterceptorService due to the dependency declared in |
| 39 // NewTabPageInterceptorServiceFactory. | 40 // NewTabPageInterceptorServiceFactory. |
| 40 TemplateURLService* template_url_service_; | 41 TemplateURLService* template_url_service_; |
| 41 | 42 |
| 42 DISALLOW_COPY_AND_ASSIGN(NewTabPageInterceptorService); | 43 DISALLOW_COPY_AND_ASSIGN(NewTabPageInterceptorService); |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 #endif // CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ | 46 #endif // CHROME_BROWSER_UI_SEARCH_NEW_TAB_PAGE_INTERCEPTOR_SERVICE_H_ |
| OLD | NEW |