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

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

Issue 2349073002: Blimp Settings framework on the c++ side (Closed)
Patch Set: move the PrefService logic from blimp_main.cc Created 4 years, 1 month 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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "blimp/client/app/blimp_startup.h" 12 #include "blimp/client/app/blimp_startup.h"
13 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h" 13 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h"
14 #include "blimp/client/app/linux/blimp_display_manager.h" 14 #include "blimp/client/app/linux/blimp_display_manager.h"
15 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h" 15 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h"
16 #include "blimp/client/core/settings/settings_prefs.h"
16 #include "blimp/client/public/blimp_client_context.h" 17 #include "blimp/client/public/blimp_client_context.h"
17 #include "blimp/client/public/contents/blimp_navigation_controller.h" 18 #include "blimp/client/public/contents/blimp_navigation_controller.h"
18 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" 19 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
20 #include "components/pref_registry/pref_registry_syncable.h"
21 #include "components/prefs/pref_service.h"
22 #include "components/prefs/pref_service_factory.h"
19 #include "ui/gfx/x/x11_connection.h" 23 #include "ui/gfx/x/x11_connection.h"
20 24
21 namespace { 25 namespace {
22 const char kDefaultUrl[] = "https://www.google.com"; 26 const char kDefaultUrl[] = "https://www.google.com";
23 constexpr int kWindowWidth = 800; 27 constexpr int kWindowWidth = 800;
24 constexpr int kWindowHeight = 600; 28 constexpr int kWindowHeight = 600;
25 } 29 }
26 30
27 int main(int argc, const char**argv) { 31 int main(int argc, const char**argv) {
28 base::AtExitManager at_exit; 32 base::AtExitManager at_exit;
(...skipping 11 matching lines...) Expand all
40 44
41 // Creating this using "new" and passing to context using "WrapUnique" as 45 // Creating this using "new" and passing to context using "WrapUnique" as
42 // opposed to "MakeUnique" because we'll need to pass the compositor 46 // opposed to "MakeUnique" because we'll need to pass the compositor
43 // dependencies to the display manager as well. 47 // dependencies to the display manager as well.
44 blimp::client::CompositorDependencies* compositor_dependencies = 48 blimp::client::CompositorDependencies* compositor_dependencies =
45 new blimp::client::CompositorDependenciesImpl(); 49 new blimp::client::CompositorDependenciesImpl();
46 // Creating the context delegate before the context so that the context is 50 // Creating the context delegate before the context so that the context is
47 // destroyed before the delegate. 51 // destroyed before the delegate.
48 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate = 52 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate =
49 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>(); 53 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>();
50 std::unique_ptr<blimp::client::BlimpClientContext> context = 54
51 base::WrapUnique<blimp::client::BlimpClientContext>( 55 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry =
David Trainor- moved to gerrit 2016/10/26 07:00:25 Shouldn't we do the following? blimp::client::Reg
Menglin 2016/10/26 19:28:33 to do ApplyBlimpSwitches, i create a subclass of C
52 blimp::client::BlimpClientContext::Create( 56 new ::user_prefs::PrefRegistrySyncable();
53 io_thread.task_runner(), io_thread.task_runner(), 57 pref_registry->RegisterBooleanPref(
54 base::WrapUnique(compositor_dependencies))); 58 blimp::client::prefs::kBlimpEnabled, false);
59 pref_registry->RegisterBooleanPref(
60 blimp::client::prefs::kRecordWholeDocument, false);
61
62 // Set up PrefService.
63 PrefServiceFactory pref_service_factory;
64 std::unique_ptr<PrefService> pref_service =
65 pref_service_factory.Create(pref_registry.get());
66
67 auto context = base::WrapUnique<blimp::client::BlimpClientContext>(
68 blimp::client::BlimpClientContext::Create(
69 io_thread.task_runner(), io_thread.task_runner(),
70 base::WrapUnique(compositor_dependencies),
71 pref_service.get()));
55 context->SetDelegate(context_delegate.get()); 72 context->SetDelegate(context_delegate.get());
56 73
57 context->Connect(); 74 context->Connect();
58 75
59 // If there is a non-switch argument to the command line, load that url. 76 // If there is a non-switch argument to the command line, load that url.
60 base::CommandLine::StringVector args = 77 base::CommandLine::StringVector args =
61 base::CommandLine::ForCurrentProcess()->GetArgs(); 78 base::CommandLine::ForCurrentProcess()->GetArgs();
62 std::string url = args.size() > 0 ? args[0] : kDefaultUrl; 79 std::string url = args.size() > 0 ? args[0] : kDefaultUrl;
63 std::unique_ptr<blimp::client::BlimpContents> contents = 80 std::unique_ptr<blimp::client::BlimpContents> contents =
64 context->CreateBlimpContents(nullptr); 81 context->CreateBlimpContents(nullptr);
65 contents->GetNavigationController().LoadURL(GURL(url)); 82 contents->GetNavigationController().LoadURL(GURL(url));
66 83
67 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate> 84 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate>
68 display_manager_delegate = 85 display_manager_delegate =
69 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>(); 86 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>();
70 blimp::client::BlimpDisplayManager display_manager( 87 blimp::client::BlimpDisplayManager display_manager(
71 display_manager_delegate.get(), compositor_dependencies); 88 display_manager_delegate.get(), compositor_dependencies);
72 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight)); 89 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight));
73 display_manager.SetBlimpContents(std::move(contents)); 90 display_manager.SetBlimpContents(std::move(contents));
74 91
75 base::RunLoop().Run(); 92 base::RunLoop().Run();
76 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698