| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_engines/search_provider_install_state_impl.h" | 5 #include "chrome/browser/search_engines/search_provider_install_state_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/google/google_url_tracker_factory.h" | 9 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 weak_factory_(this) { | 29 weak_factory_(this) { |
| 30 // This is initialized by RenderProcessHostImpl. Do not add any non-trivial | 30 // This is initialized by RenderProcessHostImpl. Do not add any non-trivial |
| 31 // initialization here. Instead do it lazily when required. | 31 // initialization here. Instead do it lazily when required. |
| 32 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 32 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SearchProviderInstallStateImpl::~SearchProviderInstallStateImpl() { | 35 SearchProviderInstallStateImpl::~SearchProviderInstallStateImpl() { |
| 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Register the given interface impl. The impl is owned by the host. Messages | |
| 40 // will be dispatched on |task_runner| (or on the default task runner if not | |
| 41 // given). The impl will also be deleted on |task_runner|. | |
| 42 template <typename InterfaceImpl> | |
| 43 void InstallService2( | |
| 44 content::RenderProcessHost* host, | |
| 45 std::unique_ptr<InterfaceImpl> impl, | |
| 46 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr) { | |
| 47 host->AddOwnedInterface(std::move(impl), task_runner); | |
| 48 } | |
| 49 | |
| 50 void SearchProviderInstallStateImpl::Bind( | 39 void SearchProviderInstallStateImpl::Bind( |
| 51 chrome::mojom::SearchProviderInstallStateRequest request) { | 40 chrome::mojom::SearchProviderInstallStateRequest request) { |
| 52 binding_set_.AddBinding(this, std::move(request)); | 41 binding_set_.AddBinding(this, std::move(request)); |
| 53 } | 42 } |
| 54 | 43 |
| 55 chrome::mojom::InstallState | 44 chrome::mojom::InstallState |
| 56 SearchProviderInstallStateImpl::GetSearchProviderInstallState( | 45 SearchProviderInstallStateImpl::GetSearchProviderInstallState( |
| 57 const GURL& page_location, | 46 const GURL& page_location, |
| 58 const GURL& requested_host) { | 47 const GURL& requested_host) { |
| 59 GURL requested_origin = requested_host.GetOrigin(); | 48 GURL requested_origin = requested_host.GetOrigin(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 84 |
| 96 void SearchProviderInstallStateImpl::ReplyWithProviderInstallState( | 85 void SearchProviderInstallStateImpl::ReplyWithProviderInstallState( |
| 97 const GURL& page_location, | 86 const GURL& page_location, |
| 98 const GURL& requested_host, | 87 const GURL& requested_host, |
| 99 const GetInstallStateCallback& callback) { | 88 const GetInstallStateCallback& callback) { |
| 100 chrome::mojom::InstallState install_state = | 89 chrome::mojom::InstallState install_state = |
| 101 GetSearchProviderInstallState(page_location, requested_host); | 90 GetSearchProviderInstallState(page_location, requested_host); |
| 102 | 91 |
| 103 callback.Run(install_state); | 92 callback.Run(install_state); |
| 104 } | 93 } |
| OLD | NEW |