Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 CreateOverscrollControllerIfPossible(); | 489 CreateOverscrollControllerIfPossible(); |
| 490 | 490 |
| 491 if (GetTextInputManager()) | 491 if (GetTextInputManager()) |
| 492 GetTextInputManager()->AddObserver(this); | 492 GetTextInputManager()->AddObserver(this); |
| 493 } | 493 } |
| 494 | 494 |
| 495 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 495 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 496 if (content_view_core_) | 496 if (content_view_core_) |
| 497 content_view_core_->RemoveObserver(this); | 497 content_view_core_->RemoveObserver(this); |
| 498 SetContentViewCore(NULL); | 498 SetContentViewCore(NULL); |
| 499 if (ime_adapter_android_) | 499 DCHECK(!ime_adapter_android_); |
| 500 ime_adapter_android_ = nullptr; | |
| 501 DCHECK(ack_callbacks_.empty()); | 500 DCHECK(ack_callbacks_.empty()); |
| 502 DCHECK(!delegated_frame_host_); | 501 DCHECK(!delegated_frame_host_); |
| 503 } | 502 } |
| 504 | 503 |
| 505 void RenderWidgetHostViewAndroid::Blur() { | 504 void RenderWidgetHostViewAndroid::Blur() { |
| 506 host_->Blur(); | 505 host_->Blur(); |
| 507 if (overscroll_controller_) | 506 if (overscroll_controller_) |
| 508 overscroll_controller_->Disable(); | 507 overscroll_controller_->Disable(); |
| 509 } | 508 } |
| 510 | 509 |
| 510 void RenderWidgetHostViewAndroid::AddDestructionObserver( | |
| 511 DestructionObserver* observer) { | |
| 512 destruction_observers_.push_back(observer); | |
| 513 } | |
| 514 | |
| 515 void RenderWidgetHostViewAndroid::RemoveDestructionObserver( | |
| 516 DestructionObserver* observer) { | |
| 517 auto it = std::find(destruction_observers_.begin(), | |
| 518 destruction_observers_.end(), observer); | |
| 519 DCHECK(it != destruction_observers_.end()); | |
| 520 destruction_observers_.erase(it); | |
| 521 } | |
| 522 | |
| 511 bool RenderWidgetHostViewAndroid::OnMessageReceived( | 523 bool RenderWidgetHostViewAndroid::OnMessageReceived( |
| 512 const IPC::Message& message) { | 524 const IPC::Message& message) { |
| 513 if (IPC_MESSAGE_ID_CLASS(message.type()) == SyncCompositorMsgStart) { | 525 if (IPC_MESSAGE_ID_CLASS(message.type()) == SyncCompositorMsgStart) { |
| 514 return SyncCompositorOnMessageReceived(message); | 526 return SyncCompositorOnMessageReceived(message); |
| 515 } | 527 } |
| 516 bool handled = true; | 528 bool handled = true; |
| 517 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) | 529 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) |
| 518 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowUnhandledTapUIIfNeeded, | 530 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowUnhandledTapUIIfNeeded, |
| 519 OnShowUnhandledTapUIIfNeeded) | 531 OnShowUnhandledTapUIIfNeeded) |
| 520 IPC_MESSAGE_UNHANDLED(handled = false) | 532 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 host_->ViewDestroyed(); | 1024 host_->ViewDestroyed(); |
| 1013 SetContentViewCore(NULL); | 1025 SetContentViewCore(NULL); |
| 1014 delegated_frame_host_.reset(); | 1026 delegated_frame_host_.reset(); |
| 1015 | 1027 |
| 1016 // The RenderWidgetHost's destruction led here, so don't call it. | 1028 // The RenderWidgetHost's destruction led here, so don't call it. |
| 1017 host_ = NULL; | 1029 host_ = NULL; |
| 1018 | 1030 |
| 1019 if (GetTextInputManager() && GetTextInputManager()->HasObserver(this)) | 1031 if (GetTextInputManager() && GetTextInputManager()->HasObserver(this)) |
| 1020 GetTextInputManager()->RemoveObserver(this); | 1032 GetTextInputManager()->RemoveObserver(this); |
| 1021 | 1033 |
| 1034 for (auto* observer : destruction_observers_) | |
| 1035 observer->RenderWidgetHostViewDestroyed(this); | |
| 1036 | |
|
boliu
2017/04/14 01:10:07
maybe clear the list to be safe
Jinsuk Kim
2017/04/14 02:16:33
Done.
| |
| 1022 delete this; | 1037 delete this; |
| 1023 } | 1038 } |
| 1024 | 1039 |
| 1025 void RenderWidgetHostViewAndroid::SetTooltipText( | 1040 void RenderWidgetHostViewAndroid::SetTooltipText( |
| 1026 const base::string16& tooltip_text) { | 1041 const base::string16& tooltip_text) { |
| 1027 // Tooltips don't makes sense on Android. | 1042 // Tooltips don't makes sense on Android. |
| 1028 } | 1043 } |
| 1029 | 1044 |
| 1030 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { | 1045 void RenderWidgetHostViewAndroid::SetBackgroundColor(SkColor color) { |
| 1031 background_color_ = color; | 1046 background_color_ = color; |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2179 | 2194 |
| 2180 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2195 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2181 if (!compositor) | 2196 if (!compositor) |
| 2182 return; | 2197 return; |
| 2183 | 2198 |
| 2184 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2199 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2185 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2200 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2186 } | 2201 } |
| 2187 | 2202 |
| 2188 } // namespace content | 2203 } // namespace content |
| OLD | NEW |