blob: 5f7680a8710247052e7c2ebc06345d8401d9100b (
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
|
// 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_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_
#include <set>
#include <string>
#include "base/basictypes.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "content/public/browser/web_contents_observer.h"
class ExtensionService;
namespace extensions {
class ExtensionSystem;
// Controls the script bubble in the omnibox, which displays information about
// extensions which are interacting with the current tab.
class ScriptBubbleController
: public TabHelper::ScriptExecutionObserver,
public content::WebContentsObserver {
public:
ScriptBubbleController(content::WebContents* web_contents,
TabHelper* tab_helper);
virtual ~ScriptBubbleController();
// Returns a set of extension ids for extensions running content scripts.
const std::set<std::string>& extensions_running_scripts() {
return extensions_running_scripts_;
}
// TabHelper::ScriptExecutionObserver implementation
virtual void OnScriptsExecuted(
const content::WebContents* web_contents,
const ExecutingScriptsMap& extension_ids,
int32 page_id,
const GURL& on_url) OVERRIDE;
// content::WebContentsObserver implementation.
virtual void DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) OVERRIDE;
void OnExtensionUnloaded(const std::string& extension_id);
private:
// Helper to get the profile of the web contents we're associated with.
Profile* profile() const;
// Helper to get the extension service for the profile of the web contents
// we're associated with.
ExtensionService* GetExtensionService() const;
// Helper to update the properties of the script bubble to reflect current
// internal state.
void UpdateScriptBubble();
// The accumulated set of extension IDs that are operating on this tab.
std::set<std::string> extensions_running_scripts_;
DISALLOW_COPY_AND_ASSIGN(ScriptBubbleController);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_
|