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

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

Issue 2349073002: Blimp Settings framework on the c++ side (Closed)
Patch Set: Merge branch 'refs/heads/master' into settings 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/public/blimp_client_context.h" 16 #include "blimp/client/public/blimp_client_context.h"
17 #include "blimp/client/public/contents/blimp_navigation_controller.h" 17 #include "blimp/client/public/contents/blimp_navigation_controller.h"
18 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" 18 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
19 #include "ui/gfx/x/x11_connection.h" 19 #include "ui/gfx/x/x11_connection.h"
20 20
21 namespace { 21 namespace {
22 const char kDefaultUrl[] = "https://www.google.com"; 22 const char kDefaultUrl[] = "https://www.google.com";
23 constexpr int kWindowWidth = 800; 23 constexpr int kWindowWidth = 800;
24 constexpr int kWindowHeight = 600; 24 constexpr int kWindowHeight = 600;
25 } 25 }
26 26
27 int main(int argc, const char**argv) { 27 int main(int argc, const char**argv) {
David Trainor- moved to gerrit 2016/10/26 01:14:55 Should we call RegisterPrefs and the AppendCommand
Menglin 2016/10/26 01:46:22 Done.
28 base::AtExitManager at_exit; 28 base::AtExitManager at_exit;
29 base::CommandLine::Init(argc, argv); 29 base::CommandLine::Init(argc, argv);
30 30
31 CHECK(gfx::InitializeThreadedX11()); 31 CHECK(gfx::InitializeThreadedX11());
32 32
33 blimp::client::InitializeLogging(); 33 blimp::client::InitializeLogging();
34 blimp::client::InitializeMainMessageLoop(); 34 blimp::client::InitializeMainMessageLoop();
35 35
36 base::Thread io_thread("BlimpIOThread"); 36 base::Thread io_thread("BlimpIOThread");
37 base::Thread::Options options; 37 base::Thread::Options options;
38 options.message_loop_type = base::MessageLoop::TYPE_IO; 38 options.message_loop_type = base::MessageLoop::TYPE_IO;
39 io_thread.StartWithOptions(options); 39 io_thread.StartWithOptions(options);
40 40
41 // Creating this using "new" and passing to context using "WrapUnique" as 41 // Creating this using "new" and passing to context using "WrapUnique" as
42 // opposed to "MakeUnique" because we'll need to pass the compositor 42 // opposed to "MakeUnique" because we'll need to pass the compositor
43 // dependencies to the display manager as well. 43 // dependencies to the display manager as well.
44 blimp::client::CompositorDependencies* compositor_dependencies = 44 blimp::client::CompositorDependencies* compositor_dependencies =
45 new blimp::client::CompositorDependenciesImpl(); 45 new blimp::client::CompositorDependenciesImpl();
46 // Creating the context delegate before the context so that the context is 46 // Creating the context delegate before the context so that the context is
47 // destroyed before the delegate. 47 // destroyed before the delegate.
48 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate = 48 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate =
49 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>(); 49 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>();
50 std::unique_ptr<blimp::client::BlimpClientContext> context = 50 auto context = base::WrapUnique<blimp::client::BlimpClientContext>(
51 base::WrapUnique<blimp::client::BlimpClientContext>( 51 blimp::client::BlimpClientContext::Create(
52 blimp::client::BlimpClientContext::Create( 52 io_thread.task_runner(), io_thread.task_runner(),
53 io_thread.task_runner(), io_thread.task_runner(), 53 base::WrapUnique(compositor_dependencies),
54 base::WrapUnique(compositor_dependencies))); 54 static_cast<blimp::client::BlimpClientContextDelegateLinux*>(
55 context_delegate.get())->pref_service()));
55 context->SetDelegate(context_delegate.get()); 56 context->SetDelegate(context_delegate.get());
56 57
57 context->Connect(); 58 context->Connect();
58 59
59 // If there is a non-switch argument to the command line, load that url. 60 // If there is a non-switch argument to the command line, load that url.
60 base::CommandLine::StringVector args = 61 base::CommandLine::StringVector args =
61 base::CommandLine::ForCurrentProcess()->GetArgs(); 62 base::CommandLine::ForCurrentProcess()->GetArgs();
62 std::string url = args.size() > 0 ? args[0] : kDefaultUrl; 63 std::string url = args.size() > 0 ? args[0] : kDefaultUrl;
63 std::unique_ptr<blimp::client::BlimpContents> contents = 64 std::unique_ptr<blimp::client::BlimpContents> contents =
64 context->CreateBlimpContents(nullptr); 65 context->CreateBlimpContents(nullptr);
65 contents->GetNavigationController().LoadURL(GURL(url)); 66 contents->GetNavigationController().LoadURL(GURL(url));
66 67
67 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate> 68 std::unique_ptr<blimp::client::BlimpDisplayManagerDelegate>
68 display_manager_delegate = 69 display_manager_delegate =
69 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>(); 70 base::MakeUnique<blimp::client::BlimpDisplayManagerDelegateMain>();
70 blimp::client::BlimpDisplayManager display_manager( 71 blimp::client::BlimpDisplayManager display_manager(
71 display_manager_delegate.get(), compositor_dependencies); 72 display_manager_delegate.get(), compositor_dependencies);
72 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight)); 73 display_manager.SetWindowSize(gfx::Size(kWindowWidth, kWindowHeight));
73 display_manager.SetBlimpContents(std::move(contents)); 74 display_manager.SetBlimpContents(std::move(contents));
74 75
75 base::RunLoop().Run(); 76 base::RunLoop().Run();
76 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698