OLD | NEW |
| (Empty) |
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_EXTENSION_NAVIGATION_OBSERVER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_NAVIGATION_OBSERVER_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chrome/browser/extensions/extension_install_prompt.h" | |
13 #include "content/public/browser/notification_registrar.h" | |
14 | |
15 class Profile; | |
16 | |
17 namespace content { | |
18 class NavigationController; | |
19 } | |
20 | |
21 // The ExtensionNavigationObserver listens to navigation notifications. If the | |
22 // user navigates into an extension that has been disabled due to a permission | |
23 // increase, it prompts the user to accept the new permissions and re-enables | |
24 // the extension. | |
25 class ExtensionNavigationObserver : public ExtensionInstallPrompt::Delegate, | |
26 public content::NotificationObserver { | |
27 public: | |
28 explicit ExtensionNavigationObserver(Profile* profile); | |
29 virtual ~ExtensionNavigationObserver(); | |
30 | |
31 // content::NotificationObserver | |
32 virtual void Observe(int type, | |
33 const content::NotificationSource& source, | |
34 const content::NotificationDetails& details) OVERRIDE; | |
35 private: | |
36 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification. | |
37 void RegisterForNotifications(); | |
38 | |
39 // Checks if |nav_controller| has entered an extension's web extent. If it | |
40 // has and the extension is disabled due to a permissions increase, this | |
41 // prompts the user to accept the new permissions and enables the extension. | |
42 void PromptToEnableExtensionIfNecessary( | |
43 content::NavigationController* nav_controller); | |
44 | |
45 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt. | |
46 virtual void InstallUIProceed() OVERRIDE; | |
47 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | |
48 | |
49 content::NotificationRegistrar registrar_; | |
50 | |
51 Profile* profile_; | |
52 | |
53 // The UI used to confirm enabling extensions. | |
54 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_; | |
55 | |
56 // The data we keep track of when prompting to enable extensions. | |
57 std::string in_progress_prompt_extension_id_; | |
58 content::NavigationController* in_progress_prompt_navigation_controller_; | |
59 | |
60 // The extension ids we've already prompted the user about. | |
61 std::set<std::string> prompted_extensions_; | |
62 }; | |
63 | |
64 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_NAVIGATION_OBSERVER_H_ | |
OLD | NEW |