Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 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_session_linux.h" | 13 #include "blimp/client/app/linux/blimp_client_context_delegate_linux.h" |
| 14 #include "blimp/client/core/contents/navigation_feature.h" | 14 #include "blimp/client/app/linux/blimp_display_manager.h" |
| 15 #include "blimp/client/core/contents/tab_control_feature.h" | 15 #include "blimp/client/app/linux/blimp_display_manager_delegate_main.h" |
| 16 #include "blimp/client/core/session/assignment_source.h" | 16 #include "blimp/client/public/blimp_client_context.h" |
| 17 #include "blimp/client/public/contents/blimp_contents_view.h" | |
| 18 #include "blimp/client/public/contents/blimp_navigation_controller.h" | |
| 19 #include "blimp/client/support/compositor/blimp_embedder_compositor.h" | |
|
Kevin M
2016/09/28 01:35:46
Is this used? Can you sift through the other depen
steimel
2016/09/28 20:33:07
Done.
| |
| 20 #include "blimp/client/support/compositor/compositor_dependencies_impl.h" | |
| 21 #include "blimp/common/get_client_auth_token.h" | |
|
Kevin M
2016/09/28 01:35:47
Not used?
steimel
2016/09/28 20:33:07
Done.
| |
| 17 #include "ui/gfx/x/x11_connection.h" | 22 #include "ui/gfx/x/x11_connection.h" |
| 18 | 23 |
| 19 namespace { | 24 namespace { |
| 20 const char kDummyLoginToken[] = ""; | 25 constexpr char kDefaultUrl[] = "https://www.google.com"; |
|
Kevin M
2016/09/28 01:35:46
Nit: this can be const char* - it's advantageous t
steimel
2016/09/28 20:33:07
Done.
| |
| 21 const char kDefaultUrl[] = "https://www.google.com"; | 26 constexpr int kWindowWidth = 800; |
| 22 const int kDummyTabId = 0; | 27 constexpr int kWindowHeight = 600; |
| 23 } | 28 } |
| 24 | 29 |
| 25 int main(int argc, const char**argv) { | 30 int main(int argc, const char**argv) { |
| 26 base::AtExitManager at_exit; | 31 base::AtExitManager at_exit; |
| 27 base::CommandLine::Init(argc, argv); | 32 base::CommandLine::Init(argc, argv); |
| 28 | 33 |
| 29 CHECK(gfx::InitializeThreadedX11()); | 34 CHECK(gfx::InitializeThreadedX11()); |
| 30 | 35 |
| 31 blimp::client::InitializeLogging(); | 36 blimp::client::InitializeLogging(); |
| 32 blimp::client::InitializeMainMessageLoop(); | 37 blimp::client::InitializeMainMessageLoop(); |
| 33 | 38 |
| 34 blimp::client::BlimpClientSessionLinux session; | 39 base::Thread io_thread("BlimpIOThread"); |
| 35 session.GetTabControlFeature()->CreateTab(kDummyTabId); | 40 base::Thread::Options options; |
| 36 session.Connect(kDummyLoginToken); | 41 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 42 io_thread.StartWithOptions(options); | |
| 43 | |
| 44 // Creating this using "new" and passing to context using "WrapUnique" as | |
| 45 // opposed to "MakeUnique" because we'll need to pass the compositor | |
| 46 // dependencies to the display manager as well. | |
| 47 blimp::client::CompositorDependencies* compositor_dependencies = | |
| 48 new blimp::client::CompositorDependenciesImpl(); | |
| 49 std::unique_ptr<blimp::client::BlimpClientContext> context = | |
| 50 base::WrapUnique<blimp::client::BlimpClientContext>( | |
| 51 blimp::client::BlimpClientContext::Create( | |
| 52 io_thread.task_runner(), io_thread.task_runner(), | |
| 53 base::WrapUnique(compositor_dependencies))); | |
| 54 | |
| 55 std::unique_ptr<blimp::client::BlimpClientContextDelegate> context_delegate = | |
| 56 base::MakeUnique<blimp::client::BlimpClientContextDelegateLinux>(); | |
| 57 context->SetDelegate(context_delegate.get()); | |
| 58 | |
| 59 context->Connect(); | |
| 37 | 60 |
| 38 // If there is a non-switch argument to the command line, load that url. | 61 // If there is a non-switch argument to the command line, load that url. |
| 39 base::CommandLine::StringVector args = | 62 base::CommandLine::StringVector args = |
| 40 base::CommandLine::ForCurrentProcess()->GetArgs(); | 63 base::CommandLine::ForCurrentProcess()->GetArgs(); |
| 41 std::string url = args.size() > 0 ? args[0] : kDefaultUrl; | 64 std::string url = args.size() > 0 ? args[0] : kDefaultUrl; |
| 42 session.GetNavigationFeature()->NavigateToUrlText(kDummyTabId, url); | 65 std::unique_ptr<blimp::client::BlimpContents> contents = |
| 66 context->CreateBlimpContents(nullptr); | |
| 67 contents->GetNavigationController().LoadURL(GURL(url)); | |
| 68 | |
| 69 blimp::client::BlimpDisplayManager display_manager( | |
| 70 gfx::Size(kWindowWidth, kWindowHeight), | |
| 71 new blimp::client::BlimpDisplayManagerDelegateMain(), | |
| 72 compositor_dependencies, std::move(contents)); | |
| 43 | 73 |
| 44 base::RunLoop().Run(); | 74 base::RunLoop().Run(); |
| 45 } | 75 } |
| OLD | NEW |