Skip to content

Commit

Permalink
refactor to remove brave/browser and chrome/browser dependencies outs…
Browse files Browse the repository at this point in the history
…ide of ViewCounterServiceFactory
  • Loading branch information
bridiver authored and petemill committed Jan 27, 2020
1 parent 5cad9f5 commit 278fb27
Show file tree
Hide file tree
Showing 46 changed files with 772 additions and 654 deletions.
7 changes: 7 additions & 0 deletions browser/brave_browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "brave/browser/tor/buildflags.h"
#include "brave/browser/ui/brave_browser_command_controller.h"
#include "brave/common/pref_names.h"
#include "brave/components/brave_component_updater/browser/brave_on_demand_updater.h"
#include "brave/components/brave_component_updater/browser/local_data_files_service.h"
#include "brave/components/brave_shields/browser/ad_block_custom_filters_service.h"
#include "brave/components/brave_shields/browser/ad_block_regional_service_manager.h"
Expand All @@ -34,6 +35,7 @@
#include "brave/components/p3a/brave_p3a_service.h"
#include "brave/services/network/public/cpp/system_request_handler.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/webui/components_ui.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_paths.h"
#include "components/component_updater/component_updater_service.h"
Expand Down Expand Up @@ -75,6 +77,8 @@
#include "chrome/browser/ui/browser.h"
#endif

using ntp_sponsored_images::NTPSponsoredImagesService;

namespace {

// Initializes callback for SystemRequestHandler
Expand Down Expand Up @@ -128,6 +132,9 @@ BraveBrowserProcessImpl::BraveBrowserProcessImpl(StartupData* startup_data)
void BraveBrowserProcessImpl::Init() {
BrowserProcessImpl::Init();

brave_component_updater::BraveOnDemandUpdater::GetInstance()->
RegisterOnDemandUpdateCallback(
base::BindRepeating(&ComponentsUI::OnDemandUpdate));
UpdateBraveDarkMode();
pref_change_registrar_.Add(
kBraveDarkMode,
Expand Down
7 changes: 5 additions & 2 deletions browser/brave_browser_process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ class ReferrerWhitelistService;
class TrackingProtectionService;
} // namespace brave_shields

class NTPSponsoredImagesService;

namespace greaselion {
#if BUILDFLAG(ENABLE_GREASELION)
class GreaselionDownloadService;
#endif
} // namespace greaselion

namespace ntp_sponsored_images {
class NTPSponsoredImagesService;
} // namespace ntp_sponsored_images

namespace extensions {
class BraveTorClientUpdater;
}

using brave_component_updater::BraveComponent;
using ntp_sponsored_images::NTPSponsoredImagesService;

class BraveBrowserProcessImpl : public BrowserProcessImpl {
public:
Expand Down
5 changes: 2 additions & 3 deletions browser/browser_context_keyed_service_factories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "brave/components/brave_ads/browser/ads_service_factory.h"
#include "brave/components/brave_rewards/browser/rewards_service_factory.h"
#include "brave/components/greaselion/browser/buildflags/buildflags.h"
#include "brave/browser/ntp_sponsored_images/new_tab_page_branded_view_counter.h"
#include "brave/browser/ntp_sponsored_images/view_counter_service_factory.h"

#if BUILDFLAG(ENABLE_GREASELION)
#include "brave/browser/greaselion/greaselion_service_factory.h"
Expand All @@ -34,8 +34,7 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
#endif
TorProfileServiceFactory::GetInstance();
SearchEngineProviderServiceFactory::GetInstance();
NewTabPageBrandedViewCounter::
EnsureBrowserContextKeyedServiceFactoriesBuilt();
ntp_sponsored_images::ViewCounterServiceFactory::GetInstance();

#if !defined(OS_ANDROID)
BookmarkPrefsServiceFactory::GetInstance();
Expand Down
5 changes: 3 additions & 2 deletions browser/component_updater/brave_component_updater_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#include "base/sequenced_task_runner.h"
#include "base/task/post_task.h"
#include "brave/browser/component_updater/brave_component_installer.h"
#include "chrome/browser/ui/webui/components_ui.h"
#include "brave/components/brave_component_updater/browser/brave_on_demand_updater.h"
#include "chrome/browser/browser_process.h"
#include "components/component_updater/component_updater_service.h"

using brave_component_updater::BraveComponent;
using brave_component_updater::BraveOnDemandUpdater;

namespace brave {

Expand Down Expand Up @@ -46,7 +47,7 @@ bool BraveComponentUpdaterDelegate::Unregister(

void BraveComponentUpdaterDelegate::OnDemandUpdate(
const std::string& component_id) {
ComponentsUI::OnDemandUpdate(component_id);
BraveOnDemandUpdater::GetInstance()->OnDemandUpdate(component_id);
}

scoped_refptr<base::SequencedTaskRunner>
Expand Down
14 changes: 6 additions & 8 deletions browser/ntp_sponsored_images/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
source_set("ntp_sponsored_images") {
sources = [
"new_tab_page_branded_view_counter.cc",
"new_tab_page_branded_view_counter.h",
"view_counter_model.cc",
"view_counter_model.h",
"view_counter_service_factory.cc",
"view_counter_service_factory.h",
]

deps = [
"//base",
"//components/keyed_service/core",
"//components/prefs",
"//components/pref_registry",
"//brave/components/brave_rewards/browser",
"//brave/components/ntp_sponsored_images/browser",
"//brave/common",
"//brave/components/brave_ads/browser",
"//chrome/common",
"//content/public/browser",
"//components/keyed_service/content",
"//components/prefs",
"//components/pref_registry",
]
}
231 changes: 0 additions & 231 deletions browser/ntp_sponsored_images/new_tab_page_branded_view_counter.cc

This file was deleted.

Loading

0 comments on commit 278fb27

Please sign in to comment.