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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 DISALLOW_COPY_AND_ASSIGN(ResizeLock); | 187 DISALLOW_COPY_AND_ASSIGN(ResizeLock); |
188 }; | 188 }; |
189 | 189 |
190 //////////////////////////////////////////////////////////////////////////////// | 190 //////////////////////////////////////////////////////////////////////////////// |
191 // RenderWidgetHostViewAura, public: | 191 // RenderWidgetHostViewAura, public: |
192 | 192 |
193 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 193 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
194 : host_(RenderWidgetHostImpl::From(host)), | 194 : host_(RenderWidgetHostImpl::From(host)), |
195 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 195 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
196 in_shutdown_(false), | |
196 is_fullscreen_(false), | 197 is_fullscreen_(false), |
197 popup_parent_host_view_(NULL), | 198 popup_parent_host_view_(NULL), |
198 popup_child_host_view_(NULL), | 199 popup_child_host_view_(NULL), |
199 is_loading_(false), | 200 is_loading_(false), |
200 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 201 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
201 can_compose_inline_(true), | 202 can_compose_inline_(true), |
202 has_composition_text_(false), | 203 has_composition_text_(false), |
203 current_surface_(0), | 204 current_surface_(0), |
204 paint_canvas_(NULL), | 205 paint_canvas_(NULL), |
205 synthetic_move_sent_(false), | 206 synthetic_move_sent_(false), |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 } else { | 913 } else { |
913 host_->SetInputMethodActive(false); | 914 host_->SetInputMethodActive(false); |
914 } | 915 } |
915 } | 916 } |
916 | 917 |
917 void RenderWidgetHostViewAura::OnBlur() { | 918 void RenderWidgetHostViewAura::OnBlur() { |
918 host_->SetActive(false); | 919 host_->SetActive(false); |
919 host_->Blur(); | 920 host_->Blur(); |
920 | 921 |
921 ui::InputMethod* input_method = GetInputMethod(); | 922 ui::InputMethod* input_method = GetInputMethod(); |
922 if (input_method) { | 923 if (input_method && input_method->GetTextInputClient() == this) |
923 if (input_method->GetTextInputClient() == this) | 924 input_method->SetFocusedTextInputClient(NULL); |
924 input_method->SetFocusedTextInputClient(NULL); | 925 host_->SetInputMethodActive(false); |
926 | |
927 // If we lose the focus while fullscreen, close the window; Pepper Flash won't | |
928 // do it for us (unlike NPAPI Flash). | |
929 if (is_fullscreen_ && !in_shutdown_) { | |
930 in_shutdown_ = true; | |
931 host_->Shutdown(); | |
925 } | 932 } |
926 host_->SetInputMethodActive(false); | |
927 } | 933 } |
928 | 934 |
929 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { | 935 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { |
930 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() && | 936 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab() && |
931 popup_child_host_view_->OnKeyEvent(event)) | 937 popup_child_host_view_->OnKeyEvent(event)) |
932 return true; | 938 return true; |
933 | 939 |
934 // We need to handle the Escape key for Pepper Flash. | 940 // We need to handle the Escape key for Pepper Flash. |
935 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { | 941 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
942 in_shutdown_ = true; | |
piman
2012/05/09 20:19:22
drive-by: should we test !in_shutdown_ before this
Daniel Erat
2012/05/09 20:25:21
I don't think we return to the event loop before w
| |
936 host_->Shutdown(); | 943 host_->Shutdown(); |
937 } else { | 944 } else { |
938 // We don't have to communicate with an input method here. | 945 // We don't have to communicate with an input method here. |
939 if (!event->HasNativeEvent()) { | 946 if (!event->HasNativeEvent()) { |
940 // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event. | 947 // Send a fabricated event, which is usually a VKEY_PROCESSKEY IME event. |
941 NativeWebKeyboardEvent webkit_event(event->type(), | 948 NativeWebKeyboardEvent webkit_event(event->type(), |
942 false /* is_char */, | 949 false /* is_char */, |
943 event->GetCharacter(), | 950 event->GetCharacter(), |
944 event->flags(), | 951 event->flags(), |
945 base::Time::Now().ToDoubleT()); | 952 base::Time::Now().ToDoubleT()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1277 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 1284 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
1278 RenderWidgetHost* widget) { | 1285 RenderWidgetHost* widget) { |
1279 return new RenderWidgetHostViewAura(widget); | 1286 return new RenderWidgetHostViewAura(widget); |
1280 } | 1287 } |
1281 | 1288 |
1282 // static | 1289 // static |
1283 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1290 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
1284 WebKit::WebScreenInfo* results) { | 1291 WebKit::WebScreenInfo* results) { |
1285 GetScreenInfoForWindow(results, NULL); | 1292 GetScreenInfoForWindow(results, NULL); |
1286 } | 1293 } |
OLD | NEW |