| OLD | NEW |
| 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 "mash/quick_launch/quick_launch_application.h" |
| 6 |
| 5 #include "base/macros.h" | 7 #include "base/macros.h" |
| 6 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
| 9 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 11 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 10 #include "mojo/shell/public/cpp/application_runner.h" | 12 #include "mojo/shell/public/cpp/application_runner.h" |
| 11 #include "mojo/shell/public/cpp/shell.h" | 13 #include "mojo/shell/public/cpp/shell.h" |
| 12 #include "mojo/shell/public/cpp/shell_client.h" | 14 #include "mojo/shell/public/cpp/shell_client.h" |
| 13 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
| 14 #include "ui/views/controls/textfield/textfield.h" | 16 #include "ui/views/controls/textfield/textfield.h" |
| 15 #include "ui/views/controls/textfield/textfield_controller.h" | 17 #include "ui/views/controls/textfield/textfield_controller.h" |
| 16 #include "ui/views/mus/aura_init.h" | 18 #include "ui/views/mus/aura_init.h" |
| 17 #include "ui/views/mus/window_manager_connection.h" | 19 #include "ui/views/mus/window_manager_connection.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 20 | 22 |
| 21 namespace views { | 23 namespace views { |
| 22 class AuraInit; | 24 class AuraInit; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace mash { | 27 namespace mash { |
| 26 namespace quick_launch { | 28 namespace quick_launch { |
| 27 | 29 |
| 28 class QuickLaunchUI : public views::WidgetDelegateView, | 30 class QuickLaunchUI : public views::WidgetDelegateView, |
| 29 public views::TextfieldController { | 31 public views::TextfieldController { |
| 30 public: | 32 public: |
| 31 QuickLaunchUI(mojo::Shell* shell) | 33 QuickLaunchUI(mojo::Shell* shell) |
| 32 : shell_(shell), | 34 : shell_(shell), prompt_(new views::Textfield) { |
| 33 prompt_(new views::Textfield) { | |
| 34 set_background(views::Background::CreateStandardPanelBackground()); | 35 set_background(views::Background::CreateStandardPanelBackground()); |
| 35 prompt_->set_controller(this); | 36 prompt_->set_controller(this); |
| 36 AddChildView(prompt_); | 37 AddChildView(prompt_); |
| 37 } | 38 } |
| 38 ~QuickLaunchUI() override {} | 39 ~QuickLaunchUI() override {} |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 // Overridden from views::WidgetDelegate: | 42 // Overridden from views::WidgetDelegate: |
| 42 views::View* GetContentsView() override { return this; } | 43 views::View* GetContentsView() override { return this; } |
| 43 base::string16 GetWindowTitle() const override { | 44 base::string16 GetWindowTitle() const override { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return base::UTF16ToUTF8(working); | 78 return base::UTF16ToUTF8(working); |
| 78 } | 79 } |
| 79 | 80 |
| 80 mojo::Shell* shell_; | 81 mojo::Shell* shell_; |
| 81 views::Textfield* prompt_; | 82 views::Textfield* prompt_; |
| 82 std::vector<scoped_ptr<mojo::Connection>> connections_; | 83 std::vector<scoped_ptr<mojo::Connection>> connections_; |
| 83 | 84 |
| 84 DISALLOW_COPY_AND_ASSIGN(QuickLaunchUI); | 85 DISALLOW_COPY_AND_ASSIGN(QuickLaunchUI); |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 class QuickLaunchApplicationDelegate : public mojo::ShellClient { | 88 QuickLaunchApplication::QuickLaunchApplication() {} |
| 88 public: | 89 QuickLaunchApplication::~QuickLaunchApplication() {} |
| 89 QuickLaunchApplicationDelegate() {} | |
| 90 ~QuickLaunchApplicationDelegate() override {} | |
| 91 | 90 |
| 92 private: | 91 void QuickLaunchApplication::Initialize(mojo::Shell* shell, |
| 93 // mojo::ShellClient: | 92 const std::string& url, |
| 94 void Initialize(mojo::Shell* shell, const std::string& url, | 93 uint32_t id) { |
| 95 uint32_t id) override { | 94 tracing_.Initialize(shell, url); |
| 96 tracing_.Initialize(shell, url); | |
| 97 | 95 |
| 98 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); | 96 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); |
| 99 views::WindowManagerConnection::Create(shell); | 97 views::WindowManagerConnection::Create(shell); |
| 100 | 98 |
| 101 views::Widget* window = views::Widget::CreateWindowWithBounds( | 99 views::Widget* window = views::Widget::CreateWindowWithBounds( |
| 102 new QuickLaunchUI(shell), gfx::Rect(10, 640, 0, 0)); | 100 new QuickLaunchUI(shell), gfx::Rect(10, 640, 0, 0)); |
| 103 window->Show(); | 101 window->Show(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 mojo::TracingImpl tracing_; | 104 bool QuickLaunchApplication::AcceptConnection(mojo::Connection* connection) { |
| 107 scoped_ptr<views::AuraInit> aura_init_; | 105 return true; |
| 108 | 106 } |
| 109 DISALLOW_COPY_AND_ASSIGN(QuickLaunchApplicationDelegate); | |
| 110 }; | |
| 111 | 107 |
| 112 } // namespace quick_launch | 108 } // namespace quick_launch |
| 113 } // namespace mash | 109 } // namespace mash |
| 114 | |
| 115 MojoResult MojoMain(MojoHandle shell_handle) { | |
| 116 mojo::ApplicationRunner runner( | |
| 117 new mash::quick_launch::QuickLaunchApplicationDelegate); | |
| 118 return runner.Run(shell_handle); | |
| 119 } | |
| OLD | NEW |