summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/dom_view.h
blob: 27d94342321e0ae0068ba2718dce6665329d48d8 (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) 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.

// DOMView is a ChromeView that displays the content of a web DOM.
// It should be used with data: URLs.

#ifndef CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_
#pragma once

#include "base/scoped_ptr.h"
#include "googleurl/src/gurl.h"
#include "views/controls/native/native_view_host.h"
#include "views/event.h"

class Profile;
class SiteInstance;
class TabContents;

class DOMView : public views::NativeViewHost {
 public:
  DOMView();
  virtual ~DOMView();

  // Initialize the view, creating the contents. This should be
  // called once the view has been added to a container.
  //
  // If |instance| is not null, then the view will be loaded in the same
  // process as the given instance.
  bool Init(Profile* profile, SiteInstance* instance);

  // Loads the given URL into the page. You must have previously called Init().
  void LoadURL(const GURL& url);

  // The tab contents displaying the actual contents.
  TabContents* tab_contents() const { return tab_contents_.get(); }

 protected:
  // Overridden from View.
  virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e);
  virtual void Focus();
  virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
                                    views::View* child);

  // Returns new allocated TabContents instance, caller is responsible deleting.
  // Override in derived classes to replace TabContents with derivative.
  virtual TabContents* CreateTabContents(Profile* profile,
                                         SiteInstance* instance);

  scoped_ptr<TabContents> tab_contents_;

 private:
  bool initialized_;

  DISALLOW_COPY_AND_ASSIGN(DOMView);
};

#endif  // CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_