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

Side by Side Diff: blimp/client/app/linux/blimp_main.cc

Issue 2542083004: Make //blimp/client/app a real embedder of //blimp/client/public (Closed)
Patch Set: Fix findbugs issue Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <string> 5 #include <string>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/path_service.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
11 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
12 #include "blimp/client/app/blimp_startup.h" 14 #include "blimp/client/app/blimp_startup.h"
13 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h" 15 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h"
14 #include "blimp/client/app/linux/blimp_display_manager.h" 16 #include "blimp/client/app/linux/blimp_display_manager.h"
15 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h" 17 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h"
16 #include "blimp/client/core/settings/settings_prefs.h"
17 #include "blimp/client/core/switches/blimp_client_switches.h"
18 #include "blimp/client/public/blimp_client_context.h" 18 #include "blimp/client/public/blimp_client_context.h"
19 #include "blimp/client/public/contents/blimp_navigation_controller.h" 19 #include "blimp/client/public/contents/blimp_navigation_controller.h"
20 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" 20 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
21 #include "components/pref_registry/pref_registry_syncable.h" 21 #include "components/pref_registry/pref_registry_syncable.h"
22 #include "components/prefs/command_line_pref_store.h" 22 #include "components/prefs/command_line_pref_store.h"
23 #include "components/prefs/in_memory_pref_store.h" 23 #include "components/prefs/in_memory_pref_store.h"
24 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/prefs/pref_service_factory.h" 25 #include "components/prefs/pref_service_factory.h"
26 #include "skia/ext/fontmgr_default_linux.h" 26 #include "skia/ext/fontmgr_default_linux.h"
27 #include "third_party/skia/include/ports/SkFontConfigInterface.h" 27 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
28 #include "third_party/skia/include/ports/SkFontMgr.h" 28 #include "third_party/skia/include/ports/SkFontMgr.h"
29 #include "third_party/skia/include/ports/SkFontMgr_android.h" 29 #include "third_party/skia/include/ports/SkFontMgr_android.h"
30 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/x/x11_connection.h" 31 #include "ui/gfx/x/x11_connection.h"
31 32
32 namespace { 33 namespace {
34 // Specifies directory where android fonts are stored.
35 const char kAndroidFontsPath[] = "android-fonts-path";
33 const char kDefaultUrl[] = "https://www.google.com"; 36 const char kDefaultUrl[] = "https://www.google.com";
34 constexpr int kWindowWidth = 800; 37 constexpr int kWindowWidth = 800;
35 constexpr int kWindowHeight = 600; 38 constexpr int kWindowHeight = 600;
36 39
37 class BlimpShellCommandLinePrefStore : public CommandLinePrefStore { 40 class BlimpShellCommandLinePrefStore : public CommandLinePrefStore {
38 public: 41 public:
39 explicit BlimpShellCommandLinePrefStore(const base::CommandLine* command_line) 42 explicit BlimpShellCommandLinePrefStore(const base::CommandLine* command_line)
40 : CommandLinePrefStore(command_line) { 43 : CommandLinePrefStore(command_line) {
41 blimp::client::BlimpClientContext::ApplyBlimpSwitches(this); 44 blimp::client::BlimpClientContext::ApplyBlimpSwitches(this);
42 } 45 }
43 46
44 protected: 47 protected:
45 ~BlimpShellCommandLinePrefStore() override = default; 48 ~BlimpShellCommandLinePrefStore() override = default;
46 }; 49 };
47 50
48 bool HasAndroidFontSwitch() { 51 bool HasAndroidFontSwitch() {
49 return base::CommandLine::ForCurrentProcess()->HasSwitch( 52 return base::CommandLine::ForCurrentProcess()->HasSwitch(kAndroidFontsPath);
50 blimp::switches::kAndroidFontsPath);
51 } 53 }
52 54
53 std::string GetAndroidFontsDirectory() { 55 std::string GetAndroidFontsDirectory() {
54 std::string android_fonts_dir = 56 std::string android_fonts_dir =
55 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 57 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
56 blimp::switches::kAndroidFontsPath); 58 kAndroidFontsPath);
57 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/') { 59 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/') {
58 android_fonts_dir += '/'; 60 android_fonts_dir += '/';
59 } 61 }
60 return android_fonts_dir; 62 return android_fonts_dir;
61 } 63 }
62 64
63 SkFontMgr* CreateAndroidFontMgr(std::string android_fonts_dir) { 65 SkFontMgr* CreateAndroidFontMgr(std::string android_fonts_dir) {
64 SkFontMgr_Android_CustomFonts custom; 66 SkFontMgr_Android_CustomFonts custom;
65 custom.fSystemFontUse = 67 custom.fSystemFontUse =
66 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom; 68 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom;
(...skipping 13 matching lines...) Expand all
80 custom.fIsolated = true; 82 custom.fIsolated = true;
81 83
82 return SkFontMgr_New_Android(&custom); 84 return SkFontMgr_New_Android(&custom);
83 } 85 }
84 86
85 void SetupAndroidFontManager() { 87 void SetupAndroidFontManager() {
86 if (HasAndroidFontSwitch()) { 88 if (HasAndroidFontSwitch()) {
87 SetDefaultSkiaFactory(CreateAndroidFontMgr(GetAndroidFontsDirectory())); 89 SetDefaultSkiaFactory(CreateAndroidFontMgr(GetAndroidFontsDirectory()));
88 } 90 }
89 } 91 }
92
93 void InitializeResourceBundle() {
94 base::FilePath pak_file;
95 bool pak_file_valid = base::PathService::Get(base::DIR_MODULE, &pak_file);
96 CHECK(pak_file_valid);
97 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_shell.pak"));
98 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
99 }
100
90 } // namespace 101 } // namespace
91 102
92 int main(int argc, const char**argv) { 103 int main(int argc, const char**argv) {
93 base::AtExitManager at_exit; 104 base::AtExitManager at_exit;
94 base::CommandLine::Init(argc, argv); 105 base::CommandLine::Init(argc, argv);
95 SetupAndroidFontManager(); 106 SetupAndroidFontManager();
96 107
97 CHECK(gfx::InitializeThreadedX11()); 108 CHECK(gfx::InitializeThreadedX11());
98 109
99 blimp::client::InitializeLogging(); 110 blimp::client::InitializeLogging();
100 blimp::client::InitializeMainMessageLoop(); 111 blimp::client::InitializeMainMessageLoop();
101 blimp::client::InitializeResourceBundle(); 112 InitializeResourceBundle();
102 113
103 base::Thread io_thread("BlimpIOThread"); 114 base::Thread io_thread("BlimpIOThread");
104 base::Thread::Options options; 115 base::Thread::Options options;
105 options.message_loop_type = base::MessageLoop::TYPE_IO; 116 options.message_loop_type = base::MessageLoop::TYPE_IO;
106 io_thread.StartWithOptions(options); 117 io_thread.StartWithOptions(options);
107 118
108 // Creating this using "new" and passing to context using "WrapUnique" as 119 // Creating this using "new" and passing to context using "WrapUnique" as
109 // opposed to "MakeUnique" because we'll need to pass the compositor 120 // opposed to "MakeUnique" because we'll need to pass the compositor
110 // dependencies to the display manager as well. 121 // dependencies to the display manager as well.
111 blimp::client::CompositorDependencies* compositor_dependencies = 122 blimp::client::CompositorDependencies* compositor_dependencies =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate> 163 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate>
153 display_manager_delegate = 164 display_manager_delegate =
154 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>(); 165 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>();
155 blimp::client::BlimpDisplayManager display_manager( 166 blimp::client::BlimpDisplayManager display_manager(
156 display_manager_delegate.get(), compositor_dependencies); 167 display_manager_delegate.get(), compositor_dependencies);
157 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight)); 168 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight));
158 display_manager.SetBlimpContents(std::move(contents)); 169 display_manager.SetBlimpContents(std::move(contents));
159 170
160 base::RunLoop().Run(); 171 base::RunLoop().Run();
161 } 172 }
OLDNEW
« no previous file with comments | « blimp/client/app/linux/blimp_client_session_linux.cc ('k') | blimp/client/app/session/blimp_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698