Unwind the URL-based experiment IDs.
[chromium-blink-merge.git] / chrome / browser / dom_distiller / profile_utils.cc
blob1892289d7981ac1def88de18c25a558e4dcebf58
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/dom_distiller/profile_utils.h"
7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
10 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
14 #include "components/dom_distiller/core/external_feedback_reporter.h"
15 #include "components/dom_distiller/core/url_constants.h"
17 #if defined(OS_ANDROID)
18 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_android.h"
19 #endif // defined(OS_ANDROID)
21 void RegisterDomDistillerViewerSource(Profile* profile) {
22 const base::CommandLine& command_line =
23 *base::CommandLine::ForCurrentProcess();
24 if (command_line.HasSwitch(switches::kEnableDomDistiller)) {
25 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory =
26 dom_distiller::DomDistillerServiceFactory::GetInstance();
27 // The LazyDomDistillerService deletes itself when the profile is destroyed.
28 dom_distiller::LazyDomDistillerService* lazy_service =
29 new dom_distiller::LazyDomDistillerService(
30 profile, dom_distiller_service_factory);
31 scoped_ptr<dom_distiller::ExternalFeedbackReporter> reporter;
33 #if defined(OS_ANDROID)
34 reporter.reset(
35 new dom_distiller::android::ExternalFeedbackReporterAndroid());
36 #endif // defined(OS_ANDROID)
38 content::URLDataSource::Add(
39 profile,
40 new dom_distiller::DomDistillerViewerSource(
41 lazy_service, dom_distiller::kDomDistillerScheme, reporter.Pass()));