summaryrefslogtreecommitdiffstats
path: root/content/shell/layout_test_controller_host.h
blob: 733dfc9c8dc9b5c88670d9d9082a6fb170113ad5 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2012 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.

#ifndef CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_
#define CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_
#pragma once

#include <map>
#include <string>

#include "content/public/browser/render_view_host_observer.h"

namespace content {

class LayoutTestControllerHost : public RenderViewHostObserver {
 public:
  static LayoutTestControllerHost* FromRenderViewHost(
      RenderViewHost* render_view_host);

  explicit LayoutTestControllerHost(RenderViewHost* render_view_host);
  virtual ~LayoutTestControllerHost();

  bool should_stay_on_page_after_handling_before_unload() const {
    return should_stay_on_page_after_handling_before_unload_;
  }

  // RenderViewHostObserver implementation.
  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

 private:
  void CaptureDump();

  // Message handlers.
  void OnDidFinishLoad();
  void OnTextDump(const std::string& dump);

  // layoutTestController handlers.
  void OnNotifyDone();
  void OnDumpAsText();
  void OnDumpChildFramesAsText();
  void OnSetPrinting();
  void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
  void OnWaitUntilDone();

  static std::map<RenderViewHost*, LayoutTestControllerHost*> controllers_;

  bool dump_as_text_;
  bool dump_child_frames_;
  bool is_printing_;
  bool should_stay_on_page_after_handling_before_unload_;
  bool wait_until_done_;

  DISALLOW_COPY_AND_ASSIGN(LayoutTestControllerHost);
};

}  // namespace content

#endif  // CONTENT_SHELL_LAYOUT_TEST_CONTROLLER_HOST_H_