Commit 9028a6ad authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup: Remove Android-specific #ifdef's etc from search/instant code

As of https://crrev.com/c/790511, this code isn't built on Android
anymore.
This also adds compile-time checks to many Instant headers to make sure
they're not accidentally built on Android.

Bug: 787830
Change-Id: I88026ce703158ac5b1580f02e621dea325a6fd64
Reviewed-on: https://chromium-review.googlesource.com/803280
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarChris Pickel <sfiera@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522101}
parent 13c92a34
......@@ -4042,7 +4042,7 @@ split_static_library("browser") {
]
}
if (!is_chrome_branded) {
if (!is_chrome_branded && !is_android) {
sources += [
"search/local_files_ntp_source.cc",
"search/local_files_ntp_source.h",
......
......@@ -6,8 +6,13 @@
#define CHROME_BROWSER_SEARCH_IFRAME_SOURCE_H_
#include "base/macros.h"
#include "build/build_config.h"
#include "content/public/browser/url_data_source.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
// Base class for URL data sources for chrome-search:// iframed content.
// TODO(treib): This has only one subclass outside of tests,
// MostVisitedIframeSource. Merge the two classes?
......
......@@ -30,13 +30,10 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/search/local_ntp_source.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#endif
InstantService::InstantService(Profile* profile) : profile_(profile) {
// The initialization below depends on a typical set of browser threads. Skip
......@@ -66,22 +63,17 @@ InstantService::InstantService(Profile* profile) : profile_(profile) {
profile->GetResourceContext(), instant_io_context_));
}
// Set up the data sources that Instant uses on the NTP.
// TODO(aurimas) remove this #if once instant_service.cc is no longer compiled
// on Android.
#if !defined(OS_ANDROID)
// Listen for theme installation.
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(profile_)));
// Set up the data sources that Instant uses on the NTP.
content::URLDataSource::Add(profile_, new ThemeSource(profile_));
content::URLDataSource::Add(profile_, new LocalNtpSource(profile_));
content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false));
content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true));
content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_));
#endif // !defined(OS_ANDROID)
content::URLDataSource::Add(profile_, new FaviconSource(profile_));
content::URLDataSource::Add(profile_, new MostVisitedIframeSource());
}
......@@ -136,13 +128,11 @@ void InstantService::UndoAllMostVisitedDeletions() {
}
void InstantService::UpdateThemeInfo() {
#if !defined(OS_ANDROID)
// Initialize |theme_info_| if necessary.
if (!theme_info_) {
BuildThemeInfo();
}
NotifyAboutThemeInfo();
#endif // !defined(OS_ANDROID)
}
void InstantService::UpdateMostVisitedItemsInfo() {
......@@ -187,12 +177,10 @@ void InstantService::Observe(int type,
OnRendererProcessTerminated(
content::Source<content::RenderProcessHost>(source)->GetID());
break;
#if !defined(OS_ANDROID)
case chrome::NOTIFICATION_BROWSER_THEME_CHANGED:
BuildThemeInfo();
NotifyAboutThemeInfo();
break;
#endif // !defined(OS_ANDROID)
default:
NOTREACHED() << "Unexpected notification type in InstantService.";
}
......@@ -244,8 +232,6 @@ void InstantService::NotifyAboutThemeInfo() {
observer.ThemeInfoChanged(*theme_info_);
}
#if !defined(OS_ANDROID)
namespace {
const int kSectionBorderAlphaTransparency = 80;
......@@ -360,4 +346,3 @@ void InstantService::BuildThemeInfo() {
theme_provider.HasCustomImage(IDR_THEME_NTP_ATTRIBUTION);
}
}
#endif // !defined(OS_ANDROID)
......@@ -24,6 +24,10 @@
#include "content/public/browser/notification_registrar.h"
#include "url/gurl.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
class InstantIOContext;
class InstantServiceObserver;
class Profile;
......@@ -113,9 +117,7 @@ class InstantService : public KeyedService,
void NotifyAboutMostVisitedItems();
void NotifyAboutThemeInfo();
#if !defined(OS_ANDROID)
void BuildThemeInfo();
#endif
Profile* const profile_;
......
......@@ -4,7 +4,6 @@
#include "chrome/browser/search/instant_service_factory.h"
#include "build/build_config.h"
#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
......@@ -17,8 +16,7 @@
// static
InstantService* InstantServiceFactory::GetForProfile(Profile* profile) {
if (!search::IsInstantExtendedAPIEnabled())
return NULL;
DCHECK(search::IsInstantExtendedAPIEnabled());
return static_cast<InstantService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
......@@ -35,14 +33,11 @@ InstantServiceFactory::InstantServiceFactory()
BrowserContextDependencyManager::GetInstance()) {
DependsOn(suggestions::SuggestionsServiceFactory::GetInstance());
DependsOn(TemplateURLServiceFactory::GetInstance());
#if !defined(OS_ANDROID)
DependsOn(ThemeServiceFactory::GetInstance());
#endif
DependsOn(TopSitesFactory::GetInstance());
}
InstantServiceFactory::~InstantServiceFactory() {
}
InstantServiceFactory::~InstantServiceFactory() = default;
content::BrowserContext* InstantServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
......@@ -50,8 +45,7 @@ content::BrowserContext* InstantServiceFactory::GetBrowserContextToUse(
}
KeyedService* InstantServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return search::IsInstantExtendedAPIEnabled()
? new InstantService(static_cast<Profile*>(profile))
: NULL;
content::BrowserContext* context) const {
DCHECK(search::IsInstantExtendedAPIEnabled());
return new InstantService(Profile::FromBrowserContext(context));
}
......@@ -5,11 +5,15 @@
#ifndef CHROME_BROWSER_SEARCH_INSTANT_SERVICE_FACTORY_H_
#define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_FACTORY_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
class InstantService;
class Profile;
......@@ -31,7 +35,7 @@ class InstantServiceFactory : public BrowserContextKeyedServiceFactory {
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override;
content::BrowserContext* context) const override;
DISALLOW_COPY_AND_ASSIGN(InstantServiceFactory);
};
......
......@@ -7,6 +7,12 @@
#include <vector>
#include "build/build_config.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
struct InstantMostVisitedItem;
struct ThemeBackgroundInfo;
......
......@@ -6,9 +6,14 @@
#define CHROME_BROWSER_SEARCH_LOCAL_FILES_NTP_SOURCE_H_
#include <string>
#include "build/build_config.h"
#include "content/public/browser/url_data_source.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
#if !defined(GOOGLE_CHROME_BUILD)
namespace local_ntp {
......
......@@ -14,9 +14,14 @@
#include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h"
#include "content/public/browser/url_data_source.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
struct OneGoogleBarData;
class OneGoogleBarService;
class Profile;
......
......@@ -6,8 +6,13 @@
#define CHROME_BROWSER_SEARCH_MOST_VISITED_IFRAME_SOURCE_H_
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/search/iframe_source.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
// Serves HTML for displaying suggestions using iframes, e.g.
// chrome-search://most-visited/single.html
class MostVisitedIframeSource : public IframeSource {
......
......@@ -9,9 +9,14 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/search/search_engine_base_url_tracker.h"
#include "chrome/browser/ui/search/instant_controller.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
class Browser;
class Profile;
......
......@@ -10,8 +10,13 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "build/build_config.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
class Profile;
class TabStripModel;
......
......@@ -13,11 +13,16 @@
#include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/common/search/ntp_logging_events.h"
#include "components/ntp_tiles/ntp_tile_impression.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
namespace content {
class WebContents;
}
......
......@@ -12,6 +12,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/common/search.mojom.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/search/ntp_logging_events.h"
......@@ -20,6 +21,10 @@
#include "content/public/browser/web_contents_binding_set.h"
#include "content/public/browser/web_contents_observer.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
class GURL;
namespace content {
......
......@@ -6,8 +6,13 @@
#define CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_POLICY_IMPL_H_
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/ui/search/search_ipc_router.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
namespace content {
class WebContents;
}
......
......@@ -112,8 +112,7 @@ SearchTabHelper::SearchTabHelper(content::WebContents* web_contents)
this,
base::MakeUnique<SearchIPCRouterPolicyImpl>(web_contents)),
instant_service_(nullptr) {
if (!search::IsInstantExtendedAPIEnabled())
return;
DCHECK(search::IsInstantExtendedAPIEnabled());
instant_service_ = InstantServiceFactory::GetForProfile(profile());
if (instant_service_)
......@@ -126,9 +125,6 @@ SearchTabHelper::~SearchTabHelper() {
}
void SearchTabHelper::OmniboxInputStateChanged() {
if (!search::IsInstantExtendedAPIEnabled())
return;
ipc_router_.SetInputInProgress(IsInputInProgress());
}
......@@ -258,9 +254,6 @@ void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host,
void SearchTabHelper::NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) {
if (!search::IsInstantExtendedAPIEnabled())
return;
if (!load_details.is_main_frame)
return;
......@@ -281,8 +274,6 @@ void SearchTabHelper::MostVisitedItemsChanged(
}
void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
OmniboxView* omnibox_view = GetOmniboxView();
if (!omnibox_view)
return;
......@@ -318,7 +309,6 @@ void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) {
web_contents()->Focus();
break;
}
#endif
}
void SearchTabHelper::OnDeleteMostVisitedItem(const GURL& url) {
......@@ -340,34 +330,23 @@ void SearchTabHelper::OnUndoAllMostVisitedDeletions() {
void SearchTabHelper::OnLogEvent(NTPLoggingEventType event,
base::TimeDelta time) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
NTPUserDataLogger::GetOrCreateFromWebContents(web_contents())
->LogEvent(event, time);
#endif
}
void SearchTabHelper::OnLogMostVisitedImpression(
const ntp_tiles::NTPTileImpression& impression) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
NTPUserDataLogger::GetOrCreateFromWebContents(web_contents())
->LogMostVisitedImpression(impression);
#endif
}
void SearchTabHelper::OnLogMostVisitedNavigation(
const ntp_tiles::NTPTileImpression& impression) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
NTPUserDataLogger::GetOrCreateFromWebContents(web_contents())
->LogMostVisitedNavigation(impression);
#endif
}
void SearchTabHelper::PasteIntoOmnibox(const base::string16& text) {
// TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef.
#if !defined(OS_ANDROID)
OmniboxView* omnibox_view = GetOmniboxView();
if (!omnibox_view)
return;
......@@ -389,7 +368,6 @@ void SearchTabHelper::PasteIntoOmnibox(const base::string16& text) {
omnibox_view->model()->OnPaste();
omnibox_view->SetUserText(text_to_paste);
omnibox_view->OnAfterPossibleChange(true);
#endif
}
bool SearchTabHelper::ChromeIdentityCheck(const base::string16& identity) {
......@@ -404,15 +382,11 @@ bool SearchTabHelper::HistorySyncCheck() {
}
const OmniboxView* SearchTabHelper::GetOmniboxView() const {
#if defined(OS_ANDROID)
return nullptr;
#else
Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
if (!browser)
return nullptr;
return browser->window()->GetLocationBar()->GetOmniboxView();
#endif // OS_ANDROID
}
OmniboxView* SearchTabHelper::GetOmniboxView() {
......
......@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/search/instant_service_observer.h"
#include "chrome/browser/ui/search/search_ipc_router.h"
#include "chrome/common/search/instant_types.h"
......@@ -21,6 +22,10 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#if defined(OS_ANDROID)
#error "Instant is only used on desktop";
#endif
namespace content {
class WebContents;
struct LoadCommittedDetails;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment