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

Side by Side Diff: content/shell/webkit_test_controller.cc

Issue 16162003: Introduce content::PageState (again). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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/shell/webkit_test_controller.h" 5 #include "content/shell/webkit_test_controller.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_contents_view.h" 25 #include "content/public/browser/web_contents_view.h"
26 #include "content/shell/common/shell_messages.h" 26 #include "content/shell/common/shell_messages.h"
27 #include "content/shell/common/shell_switches.h" 27 #include "content/shell/common/shell_switches.h"
28 #include "content/shell/common/webkit_test_helpers.h" 28 #include "content/shell/common/webkit_test_helpers.h"
29 #include "content/shell/shell.h" 29 #include "content/shell/shell.h"
30 #include "content/shell/shell_browser_context.h" 30 #include "content/shell/shell_browser_context.h"
31 #include "content/shell/shell_content_browser_client.h" 31 #include "content/shell/shell_content_browser_client.h"
32 #include "webkit/glue/glue_serialize.h"
33 #include "webkit/support/webkit_support_gfx.h" 32 #include "webkit/support/webkit_support_gfx.h"
34 33
35 namespace content { 34 namespace content {
36 35
37 const int kTestTimeoutMilliseconds = 30 * 1000; 36 const int kTestTimeoutMilliseconds = 30 * 1000;
38 // 0x20000000ms is big enough for the purpose to avoid timeout in debugging. 37 // 0x20000000ms is big enough for the purpose to avoid timeout in debugging.
39 const int kCloseEnoughToInfinity = 0x20000000; 38 const int kCloseEnoughToInfinity = 0x20000000;
40 39
41 const int kTestSVGWindowWidthDip = 480; 40 const int kTestSVGWindowWidthDip = 480;
42 const int kTestSVGWindowHeightDip = 360; 41 const int kTestSVGWindowHeightDip = 360;
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 main_window_->Reload(); 560 main_window_->Reload();
562 } 561 }
563 562
564 void WebKitTestController::OnLoadURLForFrame(const GURL& url, 563 void WebKitTestController::OnLoadURLForFrame(const GURL& url,
565 const std::string& frame_name) { 564 const std::string& frame_name) {
566 main_window_->LoadURLForFrame(url, frame_name); 565 main_window_->LoadURLForFrame(url, frame_name);
567 } 566 }
568 567
569 void WebKitTestController::OnCaptureSessionHistory() { 568 void WebKitTestController::OnCaptureSessionHistory() {
570 std::vector<int> routing_ids; 569 std::vector<int> routing_ids;
571 std::vector<std::vector<std::string> > session_histories; 570 std::vector<std::vector<PageState> > session_histories;
572 std::vector<unsigned> current_entry_indexes; 571 std::vector<unsigned> current_entry_indexes;
573 572
574 RenderViewHost* render_view_host = 573 RenderViewHost* render_view_host =
575 main_window_->web_contents()->GetRenderViewHost(); 574 main_window_->web_contents()->GetRenderViewHost();
576 575
577 for (std::vector<Shell*>::iterator window = Shell::windows().begin(); 576 for (std::vector<Shell*>::iterator window = Shell::windows().begin();
578 window != Shell::windows().end(); 577 window != Shell::windows().end();
579 ++window) { 578 ++window) {
580 WebContents* web_contents = (*window)->web_contents(); 579 WebContents* web_contents = (*window)->web_contents();
581 // Only capture the history from windows in the same process as the main 580 // Only capture the history from windows in the same process as the main
582 // window. During layout tests, we only use two processes when an 581 // window. During layout tests, we only use two processes when an
583 // devtools window is open. This should not happen during history navigation 582 // devtools window is open. This should not happen during history navigation
584 // tests. 583 // tests.
585 if (render_view_host->GetProcess() != 584 if (render_view_host->GetProcess() !=
586 web_contents->GetRenderViewHost()->GetProcess()) { 585 web_contents->GetRenderViewHost()->GetProcess()) {
587 NOTREACHED(); 586 NOTREACHED();
588 continue; 587 continue;
589 } 588 }
590 routing_ids.push_back(web_contents->GetRenderViewHost()->GetRoutingID()); 589 routing_ids.push_back(web_contents->GetRenderViewHost()->GetRoutingID());
591 current_entry_indexes.push_back( 590 current_entry_indexes.push_back(
592 web_contents->GetController().GetCurrentEntryIndex()); 591 web_contents->GetController().GetCurrentEntryIndex());
593 std::vector<std::string> history; 592 std::vector<PageState> history;
594 for (int entry = 0; entry < web_contents->GetController().GetEntryCount(); 593 for (int entry = 0; entry < web_contents->GetController().GetEntryCount();
595 ++entry) { 594 ++entry) {
596 std::string state = web_contents->GetController().GetEntryAtIndex(entry) 595 PageState state = web_contents->GetController().GetEntryAtIndex(entry)->
597 ->GetContentState(); 596 GetPageState();
598 if (state.empty()) { 597 if (!state.IsValid()) {
599 state = webkit_glue::CreateHistoryStateForURL( 598 state = PageState::CreateFromURL(
600 web_contents->GetController().GetEntryAtIndex(entry)->GetURL()); 599 web_contents->GetController().GetEntryAtIndex(entry)->GetURL());
601 } 600 }
602 history.push_back(state); 601 history.push_back(state);
603 } 602 }
604 session_histories.push_back(history); 603 session_histories.push_back(history);
605 } 604 }
606 605
607 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), 606 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(),
608 routing_ids, 607 routing_ids,
609 session_histories, 608 session_histories,
610 current_entry_indexes)); 609 current_entry_indexes));
611 } 610 }
612 611
613 void WebKitTestController::OnCloseRemainingWindows() { 612 void WebKitTestController::OnCloseRemainingWindows() {
614 DevToolsManager::GetInstance()->CloseAllClientHosts(); 613 DevToolsManager::GetInstance()->CloseAllClientHosts();
615 std::vector<Shell*> open_windows(Shell::windows()); 614 std::vector<Shell*> open_windows(Shell::windows());
616 for (size_t i = 0; i < open_windows.size(); ++i) { 615 for (size_t i = 0; i < open_windows.size(); ++i) {
617 if (open_windows[i] != main_window_) 616 if (open_windows[i] != main_window_)
618 open_windows[i]->Close(); 617 open_windows[i]->Close();
619 } 618 }
620 base::MessageLoop::current()->RunUntilIdle(); 619 base::MessageLoop::current()->RunUntilIdle();
621 } 620 }
622 621
623 void WebKitTestController::OnResetDone() { 622 void WebKitTestController::OnResetDone() {
624 base::MessageLoop::current()->PostTask(FROM_HERE, 623 base::MessageLoop::current()->PostTask(FROM_HERE,
625 base::MessageLoop::QuitClosure()); 624 base::MessageLoop::QuitClosure());
626 } 625 }
627 626
628 } // namespace content 627 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698