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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 10978028: Propagate storage partition id and persistence to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with incoming changes (159475). Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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/browser_plugin/browser_plugin_embedder.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 void BrowserPluginEmbedder::AddGuest(int instance_id, 73 void BrowserPluginEmbedder::AddGuest(int instance_id,
74 WebContents* guest_web_contents) { 74 WebContents* guest_web_contents) {
75 DCHECK(guest_web_contents_by_instance_id_.find(instance_id) == 75 DCHECK(guest_web_contents_by_instance_id_.find(instance_id) ==
76 guest_web_contents_by_instance_id_.end()); 76 guest_web_contents_by_instance_id_.end());
77 guest_web_contents_by_instance_id_[instance_id] = guest_web_contents; 77 guest_web_contents_by_instance_id_[instance_id] = guest_web_contents;
78 } 78 }
79 79
80 void BrowserPluginEmbedder::CreateGuest(RenderViewHost* render_view_host,
81 int instance_id,
82 std::string storage_partition_id,
83 bool persist_storage) {
84 WebContentsImpl* guest_web_contents = NULL;
85 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
86 CHECK(!guest);
87
88 const std::string& host =
89 render_view_host->GetSiteInstance()->GetSiteURL().host();
90 guest_web_contents = WebContentsImpl::CreateGuest(
91 web_contents()->GetBrowserContext(),
92 host,
93 instance_id);
94
95 guest = guest_web_contents->GetBrowserPluginGuest();
96 guest->set_embedder_render_process_host(render_view_host->GetProcess());
97
98 RendererPreferences* guest_renderer_prefs =
99 guest_web_contents->GetMutableRendererPrefs();
100 // Copy renderer preferences (and nothing else) from the embedder's
101 // TabContents to the guest.
102 //
103 // For GTK and Aura this is necessary to get proper renderer configuration
104 // values for caret blinking interval, colors related to selection and
105 // focus.
106 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs();
107
108 guest_renderer_prefs->throttle_input_events = false;
109 AddGuest(instance_id, guest_web_contents);
110 guest_web_contents->SetDelegate(guest);
111 }
112
80 void BrowserPluginEmbedder::NavigateGuest( 113 void BrowserPluginEmbedder::NavigateGuest(
81 RenderViewHost* render_view_host, 114 RenderViewHost* render_view_host,
82 int instance_id, 115 int instance_id,
83 const std::string& src, 116 const std::string& src,
84 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { 117 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) {
85 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 118 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
86 WebContentsImpl* guest_web_contents = NULL; 119 CHECK(guest);
87 GURL url(src); 120 GURL url(src);
88 if (!guest) { 121 WebContentsImpl* guest_web_contents =
89 const std::string& host = 122 static_cast<WebContentsImpl*>(guest->GetWebContents());
90 render_view_host->GetSiteInstance()->GetSiteURL().host();
91 guest_web_contents = WebContentsImpl::CreateGuest(
92 web_contents()->GetBrowserContext(),
93 host,
94 instance_id);
95
96 guest = guest_web_contents->GetBrowserPluginGuest();
97 guest->set_embedder_render_process_host(
98 render_view_host->GetProcess());
99
100 RendererPreferences* guest_renderer_prefs =
101 guest_web_contents->GetMutableRendererPrefs();
102 // Copy renderer preferences (and nothing else) from the embedder's
103 // TabContents to the guest.
104 //
105 // For GTK and Aura this is necessary to get proper renderer configuration
106 // values for caret blinking interval, colors related to selection and
107 // focus.
108 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs();
109
110 guest_renderer_prefs->throttle_input_events = false;
111 AddGuest(instance_id, guest_web_contents);
112 guest_web_contents->SetDelegate(guest);
113 } else {
114 guest_web_contents =
115 static_cast<WebContentsImpl*>(guest->GetWebContents());
116 }
117 123
118 // We ignore loading empty urls in web_contents. 124 // We ignore loading empty urls in web_contents.
119 // If a guest sets empty src attribute after it has navigated to some 125 // If a guest sets empty src attribute after it has navigated to some
120 // non-empty page, the action is considered no-op. 126 // non-empty page, the action is considered no-op.
121 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty 127 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty
122 // src ignoring in the shadow DOM element: http://crbug.com/149001. 128 // src ignoring in the shadow DOM element: http://crbug.com/149001.
123 if (!src.empty()) { 129 if (!src.empty()) {
124 guest_web_contents->GetController().LoadURL(url, 130 guest_web_contents->GetController().LoadURL(url,
125 Referrer(), 131 Referrer(),
126 PAGE_TRANSITION_AUTO_SUBFRAME, 132 PAGE_TRANSITION_AUTO_SUBFRAME,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool visible = *Details<bool>(details).ptr(); 291 bool visible = *Details<bool>(details).ptr();
286 WebContentsVisibilityChanged(visible); 292 WebContentsVisibilityChanged(visible);
287 break; 293 break;
288 } 294 }
289 default: 295 default:
290 NOTREACHED() << "Unexpected notification type: " << type; 296 NOTREACHED() << "Unexpected notification type: " << type;
291 } 297 }
292 } 298 }
293 299
294 } // namespace content 300 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_embedder.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698