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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 100363002: Introduce RenderFrameObserver. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 | Annotate | Revision Log
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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/char_iterator.h" 11 #include "base/i18n/char_iterator.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/child/appcache/appcache_dispatcher.h" 14 #include "content/child/appcache/appcache_dispatcher.h"
15 #include "content/child/plugin_messages.h" 15 #include "content/child/plugin_messages.h"
16 #include "content/child/quota_dispatcher.h" 16 #include "content/child/quota_dispatcher.h"
17 #include "content/child/request_extra_data.h" 17 #include "content/child/request_extra_data.h"
18 #include "content/child/service_worker/web_service_worker_provider_impl.h" 18 #include "content/child/service_worker/web_service_worker_provider_impl.h"
19 #include "content/common/frame_messages.h" 19 #include "content/common/frame_messages.h"
20 #include "content/common/socket_stream_handle_data.h" 20 #include "content/common/socket_stream_handle_data.h"
21 #include "content/common/swapped_out_messages.h" 21 #include "content/common/swapped_out_messages.h"
22 #include "content/common/view_messages.h" 22 #include "content/common/view_messages.h"
23 #include "content/public/common/content_constants.h" 23 #include "content/public/common/content_constants.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
26 #include "content/public/renderer/content_renderer_client.h" 26 #include "content/public/renderer/content_renderer_client.h"
27 #include "content/public/renderer/document_state.h" 27 #include "content/public/renderer/document_state.h"
28 #include "content/public/renderer/navigation_state.h" 28 #include "content/public/renderer/navigation_state.h"
29 #include "content/public/renderer/render_frame_observer.h"
29 #include "content/renderer/accessibility/renderer_accessibility.h" 30 #include "content/renderer/accessibility/renderer_accessibility.h"
30 #include "content/renderer/browser_plugin/browser_plugin.h" 31 #include "content/renderer/browser_plugin/browser_plugin.h"
31 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 32 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
32 #include "content/renderer/internal_document_state_data.h" 33 #include "content/renderer/internal_document_state_data.h"
33 #include "content/renderer/npapi/plugin_channel_host.h" 34 #include "content/renderer/npapi/plugin_channel_host.h"
34 #include "content/renderer/render_thread_impl.h" 35 #include "content/renderer/render_thread_impl.h"
35 #include "content/renderer/render_view_impl.h" 36 #include "content/renderer/render_view_impl.h"
36 #include "content/renderer/render_widget_fullscreen_pepper.h" 37 #include "content/renderer/render_widget_fullscreen_pepper.h"
37 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 38 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
38 #include "content/renderer/websharedworker_proxy.h" 39 #include "content/renderer/websharedworker_proxy.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 is_swapped_out_(false), 123 is_swapped_out_(false),
123 is_detaching_(false) 124 is_detaching_(false)
124 #if defined(ENABLE_PLUGINS) 125 #if defined(ENABLE_PLUGINS)
125 , focused_pepper_plugin_(NULL), 126 , focused_pepper_plugin_(NULL),
126 pepper_last_mouse_event_target_(NULL) 127 pepper_last_mouse_event_target_(NULL)
127 #endif 128 #endif
128 { 129 {
129 } 130 }
130 131
131 RenderFrameImpl::~RenderFrameImpl() { 132 RenderFrameImpl::~RenderFrameImpl() {
133 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone());
134 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct());
132 } 135 }
133 136
134 RenderWidget* RenderFrameImpl::GetRenderWidget() { 137 RenderWidget* RenderFrameImpl::GetRenderWidget() {
135 return render_view_; 138 return render_view_;
136 } 139 }
137 140
138 #if defined(ENABLE_PLUGINS) 141 #if defined(ENABLE_PLUGINS)
139 void RenderFrameImpl::PepperInstanceCreated( 142 void RenderFrameImpl::PepperInstanceCreated(
140 PepperPluginInstanceImpl* instance) { 143 PepperPluginInstanceImpl* instance) {
141 active_pepper_instances_.insert(instance); 144 active_pepper_instances_.insert(instance);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Mimics the order of events sent by WebKit. 419 // Mimics the order of events sent by WebKit.
417 // See WebCore::Editor::setComposition() for the corresponding code. 420 // See WebCore::Editor::setComposition() for the corresponding code.
418 focused_pepper_plugin_->HandleCompositionEnd(last_text); 421 focused_pepper_plugin_->HandleCompositionEnd(last_text);
419 focused_pepper_plugin_->HandleTextInput(last_text); 422 focused_pepper_plugin_->HandleTextInput(last_text);
420 } 423 }
421 pepper_composition_text_.clear(); 424 pepper_composition_text_.clear();
422 } 425 }
423 426
424 #endif // ENABLE_PLUGINS 427 #endif // ENABLE_PLUGINS
425 428
426 int RenderFrameImpl::GetRoutingID() const {
427 return routing_id_;
428 }
429
430 bool RenderFrameImpl::Send(IPC::Message* message) { 429 bool RenderFrameImpl::Send(IPC::Message* message) {
431 if (is_detaching_ || 430 if (is_detaching_ ||
432 ((is_swapped_out_ || render_view_->is_swapped_out()) && 431 ((is_swapped_out_ || render_view_->is_swapped_out()) &&
433 !SwappedOutMessages::CanSendWhileSwappedOut(message))) { 432 !SwappedOutMessages::CanSendWhileSwappedOut(message))) {
434 delete message; 433 delete message;
435 return false; 434 return false;
436 } 435 }
437 436
438 return RenderThread::Get()->Send(message); 437 return RenderThread::Get()->Send(message);
439 } 438 }
440 439
441 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { 440 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
441 ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
442 RenderFrameObserver* observer;
443 while ((observer = it.GetNext()) != NULL) {
444 if (observer->OnMessageReceived(msg))
445 return true;
446 }
447
442 // TODO(ajwong): Fill in with message handlers as various components 448 // TODO(ajwong): Fill in with message handlers as various components
443 // are migrated over to understand frames. 449 // are migrated over to understand frames.
444 return false; 450 return false;
445 } 451 }
446 452
447 // blink::WebFrameClient implementation ------------------------------------- 453 // blink::WebFrameClient implementation -------------------------------------
448 454
449 blink::WebPlugin* RenderFrameImpl::createPlugin( 455 blink::WebPlugin* RenderFrameImpl::createPlugin(
450 blink::WebFrame* frame, 456 blink::WebFrame* frame,
451 const blink::WebPluginParams& params) { 457 const blink::WebPluginParams& params) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 529
524 blink::WebFrame* RenderFrameImpl::createChildFrame( 530 blink::WebFrame* RenderFrameImpl::createChildFrame(
525 blink::WebFrame* parent, 531 blink::WebFrame* parent,
526 const blink::WebString& name) { 532 const blink::WebString& name) {
527 RenderFrameImpl* child_render_frame = this; 533 RenderFrameImpl* child_render_frame = this;
528 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); 534 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier();
529 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 535 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
530 // Synchronously notify the browser of a child frame creation to get the 536 // Synchronously notify the browser of a child frame creation to get the
531 // routing_id for the RenderFrame. 537 // routing_id for the RenderFrame.
532 int routing_id; 538 int routing_id;
533 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), 539 Send(new FrameHostMsg_CreateChildFrame(routing_id_,
534 parent->identifier(), 540 parent->identifier(),
535 child_frame_identifier, 541 child_frame_identifier,
536 UTF16ToUTF8(name), 542 UTF16ToUTF8(name),
537 &routing_id)); 543 &routing_id));
538 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); 544 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id);
539 } 545 }
540 546
541 blink::WebFrame* web_frame = WebFrame::create(child_render_frame, 547 blink::WebFrame* web_frame = WebFrame::create(child_render_frame,
542 child_frame_identifier); 548 child_frame_identifier);
543 549
(...skipping 12 matching lines...) Expand all
556 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { 562 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) {
557 // NOTE: This function is called on the frame that is being detached and not 563 // NOTE: This function is called on the frame that is being detached and not
558 // the parent frame. This is different from createChildFrame() which is 564 // the parent frame. This is different from createChildFrame() which is
559 // called on the parent frame. 565 // called on the parent frame.
560 CHECK(!is_detaching_); 566 CHECK(!is_detaching_);
561 567
562 int64 parent_frame_id = -1; 568 int64 parent_frame_id = -1;
563 if (frame->parent()) 569 if (frame->parent())
564 parent_frame_id = frame->parent()->identifier(); 570 parent_frame_id = frame->parent()->identifier();
565 571
566 Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, 572 Send(new FrameHostMsg_Detach(routing_id_, parent_frame_id,
567 frame->identifier())); 573 frame->identifier()));
568 574
569 // Currently multiple WebCore::Frames can send frameDetached to a single 575 // Currently multiple WebCore::Frames can send frameDetached to a single
570 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served 576 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served
571 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also 577 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also
572 // prevents this class from entering the |is_detaching_| state because 578 // prevents this class from entering the |is_detaching_| state because
573 // even though one WebCore::Frame may have detached itself, others will 579 // even though one WebCore::Frame may have detached itself, others will
574 // still need to use this object. 580 // still need to use this object.
575 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 581 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
576 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be 582 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 } 1285 }
1280 1286
1281 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame, 1287 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame,
1282 int arb_robustness_status_code) { 1288 int arb_robustness_status_code) {
1283 render_view_->Send(new ViewHostMsg_DidLose3DContext( 1289 render_view_->Send(new ViewHostMsg_DidLose3DContext(
1284 GURL(frame->top()->document().securityOrigin().toString()), 1290 GURL(frame->top()->document().securityOrigin().toString()),
1285 THREE_D_API_TYPE_WEBGL, 1291 THREE_D_API_TYPE_WEBGL,
1286 arb_robustness_status_code)); 1292 arb_robustness_status_code));
1287 } 1293 }
1288 1294
1295 void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) {
1296 observers_.AddObserver(observer);
1297 }
1298
1299 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) {
1300 observer->RenderFrameGone();
1301 observers_.RemoveObserver(observer);
1302 }
1303
1289 } // namespace content 1304 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698