Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/dom_distiller/profile_utils.cc

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" 14 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
15 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" 15 #include "components/dom_distiller/content/browser/distiller_ui_handle.h"
16 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h " 16 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h "
17 #include "components/dom_distiller/core/dom_distiller_switches.h" 17 #include "components/dom_distiller/core/dom_distiller_switches.h"
18 #include "components/dom_distiller/core/url_constants.h" 18 #include "components/dom_distiller/core/url_constants.h"
19 19
20 #if defined(ENABLE_PRINT_PREVIEW) 20 #if defined(ENABLE_PRINT_PREVIEW)
21 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h" 21 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h"
22 #endif // defined(ENABLE_PRINT_PREVIEW) 22 #endif // defined(ENABLE_PRINT_PREVIEW)
23 23
24 #if defined(OS_ANDROID) 24 #if defined(ANDROID_JAVA_UI)
25 #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h" 25 #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h"
26 #endif // defined(OS_ANDROID) 26 #endif // defined(ANDROID_JAVA_UI)
27 27
28 void RegisterDomDistillerViewerSource(Profile* profile) { 28 void RegisterDomDistillerViewerSource(Profile* profile) {
29 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( 29 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kEnableDomDistiller); 30 switches::kEnableDomDistiller);
31 #if defined(ENABLE_PRINT_PREVIEW) 31 #if defined(ENABLE_PRINT_PREVIEW)
32 if (PrintPreviewDistiller::IsEnabled()) 32 if (PrintPreviewDistiller::IsEnabled())
33 enabled_distiller = true; 33 enabled_distiller = true;
34 #endif // defined(ENABLE_PRINT_PREVIEW) 34 #endif // defined(ENABLE_PRINT_PREVIEW)
35 35
36 if (enabled_distiller) { 36 if (enabled_distiller) {
37 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory = 37 dom_distiller::DomDistillerServiceFactory* dom_distiller_service_factory =
38 dom_distiller::DomDistillerServiceFactory::GetInstance(); 38 dom_distiller::DomDistillerServiceFactory::GetInstance();
39 // The LazyDomDistillerService deletes itself when the profile is destroyed. 39 // The LazyDomDistillerService deletes itself when the profile is destroyed.
40 dom_distiller::LazyDomDistillerService* lazy_service = 40 dom_distiller::LazyDomDistillerService* lazy_service =
41 new dom_distiller::LazyDomDistillerService( 41 new dom_distiller::LazyDomDistillerService(
42 profile, dom_distiller_service_factory); 42 profile, dom_distiller_service_factory);
43 scoped_ptr<dom_distiller::DistillerUIHandle> ui_handle; 43 scoped_ptr<dom_distiller::DistillerUIHandle> ui_handle;
44 44
45 #if defined(OS_ANDROID) 45 #if defined(ANDROID_JAVA_UI)
46 ui_handle.reset( 46 ui_handle.reset(
47 new dom_distiller::android::DistillerUIHandleAndroid()); 47 new dom_distiller::android::DistillerUIHandleAndroid());
48 #endif // defined(OS_ANDROID) 48 #endif // defined(ANDROID_JAVA_UI)
49 49
50 // Set the JavaScript world ID. 50 // Set the JavaScript world ID.
51 if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) { 51 if (!dom_distiller::DistillerJavaScriptWorldIdIsSet()) {
52 dom_distiller::SetDistillerJavaScriptWorldId( 52 dom_distiller::SetDistillerJavaScriptWorldId(
53 chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL); 53 chrome::ISOLATED_WORLD_ID_CHROME_INTERNAL);
54 } 54 }
55 55
56 content::URLDataSource::Add( 56 content::URLDataSource::Add(
57 profile, 57 profile,
58 new dom_distiller::DomDistillerViewerSource( 58 new dom_distiller::DomDistillerViewerSource(
59 lazy_service, dom_distiller::kDomDistillerScheme, 59 lazy_service, dom_distiller::kDomDistillerScheme,
60 ui_handle.Pass())); 60 ui_handle.Pass()));
61 } 61 }
62 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698