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

Side by Side Diff: services/native_viewport/platform_viewport_android.cc

Issue 2011053003: Make PlatformViewport and NativeViewportImpl use Shell* instead of ApplicationImpl*. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix android Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "services/native_viewport/platform_viewport_android.h" 5 #include "services/native_viewport/platform_viewport_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "jni/PlatformViewportAndroid_jni.h" 12 #include "jni/PlatformViewportAndroid_jni.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h" 13 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/input_events/input_events_type_converters.h" 14 #include "mojo/converters/input_events/input_events_type_converters.h"
15 #include "mojo/public/cpp/application/application_impl.h"
16 #include "mojo/public/cpp/application/connect.h" 15 #include "mojo/public/cpp/application/connect.h"
17 #include "services/native_viewport/native_viewport_support.mojom.h" 16 #include "services/native_viewport/native_viewport_support.mojom.h"
18 #include "ui/events/event.h" 17 #include "ui/events/event.h"
19 #include "ui/events/keycodes/keyboard_code_conversion_android.h" 18 #include "ui/events/keycodes/keyboard_code_conversion_android.h"
20 #include "ui/gfx/point.h" 19 #include "ui/gfx/point.h"
21 20
22 namespace native_viewport { 21 namespace native_viewport {
23 namespace { 22 namespace {
24 23
25 mojo::EventType MotionEventActionToEventType(jint action) { 24 mojo::EventType MotionEventActionToEventType(jint action) {
(...skipping 22 matching lines...) Expand all
48 } // namespace 47 } // namespace
49 48
50 //////////////////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////////////////
51 // PlatformViewportAndroid, public: 50 // PlatformViewportAndroid, public:
52 51
53 // static 52 // static
54 bool PlatformViewportAndroid::Register(JNIEnv* env) { 53 bool PlatformViewportAndroid::Register(JNIEnv* env) {
55 return RegisterNativesImpl(env); 54 return RegisterNativesImpl(env);
56 } 55 }
57 56
58 PlatformViewportAndroid::PlatformViewportAndroid( 57 PlatformViewportAndroid::PlatformViewportAndroid(mojo::Shell* shell,
59 mojo::ApplicationImpl* application, 58 Delegate* delegate)
60 Delegate* delegate) 59 : shell_(shell),
61 : application_(application),
62 delegate_(delegate), 60 delegate_(delegate),
63 window_(NULL), 61 window_(NULL),
64 id_generator_(0), 62 id_generator_(0),
65 weak_factory_(this) {} 63 weak_factory_(this) {}
66 64
67 PlatformViewportAndroid::~PlatformViewportAndroid() { 65 PlatformViewportAndroid::~PlatformViewportAndroid() {
68 if (window_) 66 if (window_)
69 ReleaseWindow(); 67 ReleaseWindow();
70 JNIEnv* env = base::android::AttachCurrentThread(); 68 JNIEnv* env = base::android::AttachCurrentThread();
71 if (!java_platform_viewport_android_.is_empty()) { 69 if (!java_platform_viewport_android_.is_empty()) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 158 }
161 159
162 //////////////////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////////////////
163 // PlatformViewportAndroid, PlatformViewport implementation: 161 // PlatformViewportAndroid, PlatformViewport implementation:
164 162
165 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) { 163 void PlatformViewportAndroid::Init(const gfx::Rect& bounds) {
166 JNIEnv* env = base::android::AttachCurrentThread(); 164 JNIEnv* env = base::android::AttachCurrentThread();
167 Java_PlatformViewportAndroid_createRequest(env, 165 Java_PlatformViewportAndroid_createRequest(env,
168 reinterpret_cast<intptr_t>(this)); 166 reinterpret_cast<intptr_t>(this));
169 167
170 mojo::ConnectToService(application_->shell(), "mojo:native_viewport_support", 168 mojo::ConnectToService(shell_, "mojo:native_viewport_support",
171 GetProxy(&support_service_)); 169 GetProxy(&support_service_));
172 support_service_->CreateNewNativeWindow( 170 support_service_->CreateNewNativeWindow(
173 base::Bind(&PlatformViewportAndroid::Close, weak_factory_.GetWeakPtr())); 171 base::Bind(&PlatformViewportAndroid::Close, weak_factory_.GetWeakPtr()));
174 } 172 }
175 173
176 void PlatformViewportAndroid::Show() { 174 void PlatformViewportAndroid::Show() {
177 // Nothing to do. View is created visible. 175 // Nothing to do. View is created visible.
178 } 176 }
179 177
180 void PlatformViewportAndroid::Hide() { 178 void PlatformViewportAndroid::Hide() {
(...skipping 20 matching lines...) Expand all
201 199
202 void PlatformViewportAndroid::ReleaseWindow() { 200 void PlatformViewportAndroid::ReleaseWindow() {
203 ANativeWindow_release(window_); 201 ANativeWindow_release(window_);
204 window_ = NULL; 202 window_ = NULL;
205 } 203 }
206 204
207 //////////////////////////////////////////////////////////////////////////////// 205 ////////////////////////////////////////////////////////////////////////////////
208 // PlatformViewport, public: 206 // PlatformViewport, public:
209 207
210 // static 208 // static
211 scoped_ptr<PlatformViewport> PlatformViewport::Create( 209 scoped_ptr<PlatformViewport> PlatformViewport::Create(mojo::Shell* shell,
212 mojo::ApplicationImpl* application_, 210 Delegate* delegate) {
213 Delegate* delegate) {
214 return scoped_ptr<PlatformViewport>( 211 return scoped_ptr<PlatformViewport>(
215 new PlatformViewportAndroid(application_, delegate)) 212 new PlatformViewportAndroid(shell, delegate))
216 .Pass(); 213 .Pass();
217 } 214 }
218 215
219 } // namespace native_viewport 216 } // namespace native_viewport
OLDNEW
« no previous file with comments | « services/native_viewport/platform_viewport_android.h ('k') | services/native_viewport/platform_viewport_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698