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

Side by Side Diff: chrome/browser/guest_view/guest_view_manager.cc

Issue 376033002: Adding MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pending-zork-patch2
Patch Set: Put all MimeHandlerView /w same mime-type to same process Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/guest_view/guest_view_manager.h" 5 #include "chrome/browser/guest_view/guest_view_manager.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/guest_view/guest_view_base.h" 9 #include "chrome/browser/guest_view/guest_view_base.h"
10 #include "chrome/browser/guest_view/guest_view_constants.h" 10 #include "chrome/browser/guest_view/guest_view_constants.h"
11 #include "chrome/browser/guest_view/guest_view_manager_factory.h" 11 #include "chrome/browser/guest_view/guest_view_manager_factory.h"
12 #include "chrome/browser/guest_view/web_view/web_view_guest.h" 12 #include "chrome/browser/guest_view/web_view/web_view_guest.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/user_metrics.h" 16 #include "content/public/browser/user_metrics.h"
17 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
18 #include "content/public/common/result_codes.h" 18 #include "content/public/common/result_codes.h"
19 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
20 #include "extensions/browser/extension_system.h" 20 #include "extensions/browser/extension_system.h"
21 #include "net/base/escape.h" 21 #include "net/base/escape.h"
22 #include "net/base/url_util.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 using content::BrowserContext; 25 using content::BrowserContext;
25 using content::SiteInstance; 26 using content::SiteInstance;
26 using content::WebContents; 27 using content::WebContents;
27 28
28 // static 29 // static
29 GuestViewManagerFactory* GuestViewManager::factory_ = NULL; 30 GuestViewManagerFactory* GuestViewManager::factory_ = NULL;
30 31
31 GuestViewManager::GuestViewManager(content::BrowserContext* context) 32 GuestViewManager::GuestViewManager(content::BrowserContext* context)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // If we kill the embedder, then don't bother calling back. 114 // If we kill the embedder, then don't bother calling back.
114 return; 115 return;
115 } 116 }
116 content::WebContents* guest_web_contents = 117 content::WebContents* guest_web_contents =
117 GetGuestByInstanceID(guest_instance_id); 118 GetGuestByInstanceID(guest_instance_id);
118 callback.Run(guest_web_contents); 119 callback.Run(guest_web_contents);
119 } 120 }
120 121
121 SiteInstance* GuestViewManager::GetGuestSiteInstance( 122 SiteInstance* GuestViewManager::GetGuestSiteInstance(
122 const GURL& guest_site) { 123 const GURL& guest_site) {
124 std::string mime_type_param;
125 bool has_mime_type_param = net::GetValueForKeyInQuery(guest_site,
Fady Samuel 2014/07/22 10:59:49 I don't understand this change. Why not simply hav
lazyboy 2014/07/22 20:32:56 I've changed it to have mime type directly in the
126 guestview::kMimeTypePara m,
127 &mime_type_param);
123 for (GuestInstanceMap::const_iterator it = 128 for (GuestInstanceMap::const_iterator it =
124 guest_web_contents_by_instance_id_.begin(); 129 guest_web_contents_by_instance_id_.begin();
125 it != guest_web_contents_by_instance_id_.end(); ++it) { 130 it != guest_web_contents_by_instance_id_.end(); ++it) {
126 if (it->second->GetSiteInstance()->GetSiteURL() == guest_site) 131
132 bool guest_found =
133 it->second->GetSiteInstance()->GetSiteURL() == guest_site;
134
135 if (!guest_found && has_mime_type_param) {
136 std::string iter_mime_type_param;
137 bool iter_has_mime_type_param =
138 net::GetValueForKeyInQuery(it->second->GetSiteInstance()->GetSiteURL() ,
139 guestview::kMimeTypeParam,
140 &iter_mime_type_param);
141 if (iter_has_mime_type_param && iter_mime_type_param == mime_type_param) {
142 // If we have a mimeType param specified in the Site URL, we will re-use
143 // guests that has same mimeType.
144 guest_found = true;
145 }
146 }
147
148 if (guest_found)
127 return it->second->GetSiteInstance(); 149 return it->second->GetSiteInstance();
128 } 150 }
129 return NULL; 151 return NULL;
130 } 152 }
131 153
132 bool GuestViewManager::ForEachGuest(WebContents* embedder_web_contents, 154 bool GuestViewManager::ForEachGuest(WebContents* embedder_web_contents,
133 const GuestCallback& callback) { 155 const GuestCallback& callback) {
134 for (GuestInstanceMap::iterator it = 156 for (GuestInstanceMap::iterator it =
135 guest_web_contents_by_instance_id_.begin(); 157 guest_web_contents_by_instance_id_.begin();
136 it != guest_web_contents_by_instance_id_.end(); ++it) { 158 it != guest_web_contents_by_instance_id_.end(); ++it) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 guest_web_contents_by_instance_id_.find(guest_instance_id); 257 guest_web_contents_by_instance_id_.find(guest_instance_id);
236 if (it == guest_web_contents_by_instance_id_.end()) 258 if (it == guest_web_contents_by_instance_id_.end())
237 return true; 259 return true;
238 260
239 GuestViewBase* guest_view = GuestViewBase::FromWebContents(it->second); 261 GuestViewBase* guest_view = GuestViewBase::FromWebContents(it->second);
240 if (!guest_view) 262 if (!guest_view)
241 return false; 263 return false;
242 264
243 return embedder_render_process_id == guest_view->embedder_render_process_id(); 265 return embedder_render_process_id == guest_view->embedder_render_process_id();
244 } 266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698