Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / navigation_observer.h
blobacf78ad1d8623fca85136239d848435797364f6c
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 virtual ~NavigationObserver();
34 // content::NotificationObserver
35 virtual void Observe(int type,
36 const content::NotificationSource& source,
37 const content::NotificationDetails& details) OVERRIDE;
38 private:
39 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification.
40 void RegisterForNotifications();
42 // 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 // prompts the user to accept the new permissions and enables the extension.
45 void PromptToEnableExtensionIfNecessary(
46 content::NavigationController* nav_controller);
48 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt.
49 virtual void InstallUIProceed() OVERRIDE;
50 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
52 content::NotificationRegistrar registrar_;
54 Profile* profile_;
56 // The UI used to confirm enabling extensions.
57 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_;
59 // The data we keep track of when prompting to enable extensions.
60 std::string in_progress_prompt_extension_id_;
61 content::NavigationController* in_progress_prompt_navigation_controller_;
63 // The extension ids we've already prompted the user about.
64 std::set<std::string> prompted_extensions_;
66 DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_