| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/dom_distiller/profile_utils.h" | 5 #include "chrome/browser/dom_distiller/profile_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 10 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h" | 10 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_isolated_world_ids.h" | 12 #include "chrome/common/chrome_isolated_world_ids.h" |
| 13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 14 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h
" | 14 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h
" |
| 15 #include "components/dom_distiller/content/browser/external_feedback_reporter.h" | 15 #include "components/dom_distiller/content/browser/external_feedback_reporter.h" |
| 16 #include "components/dom_distiller/core/dom_distiller_switches.h" | 16 #include "components/dom_distiller/core/dom_distiller_switches.h" |
| 17 #include "components/dom_distiller/core/url_constants.h" | 17 #include "components/dom_distiller/core/url_constants.h" |
| 18 | 18 |
| 19 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 20 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_androi
d.h" | 20 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_androi
d.h" |
| 21 #endif // defined(OS_ANDROID) | 21 #endif // defined(OS_ANDROID) |
| 22 | 22 |
| 23 void RegisterDomDistillerViewerSource(Profile* profile) { | 23 void RegisterDomDistillerViewerSource(Profile* profile) { |
| 24 const base::CommandLine& command_line = | 24 const base::CommandLine& command_line = |
| 25 *base::CommandLine::ForCurrentProcess(); | 25 *base::CommandLine::ForCurrentProcess(); |
| 26 if (command_line.HasSwitch(switches::kEnableDomDistiller)) { | 26 if (command_line.HasSwitch(switches::kEnableDomDistiller)) { |
| 27 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory = | 27 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory = |
| 28 dom_distiller::DomDistillerServiceFactory::GetInstance(); | 28 dom_distiller::DomDistillerServiceFactory::GetInstance(); |
| 29 // The LazyDomDistillerService deletes itself when the profile is destroyed. | 29 // The LazyDomDistillerService deletes itself when the profile is destroyed. |
| 30 dom_distiller::LazyDomDistillerService* lazy_service = | 30 dom_distiller::LazyDomDistillerService* lazy_service = |
| 31 new dom_distiller::LazyDomDistillerService( | 31 new dom_distiller::LazyDomDistillerService( |
| 32 profile, dom_distiller_service_factory); | 32 profile, dom_distiller_service_factory); |
| 33 scoped_ptr<dom_distiller::ExternalFeedbackReporter> reporter; | 33 scoped_ptr<dom_distiller::ExternalFeedbackReporter> reporter; |
| 34 | 34 |
| 35 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 36 reporter.reset( | 36 reporter.reset( |
| 37 new dom_distiller::android::ExternalFeedbackReporterAndroid()); | 37 new dom_distiller::android::q()); |
| 38 #endif // defined(OS_ANDROID) | 38 #endif // defined(OS_ANDROID) && !defined(USE_AURA) |
| 39 | 39 |
| 40 // Set the JavaScript world ID. | 40 // Set the JavaScript world ID. |
| 41 if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) { | 41 if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) { |
| 42 dom_distiller::SetDistillerJavaScriptWorldId( | 42 dom_distiller::SetDistillerJavaScriptWorldId( |
| 43 chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); | 43 chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); |
| 44 } | 44 } |
| 45 | 45 |
| 46 content::URLDataSource::Add( | 46 content::URLDataSource::Add( |
| 47 profile, | 47 profile, |
| 48 new dom_distiller::DomDistillerViewerSource( | 48 new dom_distiller::DomDistillerViewerSource( |
| 49 lazy_service, dom_distiller::kDomDistillerScheme, reporter.Pass())); | 49 lazy_service, dom_distiller::kDomDistillerScheme, reporter.Pass())); |
| 50 } | 50 } |
| 51 } | 51 } |
| OLD | NEW |