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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "content/browser/webui/generic_handler.h" | 71 #include "content/browser/webui/generic_handler.h" |
72 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 72 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
73 #include "content/browser/webui/web_ui_impl.h" | 73 #include "content/browser/webui/web_ui_impl.h" |
74 #include "content/common/browser_plugin/browser_plugin_constants.h" | 74 #include "content/common/browser_plugin/browser_plugin_constants.h" |
75 #include "content/common/browser_plugin/browser_plugin_messages.h" | 75 #include "content/common/browser_plugin/browser_plugin_messages.h" |
76 #include "content/common/frame_messages.h" | 76 #include "content/common/frame_messages.h" |
77 #include "content/common/input_messages.h" | 77 #include "content/common/input_messages.h" |
78 #include "content/common/page_messages.h" | 78 #include "content/common/page_messages.h" |
79 #include "content/common/site_isolation_policy.h" | 79 #include "content/common/site_isolation_policy.h" |
80 #include "content/common/ssl_status_serialization.h" | 80 #include "content/common/ssl_status_serialization.h" |
81 #include "content/common/text_input_state.h" | |
82 #include "content/common/view_messages.h" | 81 #include "content/common/view_messages.h" |
83 #include "content/public/browser/ax_event_notification_details.h" | 82 #include "content/public/browser/ax_event_notification_details.h" |
84 #include "content/public/browser/browser_context.h" | 83 #include "content/public/browser/browser_context.h" |
85 #include "content/public/browser/browser_plugin_guest_manager.h" | 84 #include "content/public/browser/browser_plugin_guest_manager.h" |
86 #include "content/public/browser/content_browser_client.h" | 85 #include "content/public/browser/content_browser_client.h" |
87 #include "content/public/browser/devtools_agent_host.h" | 86 #include "content/public/browser/devtools_agent_host.h" |
88 #include "content/public/browser/download_manager.h" | 87 #include "content/public/browser/download_manager.h" |
89 #include "content/public/browser/download_url_parameters.h" | 88 #include "content/public/browser/download_url_parameters.h" |
90 #include "content/public/browser/invalidate_type.h" | 89 #include "content/public/browser/invalidate_type.h" |
91 #include "content/public/browser/javascript_dialog_manager.h" | 90 #include "content/public/browser/javascript_dialog_manager.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 is_subframe_(false), | 394 is_subframe_(false), |
396 force_disable_overscroll_content_(false), | 395 force_disable_overscroll_content_(false), |
397 last_dialog_suppressed_(false), | 396 last_dialog_suppressed_(false), |
398 geolocation_service_context_(new GeolocationServiceContext()), | 397 geolocation_service_context_(new GeolocationServiceContext()), |
399 accessibility_mode_( | 398 accessibility_mode_( |
400 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 399 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
401 audio_stream_monitor_(this), | 400 audio_stream_monitor_(this), |
402 bluetooth_connected_device_count_(0), | 401 bluetooth_connected_device_count_(0), |
403 virtual_keyboard_requested_(false), | 402 virtual_keyboard_requested_(false), |
404 page_scale_factor_is_one_(true), | 403 page_scale_factor_is_one_(true), |
405 text_input_state_(new TextInputState()), | |
406 loading_weak_factory_(this), | 404 loading_weak_factory_(this), |
407 weak_factory_(this) { | 405 weak_factory_(this) { |
408 frame_tree_.SetFrameRemoveListener( | 406 frame_tree_.SetFrameRemoveListener( |
409 base::Bind(&WebContentsImpl::OnFrameRemoved, | 407 base::Bind(&WebContentsImpl::OnFrameRemoved, |
410 base::Unretained(this))); | 408 base::Unretained(this))); |
411 #if defined(OS_ANDROID) | 409 #if defined(OS_ANDROID) |
412 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); | 410 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); |
413 #else | 411 #else |
414 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
415 #endif | 413 #endif |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); | 2294 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); |
2297 if (rwhv) { | 2295 if (rwhv) { |
2298 SendPageMessage(new PageMsg_UpdateWindowScreenRect( | 2296 SendPageMessage(new PageMsg_UpdateWindowScreenRect( |
2299 MSG_ROUTING_NONE, rwhv->GetBoundsInRootWindow())); | 2297 MSG_ROUTING_NONE, rwhv->GetBoundsInRootWindow())); |
2300 } | 2298 } |
2301 | 2299 |
2302 if (browser_plugin_embedder_) | 2300 if (browser_plugin_embedder_) |
2303 browser_plugin_embedder_->DidSendScreenRects(); | 2301 browser_plugin_embedder_->DidSendScreenRects(); |
2304 } | 2302 } |
2305 | 2303 |
2306 const TextInputState* WebContentsImpl::GetTextInputState() { | |
2307 if (GetOuterWebContents()) | |
2308 return GetOuterWebContents()->GetTextInputState(); | |
2309 // A RWHV should update WebContentsImpl in its destruction path so that state | |
2310 // type is reset to none. | |
2311 DCHECK(view_with_active_text_input_ || | |
2312 text_input_state_->type == ui::TEXT_INPUT_TYPE_NONE); | |
2313 return text_input_state_.get(); | |
2314 } | |
2315 | |
2316 void WebContentsImpl::UpdateTextInputState(RenderWidgetHostViewBase* rwhv, | |
2317 bool text_input_state_changed) { | |
2318 // If there is an outer WebContents, let it process this update. | |
2319 if (GetOuterWebContents()) { | |
2320 return GetOuterWebContents()->UpdateTextInputState( | |
2321 rwhv, text_input_state_changed); | |
2322 } | |
2323 | |
2324 // If this RWHV has a text input type of NONE, then there is nothing to | |
2325 // report to the tab RWHV. | |
2326 if (view_with_active_text_input_.get() != rwhv && | |
2327 rwhv->text_input_state()->type == ui::TEXT_INPUT_TYPE_NONE) | |
2328 return; | |
2329 | |
2330 if (rwhv->text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE) | |
2331 view_with_active_text_input_ = rwhv->GetWeakPtr(); | |
2332 else | |
2333 view_with_active_text_input_.reset(); | |
2334 | |
2335 *text_input_state_ = *rwhv->text_input_state(); | |
2336 | |
2337 // The top level RWHV should know about the change. | |
2338 RenderWidgetHostViewBase* tab_rwhv = | |
2339 static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView()); | |
2340 if (tab_rwhv) | |
2341 tab_rwhv->UpdateInputMethodIfNecessary(text_input_state_changed); | |
2342 } | |
2343 | |
2344 BrowserAccessibilityManager* | 2304 BrowserAccessibilityManager* |
2345 WebContentsImpl::GetRootBrowserAccessibilityManager() { | 2305 WebContentsImpl::GetRootBrowserAccessibilityManager() { |
2346 RenderFrameHostImpl* rfh = GetMainFrame(); | 2306 RenderFrameHostImpl* rfh = GetMainFrame(); |
2347 return rfh ? rfh->browser_accessibility_manager() : nullptr; | 2307 return rfh ? rfh->browser_accessibility_manager() : nullptr; |
2348 } | 2308 } |
2349 | 2309 |
2350 BrowserAccessibilityManager* | 2310 BrowserAccessibilityManager* |
2351 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2311 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2352 RenderFrameHostImpl* rfh = GetMainFrame(); | 2312 RenderFrameHostImpl* rfh = GetMainFrame(); |
2353 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; | 2313 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; |
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4935 else | 4895 else |
4936 WasHidden(); | 4896 WasHidden(); |
4937 } | 4897 } |
4938 | 4898 |
4939 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4899 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
4940 JavaScriptDialogManager* dialog_manager) { | 4900 JavaScriptDialogManager* dialog_manager) { |
4941 dialog_manager_ = dialog_manager; | 4901 dialog_manager_ = dialog_manager; |
4942 } | 4902 } |
4943 | 4903 |
4944 } // namespace content | 4904 } // namespace content |
OLD | NEW |