| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 121 ViewManagerDelegate* delegate, | 121 ViewManagerDelegate* delegate, |
| 122 ApplicationConnection* app_connection) | 122 Shell* shell) |
| 123 : connected_(false), | 123 : connected_(false), |
| 124 connection_id_(0), | 124 connection_id_(0), |
| 125 next_id_(1), | 125 next_id_(1), |
| 126 delegate_(delegate), | 126 delegate_(delegate), |
| 127 window_manager_delegate_(NULL) { | 127 window_manager_delegate_(NULL) { |
| 128 // TODO(beng): Come up with a better way of establishing a configuration for | 128 // TODO(beng): Come up with a better way of establishing a configuration for |
| 129 // what the active window manager is. | 129 // what the active window manager is. |
| 130 std::string window_manager_url = "mojo:mojo_window_manager"; | 130 std::string window_manager_url = "mojo:mojo_window_manager"; |
| 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch("window-manager")) { | 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch("window-manager")) { |
| 132 window_manager_url = | 132 window_manager_url = |
| 133 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 133 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 134 "window-manager"); | 134 "window-manager"); |
| 135 } | 135 } |
| 136 app_connection->ConnectToService(window_manager_url, &window_manager_); | 136 InterfacePtr<ServiceProvider> sp; |
| 137 shell->ConnectToApplication(window_manager_url, Get(&sp)); |
| 138 ConnectToService(sp.get(), &window_manager_); |
| 137 window_manager_.set_client(this); | 139 window_manager_.set_client(this); |
| 138 } | 140 } |
| 139 | 141 |
| 140 ViewManagerClientImpl::~ViewManagerClientImpl() { | 142 ViewManagerClientImpl::~ViewManagerClientImpl() { |
| 141 std::vector<View*> non_owned; | 143 std::vector<View*> non_owned; |
| 142 while (!views_.empty()) { | 144 while (!views_.empty()) { |
| 143 IdToViewMap::iterator it = views_.begin(); | 145 IdToViewMap::iterator it = views_.begin(); |
| 144 if (OwnsView(it->second->id())) { | 146 if (OwnsView(it->second->id())) { |
| 145 it->second->Destroy(); | 147 it->second->Destroy(); |
| 146 } else { | 148 } else { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 base::Unretained(this)); | 441 base::Unretained(this)); |
| 440 } | 442 } |
| 441 | 443 |
| 442 base::Callback<void(ErrorCode)> | 444 base::Callback<void(ErrorCode)> |
| 443 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { | 445 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { |
| 444 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, | 446 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, |
| 445 base::Unretained(this)); | 447 base::Unretained(this)); |
| 446 } | 448 } |
| 447 | 449 |
| 448 } // namespace mojo | 450 } // namespace mojo |
| OLD | NEW |