| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_NAVIGATION_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 // The NavigationObserver listens to navigation notifications. If the user | 24 // The NavigationObserver listens to navigation notifications. If the user |
| 25 // navigates into an extension that has been disabled due to a permission | 25 // navigates into an extension that has been disabled due to a permission |
| 26 // increase, it prompts the user to accept the new permissions and re-enables | 26 // increase, it prompts the user to accept the new permissions and re-enables |
| 27 // the extension. | 27 // the extension. |
| 28 class NavigationObserver : public ExtensionInstallPrompt::Delegate, | 28 class NavigationObserver : public ExtensionInstallPrompt::Delegate, |
| 29 public content::NotificationObserver { | 29 public content::NotificationObserver { |
| 30 public: | 30 public: |
| 31 explicit NavigationObserver(Profile* profile); | 31 explicit NavigationObserver(Profile* profile); |
| 32 virtual ~NavigationObserver(); | 32 ~NavigationObserver() override; |
| 33 | 33 |
| 34 // content::NotificationObserver | 34 // content::NotificationObserver |
| 35 virtual void Observe(int type, | 35 void Observe(int type, |
| 36 const content::NotificationSource& source, | 36 const content::NotificationSource& source, |
| 37 const content::NotificationDetails& details) override; | 37 const content::NotificationDetails& details) override; |
| 38 |
| 38 private: | 39 private: |
| 39 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification. | 40 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification. |
| 40 void RegisterForNotifications(); | 41 void RegisterForNotifications(); |
| 41 | 42 |
| 42 // Checks if |nav_controller| has entered an extension's web extent. If it | 43 // Checks if |nav_controller| has entered an extension's web extent. If it |
| 43 // has and the extension is disabled due to a permissions increase, this | 44 // has and the extension is disabled due to a permissions increase, this |
| 44 // prompts the user to accept the new permissions and enables the extension. | 45 // prompts the user to accept the new permissions and enables the extension. |
| 45 void PromptToEnableExtensionIfNecessary( | 46 void PromptToEnableExtensionIfNecessary( |
| 46 content::NavigationController* nav_controller); | 47 content::NavigationController* nav_controller); |
| 47 | 48 |
| 48 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt. | 49 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt. |
| 49 virtual void InstallUIProceed() override; | 50 void InstallUIProceed() override; |
| 50 virtual void InstallUIAbort(bool user_initiated) override; | 51 void InstallUIAbort(bool user_initiated) override; |
| 51 | 52 |
| 52 content::NotificationRegistrar registrar_; | 53 content::NotificationRegistrar registrar_; |
| 53 | 54 |
| 54 Profile* profile_; | 55 Profile* profile_; |
| 55 | 56 |
| 56 // The UI used to confirm enabling extensions. | 57 // The UI used to confirm enabling extensions. |
| 57 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_; | 58 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_; |
| 58 | 59 |
| 59 // The data we keep track of when prompting to enable extensions. | 60 // The data we keep track of when prompting to enable extensions. |
| 60 std::string in_progress_prompt_extension_id_; | 61 std::string in_progress_prompt_extension_id_; |
| 61 content::NavigationController* in_progress_prompt_navigation_controller_; | 62 content::NavigationController* in_progress_prompt_navigation_controller_; |
| 62 | 63 |
| 63 // The extension ids we've already prompted the user about. | 64 // The extension ids we've already prompted the user about. |
| 64 std::set<std::string> prompted_extensions_; | 65 std::set<std::string> prompted_extensions_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); | 67 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 } // namespace extensions | 70 } // namespace extensions |
| 70 | 71 |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |