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

Unified Diff: chrome/browser/search_engines/search_provider_install_state_impl.cc

Issue 2177123003: Move SearchProvider implementation into Blink and make it a no-op. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/search_provider_install_state_impl.cc
diff --git a/chrome/browser/search_engines/search_provider_install_state_impl.cc b/chrome/browser/search_engines/search_provider_install_state_impl.cc
deleted file mode 100644
index f6061ccdee6c1f1832a6888f183bb9d5e0aa0b1d..0000000000000000000000000000000000000000
--- a/chrome/browser/search_engines/search_provider_install_state_impl.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/search_engines/search_provider_install_state_impl.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "chrome/browser/google/google_url_tracker_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
-#include "chrome/common/search_provider.mojom.h"
-#include "content/public/browser/render_process_host.h"
-#include "services/shell/public/cpp/interface_registry.h"
-#include "url/gurl.h"
-
-using content::BrowserThread;
-
-SearchProviderInstallStateImpl::SearchProviderInstallStateImpl(
- int render_process_id,
- Profile* profile)
- : provider_data_(TemplateURLServiceFactory::GetForProfile(profile),
- UIThreadSearchTermsData(profile).GoogleBaseURLValue(),
- GoogleURLTrackerFactory::GetForProfile(profile),
- content::RenderProcessHost::FromID(render_process_id)),
- is_off_the_record_(profile->IsOffTheRecord()),
- binding_(this),
- weak_factory_(this) {
- // This is initialized by RenderProcessHostImpl. Do not add any non-trivial
- // initialization here. Instead do it lazily when required.
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-}
-
-SearchProviderInstallStateImpl::~SearchProviderInstallStateImpl() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-}
-
-// static
-void SearchProviderInstallStateImpl::Create(
- int render_process_id,
- Profile* profile,
- chrome::mojom::SearchProviderInstallStateRequest request) {
- // BindOnIOThread takes ownership on the impl object:
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&SearchProviderInstallStateImpl::BindOnIOThread,
- base::Unretained(new SearchProviderInstallStateImpl(
- render_process_id, profile)),
- base::Passed(&request)));
-}
-
-void SearchProviderInstallStateImpl::BindOnIOThread(
- chrome::mojom::SearchProviderInstallStateRequest request) {
- binding_.Bind(std::move(request));
-}
-
-chrome::mojom::InstallState
-SearchProviderInstallStateImpl::GetSearchProviderInstallState(
- const GURL& page_location,
- const GURL& requested_host) {
- GURL requested_origin = requested_host.GetOrigin();
-
- // Do the security check before any others to avoid information leaks.
- if (page_location.GetOrigin() != requested_origin)
- return chrome::mojom::InstallState::DENIED;
-
- // In incognito mode, no search information is exposed. (This check must be
- // done after the security check or else a web site can detect that the
- // user is in incognito mode just by doing a cross origin request.)
- if (is_off_the_record_)
- return chrome::mojom::InstallState::NOT_INSTALLED;
-
- switch (provider_data_.GetInstallState(requested_origin)) {
- case SearchProviderInstallData::NOT_INSTALLED:
- return chrome::mojom::InstallState::NOT_INSTALLED;
-
- case SearchProviderInstallData::INSTALLED_BUT_NOT_DEFAULT:
- return chrome::mojom::InstallState::INSTALLED_BUT_NOT_DEFAULT;
-
- case SearchProviderInstallData::INSTALLED_AS_DEFAULT:
- return chrome::mojom::InstallState::INSTALLED_AS_DEFAULT;
- }
-
- NOTREACHED();
- return chrome::mojom::InstallState::NOT_INSTALLED;
-}
-
-void SearchProviderInstallStateImpl::GetInstallState(
- const GURL& page_location,
- const GURL& requested_host,
- const GetInstallStateCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- provider_data_.CallWhenLoaded(base::Bind(
- &SearchProviderInstallStateImpl::ReplyWithProviderInstallState,
- weak_factory_.GetWeakPtr(), page_location, requested_host, callback));
-}
-
-void SearchProviderInstallStateImpl::ReplyWithProviderInstallState(
- const GURL& page_location,
- const GURL& requested_host,
- const GetInstallStateCallback& callback) {
- chrome::mojom::InstallState install_state =
- GetSearchProviderInstallState(page_location, requested_host);
-
- callback.Run(install_state);
-}

Powered by Google App Engine
This is Rietveld 408576698