blob: 83dc9cca53fcdf5e5b2dc66b5fb14350dd7bc696 (
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// 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 CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
#define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
class Balloon;
class Browser;
namespace content {
class SiteInstance;
};
class BalloonHost : public content::WebContentsDelegate,
public content::WebContentsObserver,
public ExtensionFunctionDispatcher::Delegate {
public:
explicit BalloonHost(Balloon* balloon);
// Initialize the view.
void Init();
// Stops showing the balloon.
void Shutdown();
// ExtensionFunctionDispatcher::Delegate overrides.
virtual extensions::WindowController* GetExtensionWindowController()
const OVERRIDE;
virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
const string16& GetSource() const;
content::WebContents* web_contents() const { return web_contents_.get(); }
// Enable Web UI. This has to be called before renderer is created.
void EnableWebUI();
// Returns whether the associated render view is ready. Used only for testing.
bool IsRenderViewReady() const;
// content::WebContentsDelegate implementation:
virtual bool CanLoadDataURLsInWebUI() const OVERRIDE;
protected:
virtual ~BalloonHost();
scoped_ptr<content::WebContents> web_contents_;
private:
// content::WebContentsDelegate implementation:
virtual void CloseContents(content::WebContents* source) OVERRIDE;
virtual void HandleMouseDown() OVERRIDE;
virtual void ResizeDueToAutoResize(content::WebContents* source,
const gfx::Size& pref_size) OVERRIDE;
virtual void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) OVERRIDE;
// content::WebContentsObserver implementation:
virtual void RenderViewCreated(
content::RenderViewHost* render_view_host) OVERRIDE;
virtual void RenderViewReady() OVERRIDE;
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// Message handlers
void OnRequest(const ExtensionHostMsg_Request_Params& params);
// Called to send an event that the balloon has been disconnected from
// a renderer (if should_notify_on_disconnect_ is true).
void NotifyDisconnect();
// Non-owned pointer to the associated balloon.
Balloon* balloon_;
// True after Init() has completed.
bool initialized_;
// Indicates whether we should notify about disconnection of this balloon.
// This is used to ensure disconnection notifications only happen if
// a connection notification has happened and that they happen only once.
bool should_notify_on_disconnect_;
// Site instance for the balloon/profile, to be used for opening new links.
scoped_refptr<content::SiteInstance> site_instance_;
// A flag to enable Web UI.
bool enable_web_ui_;
ExtensionFunctionDispatcher extension_function_dispatcher_;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
|