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

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

Issue 272573005: <webview>: Move NewWindow API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_rename
Patch Set: Cleanup and fix tests Created 6 years, 7 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 "content/browser/browser_plugin/test_guest_manager.h" 5 #include "content/browser/browser_plugin/test_guest_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "content/browser/browser_plugin/browser_plugin_guest.h"
12 #include "content/browser/browser_plugin/test_browser_plugin_guest_delegate.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/browser/site_instance.h" 14 #include "content/public/browser/site_instance.h"
13 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
16 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
17 #include "net/base/escape.h" 19 #include "net/base/escape.h"
18 20
19 namespace content { 21 namespace content {
20 22
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // that webview tags are also not allowed to send messages across 95 // that webview tags are also not allowed to send messages across
94 // different partitions. 96 // different partitions.
95 guest_site_instance = SiteInstance::CreateForURL( 97 guest_site_instance = SiteInstance::CreateForURL(
96 embedder_site_instance->GetBrowserContext(), guest_site); 98 embedder_site_instance->GetBrowserContext(), guest_site);
97 } 99 }
98 WebContents::CreateParams create_params( 100 WebContents::CreateParams create_params(
99 embedder_site_instance->GetBrowserContext(), 101 embedder_site_instance->GetBrowserContext(),
100 guest_site_instance); 102 guest_site_instance);
101 create_params.guest_instance_id = instance_id; 103 create_params.guest_instance_id = instance_id;
102 create_params.guest_extra_params.reset(extra_params.release()); 104 create_params.guest_extra_params.reset(extra_params.release());
103 WebContents* guest_web_contents = WebContents::Create(create_params); 105 WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>(
106 WebContents::Create(create_params));
107 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest();
108 guest_web_contents->GetBrowserPluginGuest()->SetDelegate(
109 new TestBrowserPluginGuestDelegate(guest));
104 AddGuest(instance_id, guest_web_contents); 110 AddGuest(instance_id, guest_web_contents);
105 return guest_web_contents; 111 return guest_web_contents;
106 } 112 }
107 113
108 int TestGuestManager::GetNextInstanceID() { 114 int TestGuestManager::GetNextInstanceID() {
109 return ++next_instance_id_; 115 return ++next_instance_id_;
110 } 116 }
111 117
112 void TestGuestManager::AddGuest( 118 void TestGuestManager::AddGuest(
113 int guest_instance_id, 119 int guest_instance_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 158 }
153 return NULL; 159 return NULL;
154 } 160 }
155 161
156 bool TestGuestManager::ForEachGuest( 162 bool TestGuestManager::ForEachGuest(
157 WebContents* embedder_web_contents, 163 WebContents* embedder_web_contents,
158 const GuestCallback& callback) { 164 const GuestCallback& callback) {
159 for (GuestInstanceMap::iterator it = 165 for (GuestInstanceMap::iterator it =
160 guest_web_contents_by_instance_id_.begin(); 166 guest_web_contents_by_instance_id_.begin();
161 it != guest_web_contents_by_instance_id_.end(); ++it) { 167 it != guest_web_contents_by_instance_id_.end(); ++it) {
162 WebContents* guest = it->second; 168 WebContentsImpl* guest_web_contents =
163 if (embedder_web_contents != guest->GetEmbedderWebContents()) 169 static_cast<WebContentsImpl*>(it->second);
170 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest();
171 if (embedder_web_contents != guest->embedder_web_contents())
164 continue; 172 continue;
165 173
166 if (callback.Run(guest)) 174 if (callback.Run(guest_web_contents))
167 return true; 175 return true;
168 } 176 }
169 return false; 177 return false;
170 } 178 }
171 179
172 } // namespace content 180 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698