OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/site_details.h" | 5 #include "chrome/browser/site_details.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <utility> | 11 #include <utility> |
| 12 #include <vector> |
11 | 13 |
12 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 16 #include "base/macros.h" |
15 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
16 #include "base/path_service.h" | 18 #include "base/path_service.h" |
17 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
18 #include "base/test/histogram_tester.h" | 20 #include "base/test/histogram_tester.h" |
19 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/extensions/extension_browsertest.h" | 22 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 base::StringPrintf( | 233 base::StringPrintf( |
232 "<html><body>%s, two http:// iframes:" | 234 "<html><body>%s, two http:// iframes:" |
233 " <iframe width=80 height=80 src='%s'></iframe>" | 235 " <iframe width=80 height=80 src='%s'></iframe>" |
234 " <iframe width=80 height=80 src='%s'></iframe>" | 236 " <iframe width=80 height=80 src='%s'></iframe>" |
235 "</body></html>", | 237 "</body></html>", |
236 name.c_str(), iframe_url.c_str(), iframe_url2.c_str())); | 238 name.c_str(), iframe_url.c_str(), iframe_url2.c_str())); |
237 dir->WriteManifest(manifest.ToJSON()); | 239 dir->WriteManifest(manifest.ToJSON()); |
238 | 240 |
239 const Extension* extension = LoadExtension(dir->UnpackedPath()); | 241 const Extension* extension = LoadExtension(dir->UnpackedPath()); |
240 EXPECT_TRUE(extension); | 242 EXPECT_TRUE(extension); |
241 temp_dirs_.push_back(dir.release()); | 243 temp_dirs_.push_back(std::move(dir)); |
242 return extension; | 244 return extension; |
243 } | 245 } |
244 | 246 |
245 // Creates a V2 platform app that loads a web iframe in the app's sandbox | 247 // Creates a V2 platform app that loads a web iframe in the app's sandbox |
246 // page. | 248 // page. |
247 // TODO(lazyboy): Deprecate this behavior in https://crbug.com/615585. | 249 // TODO(lazyboy): Deprecate this behavior in https://crbug.com/615585. |
248 void CreateAppWithSandboxPage(const std::string& name) { | 250 void CreateAppWithSandboxPage(const std::string& name) { |
249 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); | 251 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
250 | 252 |
251 DictionaryBuilder manifest; | 253 DictionaryBuilder manifest; |
(...skipping 23 matching lines...) Expand all Loading... |
275 dir->WriteFile( | 277 dir->WriteFile( |
276 FILE_PATH_LITERAL("sandbox.html"), | 278 FILE_PATH_LITERAL("sandbox.html"), |
277 base::StringPrintf("<html><body>%s, web iframe:" | 279 base::StringPrintf("<html><body>%s, web iframe:" |
278 " <iframe width=80 height=80 src=%s></iframe>" | 280 " <iframe width=80 height=80 src=%s></iframe>" |
279 "</body></html>", | 281 "</body></html>", |
280 name.c_str(), iframe_url.c_str())); | 282 name.c_str(), iframe_url.c_str())); |
281 dir->WriteManifest(manifest.ToJSON()); | 283 dir->WriteManifest(manifest.ToJSON()); |
282 | 284 |
283 const Extension* extension = LoadExtension(dir->UnpackedPath()); | 285 const Extension* extension = LoadExtension(dir->UnpackedPath()); |
284 EXPECT_TRUE(extension); | 286 EXPECT_TRUE(extension); |
285 temp_dirs_.push_back(dir.release()); | 287 temp_dirs_.push_back(std::move(dir)); |
286 } | 288 } |
287 | 289 |
288 const Extension* CreateHostedApp(const std::string& name, | 290 const Extension* CreateHostedApp(const std::string& name, |
289 const GURL& app_url) { | 291 const GURL& app_url) { |
290 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); | 292 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir); |
291 | 293 |
292 DictionaryBuilder manifest; | 294 DictionaryBuilder manifest; |
293 manifest.Set("name", name) | 295 manifest.Set("name", name) |
294 .Set("version", "1.0") | 296 .Set("version", "1.0") |
295 .Set("manifest_version", 2) | 297 .Set("manifest_version", 2) |
296 .Set( | 298 .Set( |
297 "app", | 299 "app", |
298 DictionaryBuilder() | 300 DictionaryBuilder() |
299 .Set("urls", ListBuilder().Append(app_url.spec()).Build()) | 301 .Set("urls", ListBuilder().Append(app_url.spec()).Build()) |
300 .Set("launch", | 302 .Set("launch", |
301 DictionaryBuilder().Set("web_url", app_url.spec()).Build()) | 303 DictionaryBuilder().Set("web_url", app_url.spec()).Build()) |
302 .Build()); | 304 .Build()); |
303 dir->WriteManifest(manifest.ToJSON()); | 305 dir->WriteManifest(manifest.ToJSON()); |
304 | 306 |
305 const Extension* extension = LoadExtension(dir->UnpackedPath()); | 307 const Extension* extension = LoadExtension(dir->UnpackedPath()); |
306 EXPECT_TRUE(extension); | 308 EXPECT_TRUE(extension); |
307 temp_dirs_.push_back(dir.release()); | 309 temp_dirs_.push_back(std::move(dir)); |
308 return extension; | 310 return extension; |
309 } | 311 } |
310 | 312 |
311 int GetRenderProcessCount() { | 313 int GetRenderProcessCount() { |
312 int count = 0; | 314 int count = 0; |
313 for (content::RenderProcessHost::iterator it( | 315 for (content::RenderProcessHost::iterator it( |
314 content::RenderProcessHost::AllHostsIterator()); | 316 content::RenderProcessHost::AllHostsIterator()); |
315 !it.IsAtEnd(); it.Advance()) { | 317 !it.IsAtEnd(); it.Advance()) { |
316 count++; | 318 count++; |
317 } | 319 } |
(...skipping 28 matching lines...) Expand all Loading... |
346 | 348 |
347 for (const auto& entry : synthetic_trials) { | 349 for (const auto& entry : synthetic_trials) { |
348 if (trial == entry.name && group == entry.group) | 350 if (trial == entry.name && group == entry.group) |
349 return true; | 351 return true; |
350 } | 352 } |
351 | 353 |
352 return false; | 354 return false; |
353 } | 355 } |
354 | 356 |
355 private: | 357 private: |
356 ScopedVector<TestExtensionDir> temp_dirs_; | 358 std::vector<std::unique_ptr<TestExtensionDir>> temp_dirs_; |
357 DISALLOW_COPY_AND_ASSIGN(SiteDetailsBrowserTest); | 359 DISALLOW_COPY_AND_ASSIGN(SiteDetailsBrowserTest); |
358 }; | 360 }; |
359 | 361 |
360 | 362 |
361 // Test the accuracy of SiteDetails process estimation, in the presence of | 363 // Test the accuracy of SiteDetails process estimation, in the presence of |
362 // multiple iframes, navigation, multiple BrowsingInstances, and multiple tabs | 364 // multiple iframes, navigation, multiple BrowsingInstances, and multiple tabs |
363 // in the same BrowsingInstance. | 365 // in the same BrowsingInstance. |
364 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ManyIframes) { | 366 IN_PROC_BROWSER_TEST_F(SiteDetailsBrowserTest, ManyIframes) { |
365 // Page with 14 nested oopifs across 9 sites (a.com through i.com). | 367 // Page with 14 nested oopifs across 9 sites (a.com through i.com). |
366 // None of these are https. | 368 // None of these are https. |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 content::NavigateIframeToURL( | 1295 content::NavigateIframeToURL( |
1294 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); | 1296 tab, "child-1", extension2->GetResourceURL("/blank_iframe.html")); |
1295 details = new TestMemoryDetails(); | 1297 details = new TestMemoryDetails(); |
1296 details->StartFetchAndWait(); | 1298 details->StartFetchAndWait(); |
1297 EXPECT_THAT(details->uma()->GetAllSamples( | 1299 EXPECT_THAT(details->uma()->GetAllSamples( |
1298 "SiteIsolation.SiteInstancesPerBrowsingInstance"), | 1300 "SiteIsolation.SiteInstancesPerBrowsingInstance"), |
1299 DependingOnPolicy(ElementsAre(Bucket(1, 2)), | 1301 DependingOnPolicy(ElementsAre(Bucket(1, 2)), |
1300 ElementsAre(Bucket(1, 1), Bucket(3, 1)), | 1302 ElementsAre(Bucket(1, 1), Bucket(3, 1)), |
1301 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); | 1303 ElementsAre(Bucket(1, 1), Bucket(5, 1)))); |
1302 } | 1304 } |
OLD | NEW |