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

Side by Side Diff: mash/quick_launch/quick_launch_application.cc

Issue 2179023004: Make Service own ServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months 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
« no previous file with comments | « mash/quick_launch/quick_launch_application.h ('k') | mash/screenlock/screenlock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mash/quick_launch/quick_launch_application.h" 5 #include "mash/quick_launch/quick_launch_application.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 20 matching lines...) Expand all
31 namespace mash { 31 namespace mash {
32 namespace quick_launch { 32 namespace quick_launch {
33 33
34 class QuickLaunchUI : public views::WidgetDelegateView, 34 class QuickLaunchUI : public views::WidgetDelegateView,
35 public views::TextfieldController { 35 public views::TextfieldController {
36 public: 36 public:
37 QuickLaunchUI(QuickLaunchApplication* quick_launch, 37 QuickLaunchUI(QuickLaunchApplication* quick_launch,
38 shell::Connector* connector, 38 shell::Connector* connector,
39 catalog::mojom::CatalogPtr catalog) 39 catalog::mojom::CatalogPtr catalog)
40 : quick_launch_(quick_launch), 40 : quick_launch_(quick_launch),
41 connector_(connector), 41 connector_(connector),
42 prompt_(new views::Textfield), 42 prompt_(new views::Textfield),
43 catalog_(std::move(catalog)) { 43 catalog_(std::move(catalog)) {
44 set_background(views::Background::CreateStandardPanelBackground()); 44 set_background(views::Background::CreateStandardPanelBackground());
45 prompt_->set_controller(this); 45 prompt_->set_controller(this);
46 AddChildView(prompt_); 46 AddChildView(prompt_);
47 47
48 UpdateEntries(); 48 UpdateEntries();
49 } 49 }
50 ~QuickLaunchUI() override { 50 ~QuickLaunchUI() override {
51 quick_launch_->RemoveWindow(GetWidget()); 51 quick_launch_->RemoveWindow(GetWidget());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 QuickLaunchApplication::~QuickLaunchApplication() {} 156 QuickLaunchApplication::~QuickLaunchApplication() {}
157 157
158 void QuickLaunchApplication::RemoveWindow(views::Widget* window) { 158 void QuickLaunchApplication::RemoveWindow(views::Widget* window) {
159 auto it = std::find(windows_.begin(), windows_.end(), window); 159 auto it = std::find(windows_.begin(), windows_.end(), window);
160 DCHECK(it != windows_.end()); 160 DCHECK(it != windows_.end());
161 windows_.erase(it); 161 windows_.erase(it);
162 if (windows_.empty() && base::MessageLoop::current()->is_running()) 162 if (windows_.empty() && base::MessageLoop::current()->is_running())
163 base::MessageLoop::current()->QuitWhenIdle(); 163 base::MessageLoop::current()->QuitWhenIdle();
164 } 164 }
165 165
166 void QuickLaunchApplication::OnStart(shell::Connector* connector, 166 void QuickLaunchApplication::OnStart(const shell::Identity& identity) {
167 const shell::Identity& identity, 167 tracing_.Initialize(connector(), identity.name());
168 uint32_t id) {
169 connector_ = connector;
170 tracing_.Initialize(connector, identity.name());
171 168
172 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); 169 aura_init_.reset(
170 new views::AuraInit(connector(), "views_mus_resources.pak"));
173 window_manager_connection_ = 171 window_manager_connection_ =
174 views::WindowManagerConnection::Create(connector, identity); 172 views::WindowManagerConnection::Create(connector(), identity);
175 173
176 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); 174 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW);
177 } 175 }
178 176
179 bool QuickLaunchApplication::OnConnect(shell::Connection* connection) { 177 bool QuickLaunchApplication::OnConnect(shell::Connection* connection) {
180 connection->AddInterface<mojom::Launchable>(this); 178 connection->AddInterface<mojom::Launchable>(this);
181 return true; 179 return true;
182 } 180 }
183 181
184 void QuickLaunchApplication::Launch(uint32_t what, mojom::LaunchMode how) { 182 void QuickLaunchApplication::Launch(uint32_t what, mojom::LaunchMode how) {
185 bool reuse = how == mojom::LaunchMode::REUSE || 183 bool reuse = how == mojom::LaunchMode::REUSE ||
186 how == mojom::LaunchMode::DEFAULT; 184 how == mojom::LaunchMode::DEFAULT;
187 if (reuse && !windows_.empty()) { 185 if (reuse && !windows_.empty()) {
188 windows_.back()->Activate(); 186 windows_.back()->Activate();
189 return; 187 return;
190 } 188 }
191 catalog::mojom::CatalogPtr catalog; 189 catalog::mojom::CatalogPtr catalog;
192 connector_->ConnectToInterface("mojo:catalog", &catalog); 190 connector()->ConnectToInterface("mojo:catalog", &catalog);
193 191
194 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 192 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
195 new QuickLaunchUI(this, connector_, std::move(catalog)), nullptr, 193 new QuickLaunchUI(this, connector(), std::move(catalog)),
196 gfx::Rect(10, 640, 0, 0)); 194 nullptr, gfx::Rect(10, 640, 0, 0));
197 window->Show(); 195 window->Show();
198 windows_.push_back(window); 196 windows_.push_back(window);
199 } 197 }
200 198
201 void QuickLaunchApplication::Create(const shell::Identity& remote_identity, 199 void QuickLaunchApplication::Create(const shell::Identity& remote_identity,
202 mojom::LaunchableRequest request) { 200 mojom::LaunchableRequest request) {
203 bindings_.AddBinding(this, std::move(request)); 201 bindings_.AddBinding(this, std::move(request));
204 } 202 }
205 203
206 } // namespace quick_launch 204 } // namespace quick_launch
207 } // namespace mash 205 } // namespace mash
OLDNEW
« no previous file with comments | « mash/quick_launch/quick_launch_application.h ('k') | mash/screenlock/screenlock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698