• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "base/observer_list.h"
12 #include "chrome/browser/extensions/location_bar_controller.h"
13 #include "content/public/browser/web_contents_observer.h"
14 
15 class ExtensionService;
16 class Profile;
17 
18 namespace extensions {
19 
20 // A LocationBarController which populates the location bar with icons based
21 // on the page_action extension API.
22 class PageActionController : public LocationBarController,
23                              public content::WebContentsObserver {
24  public:
25   explicit PageActionController(content::WebContents* web_contents);
26   virtual ~PageActionController();
27 
28   // LocationBarController implementation.
29   virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE;
30   // Page actions can't try to get attention.
GetAttentionFor(const std::string & extension_id)31   virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE {}
32   virtual Action OnClicked(const std::string& extension_id,
33                            int mouse_button) OVERRIDE;
34   virtual void NotifyChange() OVERRIDE;
35 
36   // content::WebContentsObserver implementation.
37   virtual void DidNavigateMainFrame(
38       const content::LoadCommittedDetails& details,
39       const content::FrameNavigateParams& params) OVERRIDE;
40 
41  private:
42   // Gets the Profile for the web contents.
43   Profile* profile() const;
44 
45   // Gets the ExtensionService for the web contents.
46   ExtensionService* GetExtensionService() const;
47 
48   DISALLOW_COPY_AND_ASSIGN(PageActionController);
49 };
50 
51 }  // namespace extensions
52 
53 #endif  // CHROME_BROWSER_EXTENSIONS_PAGE_ACTION_CONTROLLER_H_
54