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

Unified Diff: content/browser/content_frame.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Current checkpoint Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/content_frame.h ('k') | content/browser/frame_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/content_frame.cc
diff --git a/content/browser/content_frame.cc b/content/browser/content_frame.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c3a2b6c28311a651af886ddceb938619546da9a3
--- /dev/null
+++ b/content/browser/content_frame.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content_frame.h"
+
+#include "content/browser/frame_map.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/public/browser/browser_context.h"
+
+namespace content {
+
+// This class tracks all frame loads for a top-level ContentFrame. This
+// updates the FrameMap with the current WebKitIdTuple for the ContentFrame
+// and its children.
+class ContentFrameObserver : public TabContentsObserver {
+ public:
+ ContentFrameObserver(ContentFrame* frame);
+ // TabContentsObserver methods
+ virtual void DidCommitProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& url,
+ content::PageTransition transition_type) OVERRIDE;
+ virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE;
+ private:
+ ContentFrame* frame_;
+};
+
+ContentFrameObserver::ContentFrameObserver(
+ ContentFrame* frame)
+ : TabContentsObserver(&frame->tab_contents()),
+ frame_(frame) {
+}
+
+void ContentFrameObserver::DidCommitProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& url,
+ content::PageTransition transition_type) {
+ content::FrameMap* mapper =
+ frame_->tab_contents_.browser_context()->frame_mapper();
+
+ if (is_main_frame) {
+ mapper->UpdateFrame(
+ frame_, frame_->tab_contents_.render_view_host()->process()->GetID(),
+ frame_->tab_contents_.render_view_host()->routing_id(), frame_id);
+ } else {
+ // If we're navigating a subframe, we may need to create a ContentFrame
+ // TODO(supersat): This is hack until we get proper subframe support
+ ContentFrame* frame = mapper->FindRendererFrame(
+ frame_->tab_contents_.render_view_host()->process()->GetID(),
+ frame_id);
+
+ if (!frame) {
+ frame = mapper->InitializeFrame(false, frame_->tab_contents_, frame_);
+ mapper->UpdateFrame(frame,
+ frame_->tab_contents_.render_view_host()->process()->GetID(),
+ frame_->tab_contents_.render_view_host()->routing_id(),
+ frame_id);
+ }
+ }
+}
+
+void ContentFrameObserver::TabContentsDestroyed(TabContents* tab) {
+ delete this;
+}
+
+ContentFrame::ContentFrame(int64 id,
+ bool is_top_level,
+ TabContents& tab_contents,
+ ContentFrame* opener)
+ : id_(id),
+ active_webkit_frame_(WebKitFrameIdentifier(-1, -1, -1)),
+ is_top_level_(is_top_level),
+ tab_contents_(tab_contents),
+ opener_(opener) {
+ if (is_top_level)
+ new ContentFrameObserver(this);
+}
+
+ContentFrame::~ContentFrame() {
+}
+
+void ContentFrame::UpdateFrame(int new_process_host_id,
+ int new_route_id,
+ int64 new_frame_id) {
+ WebKitFrameIdentifier newWebKitId(new_process_host_id, new_route_id,
+ new_frame_id);
+ active_webkit_frame_ = newWebKitId;
+
+ all_webkit_frames_.push_back(newWebKitId);
+}
+
+void ContentFrame::AddChildFrame(ContentFrame* child) {
+ children_.push_back(child);
+}
+
+void ContentFrame::RemoveChildren() {
+ children_.clear();
+}
+
+} // namespace content
« no previous file with comments | « content/browser/content_frame.h ('k') | content/browser/frame_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698