blob: d58fdc7849036b51b05017579e1289f8093af0d2 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2006-2009 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
#include "build/build_config.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/extensions/extension_host.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
// TODO(port): Port these files.
#if defined(OS_WIN)
#include "views/controls/hwnd_view.h"
#else
#include "views/view.h"
#include "chrome/common/temp_scaffolding_stubs.h"
#endif
class Browser;
class Extension;
// This handles the display portion of an ExtensionHost.
class ExtensionView : public views::HWNDView {
public:
ExtensionView(ExtensionHost* host, Browser* browser, const GURL& content_url);
~ExtensionView();
ExtensionHost* host() const { return host_.get(); }
Browser* browser() const { return browser_; }
Extension* extension() { return host_->extension(); }
RenderViewHost* render_view_host() { return host_->render_view_host(); }
// Notification from ExtensionHost.
void DidContentsPreferredWidthChange(const int pref_width);
// Set a custom background for the view. The background will be tiled.
void SetBackground(const SkBitmap& background);
// views::HWNDView
virtual void SetVisible(bool is_visible);
virtual void DidChangeBounds(const gfx::Rect& previous,
const gfx::Rect& current);
virtual void ViewHierarchyChanged(bool is_add,
views::View *parent, views::View *child);
private:
friend class ExtensionHost;
// We wait to show the ExtensionView until several things have loaded.
void ShowIfCompletelyLoaded();
// The running extension instance that we're displaying.
scoped_ptr<ExtensionHost> host_;
// The browser window that this view is in.
Browser* browser_;
// The URL to navigate the host to upon initialization.
GURL content_url_;
// True if we've been initialized.
bool initialized_;
// The background the view should have once it is initialized. This is set
// when the view has a custom background, but hasn't been initialized yet.
SkBitmap pending_background_;
// What we should set the preferred width to once the ExtensionView has
// loaded.
int pending_preferred_width_;
DISALLOW_COPY_AND_ASSIGN(ExtensionView);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_
|