Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / navigation_observer.h
blob017acc0b577e41e7b85733c6d9dcdfe2b3e6325d
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_NAVIGATION_OBSERVER_H_
6 #define CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_
8 #include <set>
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 class Profile;
18 namespace content {
19 class NavigationController;
22 namespace extensions {
24 // The NavigationObserver listens to navigation notifications. If the user
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
27 // the extension.
28 class NavigationObserver : public ExtensionInstallPrompt::Delegate,
29 public content::NotificationObserver {
30 public:
31 explicit NavigationObserver(Profile* profile);
32 ~NavigationObserver() override;
34 // content::NotificationObserver
35 void Observe(int type,
36 const content::NotificationSource& source,
37 const content::NotificationDetails& details) override;
39 private:
40 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification.
41 void RegisterForNotifications();
43 // Checks if |nav_controller| has entered an extension's web extent. If it
44 // has and the extension is disabled due to a permissions increase, this
45 // prompts the user to accept the new permissions and enables the extension.
46 void PromptToEnableExtensionIfNecessary(
47 content::NavigationController* nav_controller);
49 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt.
50 void InstallUIProceed() override;
51 void InstallUIAbort(bool user_initiated) override;
53 content::NotificationRegistrar registrar_;
55 Profile* profile_;
57 // The UI used to confirm enabling extensions.
58 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_;
60 // The data we keep track of when prompting to enable extensions.
61 std::string in_progress_prompt_extension_id_;
62 content::NavigationController* in_progress_prompt_navigation_controller_;
64 // The extension ids we've already prompted the user about.
65 std::set<std::string> prompted_extensions_;
67 DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
70 } // namespace extensions
72 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_