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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc

Issue 514063003: Update view_manager and window_manager to make use of content handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@viewman2
Patch Set: git cl format Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/public/cpp/application/connect.h" 11 #include "mojo/public/cpp/application/connect.h"
13 #include "mojo/public/cpp/application/service_provider_impl.h" 12 #include "mojo/public/cpp/application/service_provider_impl.h"
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" 13 #include "mojo/public/interfaces/application/service_provider.mojom.h"
14 #include "mojo/public/interfaces/application/shell.mojom.h"
15 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" 15 #include "mojo/services/public/cpp/view_manager/lib/view_private.h"
16 #include "mojo/services/public/cpp/view_manager/util.h" 16 #include "mojo/services/public/cpp/view_manager/util.h"
17 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 17 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
18 #include "mojo/services/public/cpp/view_manager/view_observer.h" 18 #include "mojo/services/public/cpp/view_manager/view_observer.h"
19 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" 19 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
20 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "ui/gfx/codec/png_codec.h" 21 #include "ui/gfx/codec/png_codec.h"
22 22
23 namespace mojo { 23 namespace mojo {
24 24
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 result = MapBuffer( 111 result = MapBuffer(
112 handle->get(), 0, size, memory, MOJO_MAP_BUFFER_FLAG_NONE); 112 handle->get(), 0, size, memory, MOJO_MAP_BUFFER_FLAG_NONE);
113 if (result != MOJO_RESULT_OK) 113 if (result != MOJO_RESULT_OK)
114 return false; 114 return false;
115 DCHECK(*memory); 115 DCHECK(*memory);
116 116
117 return true; 117 return true;
118 } 118 }
119 119
120 ViewManagerClientImpl::ViewManagerClientImpl( 120 ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate,
121 ViewManagerDelegate* delegate, 121 Shell* shell)
122 ApplicationConnection* app_connection)
123 : connected_(false), 122 : connected_(false),
124 connection_id_(0), 123 connection_id_(0),
125 next_id_(1), 124 next_id_(1),
126 delegate_(delegate), 125 delegate_(delegate),
127 window_manager_delegate_(NULL) { 126 window_manager_delegate_(NULL) {
128 // TODO(beng): Come up with a better way of establishing a configuration for 127 // TODO(beng): Come up with a better way of establishing a configuration for
129 // what the active window manager is. 128 // what the active window manager is.
130 std::string window_manager_url = "mojo:mojo_window_manager"; 129 std::string window_manager_url = "mojo:mojo_window_manager";
131 if (base::CommandLine::ForCurrentProcess()->HasSwitch("window-manager")) { 130 if (base::CommandLine::ForCurrentProcess()->HasSwitch("window-manager")) {
132 window_manager_url = 131 window_manager_url =
133 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 132 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
134 "window-manager"); 133 "window-manager");
135 } 134 }
136 app_connection->ConnectToService(window_manager_url, &window_manager_); 135 InterfacePtr<ServiceProvider> sp;
136 shell->ConnectToApplication(window_manager_url, Get(&sp));
137 ConnectToService(sp.get(), &window_manager_);
137 window_manager_.set_client(this); 138 window_manager_.set_client(this);
138 } 139 }
139 140
140 ViewManagerClientImpl::~ViewManagerClientImpl() { 141 ViewManagerClientImpl::~ViewManagerClientImpl() {
141 std::vector<View*> non_owned; 142 std::vector<View*> non_owned;
142 while (!views_.empty()) { 143 while (!views_.empty()) {
143 IdToViewMap::iterator it = views_.begin(); 144 IdToViewMap::iterator it = views_.begin();
144 if (OwnsView(it->second->id())) { 145 if (OwnsView(it->second->id())) {
145 it->second->Destroy(); 146 it->second->Destroy();
146 } else { 147 } else {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 base::Unretained(this)); 440 base::Unretained(this));
440 } 441 }
441 442
442 base::Callback<void(ErrorCode)> 443 base::Callback<void(ErrorCode)>
443 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { 444 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() {
444 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, 445 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode,
445 base::Unretained(this)); 446 base::Unretained(this));
446 } 447 }
447 448
448 } // namespace mojo 449 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698