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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
12 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h" | 12 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/chrome_isolated_world_ids.h" | 14 #include "chrome/common/chrome_isolated_world_ids.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/features.h" | 16 #include "chrome/common/features.h" |
17 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 17 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
18 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" | 18 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" |
19 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h
" | 19 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h
" |
20 #include "components/dom_distiller/core/dom_distiller_switches.h" | 20 #include "components/dom_distiller/core/dom_distiller_switches.h" |
21 #include "components/dom_distiller/core/url_constants.h" | 21 #include "components/dom_distiller/core/url_constants.h" |
22 | 22 |
23 #if BUILDFLAG(ANDROID_JAVA_UI) | 23 #if defined(OS_ANDROID) |
24 #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h" | 24 #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h" |
25 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 25 #endif // defined(OS_ANDROID) |
26 | 26 |
27 namespace dom_distiller { | 27 namespace dom_distiller { |
28 | 28 |
29 void RegisterViewerSource(Profile* profile) { | 29 void RegisterViewerSource(Profile* profile) { |
30 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( | 30 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( |
31 switches::kEnableDomDistiller); | 31 switches::kEnableDomDistiller); |
32 if (!enabled_distiller) | 32 if (!enabled_distiller) |
33 return; | 33 return; |
34 | 34 |
35 DomDistillerServiceFactory* dom_distiller_service_factory = | 35 DomDistillerServiceFactory* dom_distiller_service_factory = |
36 DomDistillerServiceFactory::GetInstance(); | 36 DomDistillerServiceFactory::GetInstance(); |
37 // The LazyDomDistillerService deletes itself when the profile is destroyed. | 37 // The LazyDomDistillerService deletes itself when the profile is destroyed. |
38 LazyDomDistillerService* lazy_service = | 38 LazyDomDistillerService* lazy_service = |
39 new LazyDomDistillerService(profile, dom_distiller_service_factory); | 39 new LazyDomDistillerService(profile, dom_distiller_service_factory); |
40 std::unique_ptr<DistillerUIHandle> ui_handle; | 40 std::unique_ptr<DistillerUIHandle> ui_handle; |
41 | 41 |
42 #if BUILDFLAG(ANDROID_JAVA_UI) | 42 #if defined(OS_ANDROID) |
43 ui_handle.reset(new dom_distiller::android::DistillerUIHandleAndroid()); | 43 ui_handle.reset(new dom_distiller::android::DistillerUIHandleAndroid()); |
44 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 44 #endif // defined(OS_ANDROID) |
45 | 45 |
46 // Set the JavaScript world ID. | 46 // Set the JavaScript world ID. |
47 if (!DistillerJavaScriptWorldIdIsSet()) { | 47 if (!DistillerJavaScriptWorldIdIsSet()) { |
48 SetDistillerJavaScriptWorldId(chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); | 48 SetDistillerJavaScriptWorldId(chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); |
49 } | 49 } |
50 | 50 |
51 content::URLDataSource::Add( | 51 content::URLDataSource::Add( |
52 profile, new DomDistillerViewerSource(lazy_service, kDomDistillerScheme, | 52 profile, new DomDistillerViewerSource(lazy_service, kDomDistillerScheme, |
53 std::move(ui_handle))); | 53 std::move(ui_handle))); |
54 } | 54 } |
55 | 55 |
56 } // namespace dom_distiller | 56 } // namespace dom_distiller |
OLD | NEW |