summaryrefslogtreecommitdiffstats
path: root/chrome/test/test_tab_contents.cc
blob: 1ee16fb2ebac2130c885aafb750bb04bf8c838e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/test/test_tab_contents.h"

#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/common/render_messages.h"

// static
SiteInstance* TestTabContents::site_instance_ = NULL;

TestTabContents::TestTabContents(TabContentsType type)
    : TabContents(type),
      commit_on_navigate_(false),
      next_page_id_(1) {
}

bool TestTabContents::NavigateToPendingEntry(bool reload) {
  if (commit_on_navigate_) {
    CompleteNavigationAsRenderer(next_page_id_++,
                                 controller()->GetPendingEntry()->url());
  }
  return true;
}

void TestTabContents::CompleteNavigationAsRenderer(int page_id,
                                                   const GURL& url) {
  ViewHostMsg_FrameNavigate_Params params;
  params.page_id = page_id;
  params.url = url;
  params.transition = PageTransition::LINK;
  params.should_update_history = false;
  params.gesture = NavigationGestureUser;
  params.is_post = false;

  NavigationController::LoadCommittedDetails details;
  controller()->RendererDidNavigate(params, &details);
}