| OLD | NEW |
| 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 | 1565 |
| 1566 // One of the resources that has a WebContents associated with it should have | 1566 // One of the resources that has a WebContents associated with it should have |
| 1567 // the Prerender prefix. | 1567 // the Prerender prefix. |
| 1568 const string16 prefix = | 1568 const string16 prefix = |
| 1569 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, string16()); | 1569 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, string16()); |
| 1570 string16 prerender_title; | 1570 string16 prerender_title; |
| 1571 int num_prerender_tabs = 0; | 1571 int num_prerender_tabs = 0; |
| 1572 | 1572 |
| 1573 const TaskManagerModel* model = GetModel(); | 1573 const TaskManagerModel* model = GetModel(); |
| 1574 for (int i = 0; i < model->ResourceCount(); ++i) { | 1574 for (int i = 0; i < model->ResourceCount(); ++i) { |
| 1575 if (model->GetResourceTabContents(i)) { | 1575 if (model->GetResourceWebContents(i)) { |
| 1576 prerender_title = model->GetResourceTitle(i); | 1576 prerender_title = model->GetResourceTitle(i); |
| 1577 if (StartsWith(prerender_title, prefix, true)) | 1577 if (StartsWith(prerender_title, prefix, true)) |
| 1578 ++num_prerender_tabs; | 1578 ++num_prerender_tabs; |
| 1579 } | 1579 } |
| 1580 } | 1580 } |
| 1581 EXPECT_EQ(1, num_prerender_tabs); | 1581 EXPECT_EQ(1, num_prerender_tabs); |
| 1582 const string16 prerender_page_title = prerender_title.substr(prefix.length()); | 1582 const string16 prerender_page_title = prerender_title.substr(prefix.length()); |
| 1583 | 1583 |
| 1584 NavigateToDestURL(); | 1584 NavigateToDestURL(); |
| 1585 | 1585 |
| 1586 // There should be no tabs with the Prerender prefix. | 1586 // There should be no tabs with the Prerender prefix. |
| 1587 const string16 tab_prefix = | 1587 const string16 tab_prefix = |
| 1588 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, string16()); | 1588 l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, string16()); |
| 1589 num_prerender_tabs = 0; | 1589 num_prerender_tabs = 0; |
| 1590 int num_tabs_with_prerender_page_title = 0; | 1590 int num_tabs_with_prerender_page_title = 0; |
| 1591 for (int i = 0; i < model->ResourceCount(); ++i) { | 1591 for (int i = 0; i < model->ResourceCount(); ++i) { |
| 1592 if (model->GetResourceTabContents(i)) { | 1592 if (model->GetResourceWebContents(i)) { |
| 1593 string16 tab_title = model->GetResourceTitle(i); | 1593 string16 tab_title = model->GetResourceTitle(i); |
| 1594 if (StartsWith(tab_title, prefix, true)) { | 1594 if (StartsWith(tab_title, prefix, true)) { |
| 1595 ++num_prerender_tabs; | 1595 ++num_prerender_tabs; |
| 1596 } else { | 1596 } else { |
| 1597 EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true)); | 1597 EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true)); |
| 1598 | 1598 |
| 1599 // The prerender tab should now be a normal tab but the title should be | 1599 // The prerender tab should now be a normal tab but the title should be |
| 1600 // the same. Depending on timing, there may be more than one of these. | 1600 // the same. Depending on timing, there may be more than one of these. |
| 1601 const string16 tab_page_title = tab_title.substr(tab_prefix.length()); | 1601 const string16 tab_page_title = tab_title.substr(tab_prefix.length()); |
| 1602 if (prerender_page_title.compare(tab_page_title) == 0) | 1602 if (prerender_page_title.compare(tab_page_title) == 0) |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 ResultCatcher catcher; | 2381 ResultCatcher catcher; |
| 2382 | 2382 |
| 2383 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 2383 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
| 2384 NavigateToDestURL(); | 2384 NavigateToDestURL(); |
| 2385 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 2385 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
| 2386 | 2386 |
| 2387 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 2387 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 } // namespace prerender | 2390 } // namespace prerender |
| OLD | NEW |