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