1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_
11 #include "base/basictypes.h"
12 #include "chrome/browser/extensions/tab_helper.h"
13 #include "content/public/browser/web_contents_observer.h"
15 class ExtensionService
;
17 namespace extensions
{
19 class ExtensionSystem
;
21 // Controls the script bubble in the omnibox, which displays information about
22 // extensions which are interacting with the current tab.
23 class ScriptBubbleController
24 : public TabHelper::ScriptExecutionObserver
,
25 public content::WebContentsObserver
{
27 ScriptBubbleController(content::WebContents
* web_contents
,
28 TabHelper
* tab_helper
);
29 virtual ~ScriptBubbleController();
31 // Returns a set of extension ids for extensions running content scripts.
32 const std::set
<std::string
>& extensions_running_scripts() {
33 return extensions_running_scripts_
;
36 // TabHelper::ScriptExecutionObserver implementation
37 virtual void OnScriptsExecuted(
38 const content::WebContents
* web_contents
,
39 const ExecutingScriptsMap
& extension_ids
,
41 const GURL
& on_url
) OVERRIDE
;
43 // content::WebContentsObserver implementation.
44 virtual void DidNavigateMainFrame(
45 const content::LoadCommittedDetails
& details
,
46 const content::FrameNavigateParams
& params
) OVERRIDE
;
48 void OnExtensionUnloaded(const std::string
& extension_id
);
51 // Helper to get the profile of the web contents we're associated with.
52 Profile
* profile() const;
54 // Helper to get the extension service for the profile of the web contents
55 // we're associated with.
56 ExtensionService
* GetExtensionService() const;
58 // Helper to update the properties of the script bubble to reflect current
60 void UpdateScriptBubble();
62 // The accumulated set of extension IDs that are operating on this tab.
63 std::set
<std::string
> extensions_running_scripts_
;
65 DISALLOW_COPY_AND_ASSIGN(ScriptBubbleController
);
68 } // namespace extensions
70 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BUBBLE_CONTROLLER_H_