Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / dom_distiller / profile_utils.cc
blob52f8c22d310d7f62ad62b4a224a76006f0df994a
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_isolated_world_ids.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
15 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h"
16 #include "components/dom_distiller/content/browser/external_feedback_reporter.h"
17 #include "components/dom_distiller/core/url_constants.h"
19 #if defined(OS_ANDROID)
20 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_android.h"
21 #endif // defined(OS_ANDROID)
23 void RegisterDomDistillerViewerSource(Profile* profile) {
24 const base::CommandLine& command_line =
25 *base::CommandLine::ForCurrentProcess();
26 if (command_line.HasSwitch(switches::kEnableDomDistiller)) {
27 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory =
28 dom_distiller::DomDistillerServiceFactory::GetInstance();
29 // The LazyDomDistillerService deletes itself when the profile is destroyed.
30 dom_distiller::LazyDomDistillerService* lazy_service =
31 new dom_distiller::LazyDomDistillerService(
32 profile, dom_distiller_service_factory);
33 scoped_ptr<dom_distiller::ExternalFeedbackReporter> reporter;
35 #if defined(OS_ANDROID)
36 reporter.reset(
37 new dom_distiller::android::ExternalFeedbackReporterAndroid());
38 #endif // defined(OS_ANDROID)
40 // Set the JavaScript world ID.
41 if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) {
42 dom_distiller::SetDistillerJavaScriptWorldId(
43 chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL);
46 content::URLDataSource::Add(
47 profile,
48 new dom_distiller::DomDistillerViewerSource(
49 lazy_service, dom_distiller::kDomDistillerScheme, reporter.Pass()));