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

Side by Side Diff: chrome/browser/guestview/guestview.cc

Issue 21930006: <webview>: Allocate the view instance ID from the WebView shim (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 7 years, 4 months 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
« no previous file with comments | « chrome/browser/guestview/guestview.h ('k') | chrome/browser/guestview/guestview_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/guestview/guestview.h" 5 #include "chrome/browser/guestview/guestview.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/event_router.h" 8 #include "chrome/browser/extensions/event_router.h"
9 #include "chrome/browser/guestview/guestview_constants.h" 9 #include "chrome/browser/guestview/guestview_constants.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // static 60 // static
61 GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) { 61 GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) {
62 EmbedderGuestViewMap* guest_map = embedder_guestview_map.Pointer(); 62 EmbedderGuestViewMap* guest_map = embedder_guestview_map.Pointer();
63 EmbedderGuestViewMap::iterator it = guest_map->find( 63 EmbedderGuestViewMap::iterator it = guest_map->find(
64 std::make_pair(embedder_process_id, guest_instance_id)); 64 std::make_pair(embedder_process_id, guest_instance_id));
65 return it == guest_map->end() ? NULL : it->second; 65 return it == guest_map->end() ? NULL : it->second;
66 } 66 }
67 67
68 void GuestView::Attach(content::WebContents* embedder_web_contents, 68 void GuestView::Attach(content::WebContents* embedder_web_contents,
69 const std::string& extension_id, 69 const std::string& extension_id,
70 int view_instance_id,
71 const base::DictionaryValue& args) { 70 const base::DictionaryValue& args) {
72 embedder_web_contents_ = embedder_web_contents; 71 embedder_web_contents_ = embedder_web_contents;
73 embedder_render_process_id_ = 72 embedder_render_process_id_ =
74 embedder_web_contents->GetRenderProcessHost()->GetID(); 73 embedder_web_contents->GetRenderProcessHost()->GetID();
75 extension_id_ = extension_id; 74 extension_id_ = extension_id;
76 view_instance_id_ = view_instance_id; 75 args.GetInteger(guestview::kParameterInstanceId, &view_instance_id_);
77 76
78 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); 77 std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_);
79 embedder_guestview_map.Get().insert(std::make_pair(key, this)); 78 embedder_guestview_map.Get().insert(std::make_pair(key, this));
80 79
81 // GuestView::Attach is called prior to initialization (and initial 80 // GuestView::Attach is called prior to initialization (and initial
82 // navigation) of the guest in the content layer in order to permit mapping 81 // navigation) of the guest in the content layer in order to permit mapping
83 // the necessary associations between the <*view> element and its guest. This 82 // the necessary associations between the <*view> element and its guest. This
84 // is needed by the <webview> WebRequest API to allow intercepting resource 83 // is needed by the <webview> WebRequest API to allow intercepting resource
85 // requests during navigation. However, queued events should be fired after 84 // requests during navigation. However, queued events should be fired after
86 // content layer initialization in order to ensure that load events (such as 85 // content layer initialization in order to ensure that load events (such as
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void GuestView::SendQueuedEvents() { 139 void GuestView::SendQueuedEvents() {
141 if (!attached()) 140 if (!attached())
142 return; 141 return;
143 142
144 while (!pending_events_.empty()) { 143 while (!pending_events_.empty()) {
145 Event* event = pending_events_.front(); 144 Event* event = pending_events_.front();
146 pending_events_.pop(); 145 pending_events_.pop();
147 DispatchEvent(event); 146 DispatchEvent(event);
148 } 147 }
149 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/guestview/guestview.h ('k') | chrome/browser/guestview/guestview_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698