Home | History | Annotate | Download | only in dom_distiller
      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.
      4 
      5 #include "chrome/browser/dom_distiller/profile_utils.h"
      6 
      7 #include "base/command_line.h"
      8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
      9 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h"
     10 #include "chrome/browser/profiles/profile.h"
     11 #include "chrome/common/chrome_switches.h"
     12 #include "components/dom_distiller/content/dom_distiller_viewer_source.h"
     13 #include "components/dom_distiller/core/url_constants.h"
     14 
     15 void RegisterDomDistillerViewerSource(Profile* profile) {
     16   const CommandLine& command_line = *CommandLine::ForCurrentProcess();
     17   if (command_line.HasSwitch(switches::kEnableDomDistiller)) {
     18     dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory =
     19         dom_distiller::DomDistillerServiceFactory::GetInstance();
     20     // The LazyDomDistillerService deletes itself when the profile is destroyed.
     21     dom_distiller::LazyDomDistillerService* lazy_service =
     22         new dom_distiller::LazyDomDistillerService(
     23             profile, dom_distiller_service_factory);
     24     content::URLDataSource::Add(
     25         profile,
     26         new dom_distiller::DomDistillerViewerSource(
     27             lazy_service, dom_distiller::kDomDistillerScheme));
     28   }
     29 }
     30