Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/search_engines/search_provider_install_state_impl.cc

Issue 2170313002: Remove OwnedInterface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove OwnedInterface Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 12 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
13 #include "chrome/common/search_provider.mojom.h" 13 #include "chrome/common/search_provider.mojom.h"
14 #include "content/public/browser/owned_interface.h"
15 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
16 #include "services/shell/public/cpp/interface_registry.h" 15 #include "services/shell/public/cpp/interface_registry.h"
17 #include "url/gurl.h" 16 #include "url/gurl.h"
18 17
19 using content::BrowserThread; 18 using content::BrowserThread;
20 19
21 SearchProviderInstallStateImpl::SearchProviderInstallStateImpl( 20 SearchProviderInstallStateImpl::SearchProviderInstallStateImpl(
22 int render_process_id, 21 int render_process_id,
23 Profile* profile) 22 Profile* profile)
24 : provider_data_(TemplateURLServiceFactory::GetForProfile(profile), 23 : provider_data_(TemplateURLServiceFactory::GetForProfile(profile),
25 UIThreadSearchTermsData(profile).GoogleBaseURLValue(), 24 UIThreadSearchTermsData(profile).GoogleBaseURLValue(),
26 GoogleURLTrackerFactory::GetForProfile(profile), 25 GoogleURLTrackerFactory::GetForProfile(profile),
27 content::RenderProcessHost::FromID(render_process_id)), 26 content::RenderProcessHost::FromID(render_process_id)),
28 is_off_the_record_(profile->IsOffTheRecord()), 27 is_off_the_record_(profile->IsOffTheRecord()),
28 binding_(this),
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 void SearchProviderInstallStateImpl::Bind( 39 // static
40 void SearchProviderInstallStateImpl::Create(
41 int render_process_id,
42 Profile* profile,
40 chrome::mojom::SearchProviderInstallStateRequest request) { 43 chrome::mojom::SearchProviderInstallStateRequest request) {
41 binding_set_.AddBinding(this, std::move(request)); 44 BrowserThread::PostTask(
45 BrowserThread::IO, FROM_HERE,
46 base::Bind(&SearchProviderInstallStateImpl::BindOnIOThread,
47 base::Unretained(new SearchProviderInstallStateImpl(
dcheng 2016/07/25 17:01:33 I would personally prefer a small comment that men
tibell 2016/07/26 00:42:03 Done.
48 render_process_id, profile)),
49 base::Passed(std::move(request))));
dcheng 2016/07/25 17:01:33 Nit: base::Passed(&request)
tibell 2016/07/26 00:42:03 Done.
50 }
51
52 void SearchProviderInstallStateImpl::BindOnIOThread(
53 chrome::mojom::SearchProviderInstallStateRequest request) {
54 binding_.Bind(std::move(request));
42 } 55 }
43 56
44 chrome::mojom::InstallState 57 chrome::mojom::InstallState
45 SearchProviderInstallStateImpl::GetSearchProviderInstallState( 58 SearchProviderInstallStateImpl::GetSearchProviderInstallState(
46 const GURL& page_location, 59 const GURL& page_location,
47 const GURL& requested_host) { 60 const GURL& requested_host) {
48 GURL requested_origin = requested_host.GetOrigin(); 61 GURL requested_origin = requested_host.GetOrigin();
49 62
50 // Do the security check before any others to avoid information leaks. 63 // Do the security check before any others to avoid information leaks.
51 if (page_location.GetOrigin() != requested_origin) 64 if (page_location.GetOrigin() != requested_origin)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 97
85 void SearchProviderInstallStateImpl::ReplyWithProviderInstallState( 98 void SearchProviderInstallStateImpl::ReplyWithProviderInstallState(
86 const GURL& page_location, 99 const GURL& page_location,
87 const GURL& requested_host, 100 const GURL& requested_host,
88 const GetInstallStateCallback& callback) { 101 const GetInstallStateCallback& callback) {
89 chrome::mojom::InstallState install_state = 102 chrome::mojom::InstallState install_state =
90 GetSearchProviderInstallState(page_location, requested_host); 103 GetSearchProviderInstallState(page_location, requested_host);
91 104
92 callback.Run(install_state); 105 callback.Run(install_state);
93 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698