Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/extensions/navigation_observer.h

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/extension_install_prompt.h" 14 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace content { 20 namespace content {
20 class NavigationController; 21 class NavigationController;
21 } 22 }
22 23
23 namespace extensions { 24 namespace extensions {
24 25
25 // The NavigationObserver listens to navigation notifications. If the user 26 // The NavigationObserver listens to navigation notifications. If the user
26 // navigates into an extension that has been disabled due to a permission 27 // navigates into an extension that has been disabled due to a permission
27 // increase, it prompts the user to accept the new permissions and re-enables 28 // increase, it prompts the user to accept the new permissions and re-enables
28 // the extension. 29 // the extension.
29 class NavigationObserver : public ExtensionInstallPrompt::Delegate, 30 class NavigationObserver : public content::NotificationObserver {
30 public content::NotificationObserver {
31 public: 31 public:
32 explicit NavigationObserver(Profile* profile); 32 explicit NavigationObserver(Profile* profile);
33 ~NavigationObserver() override; 33 ~NavigationObserver() override;
34 34
35 // content::NotificationObserver 35 // content::NotificationObserver
36 void Observe(int type, 36 void Observe(int type,
37 const content::NotificationSource& source, 37 const content::NotificationSource& source,
38 const content::NotificationDetails& details) override; 38 const content::NotificationDetails& details) override;
39 39
40 private: 40 private:
41 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification. 41 // Registers for the NOTIFICATION_NAV_ENTRY_COMMITTED notification.
42 void RegisterForNotifications(); 42 void RegisterForNotifications();
43 43
44 // Checks if |nav_controller| has entered an extension's web extent. If it 44 // Checks if |nav_controller| has entered an extension's web extent. If it
45 // has and the extension is disabled due to a permissions increase, this 45 // has and the extension is disabled due to a permissions increase, this
46 // prompts the user to accept the new permissions and enables the extension. 46 // prompts the user to accept the new permissions and enables the extension.
47 void PromptToEnableExtensionIfNecessary( 47 void PromptToEnableExtensionIfNecessary(
48 content::NavigationController* nav_controller); 48 content::NavigationController* nav_controller);
49 49
50 // ExtensionInstallPrompt::Delegate callbacks used for the permissions prompt. 50 void OnInstallPromptDone(ExtensionInstallPrompt::Result result);
51 void InstallUIProceed() override;
52 void InstallUIAbort(bool user_initiated) override;
53 51
54 content::NotificationRegistrar registrar_; 52 content::NotificationRegistrar registrar_;
55 53
56 Profile* profile_; 54 Profile* profile_;
57 55
58 // The UI used to confirm enabling extensions. 56 // The UI used to confirm enabling extensions.
59 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_; 57 scoped_ptr<ExtensionInstallPrompt> extension_install_prompt_;
60 58
61 // The data we keep track of when prompting to enable extensions. 59 // The data we keep track of when prompting to enable extensions.
62 std::string in_progress_prompt_extension_id_; 60 std::string in_progress_prompt_extension_id_;
63 content::NavigationController* in_progress_prompt_navigation_controller_; 61 content::NavigationController* in_progress_prompt_navigation_controller_;
64 62
65 // The extension ids we've already prompted the user about. 63 // The extension ids we've already prompted the user about.
66 std::set<std::string> prompted_extensions_; 64 std::set<std::string> prompted_extensions_;
67 65
66 base::WeakPtrFactory<NavigationObserver> weak_factory_;
67
68 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); 68 DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
69 }; 69 };
70 70
71 } // namespace extensions 71 } // namespace extensions
72 72
73 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_ 73 #endif // CHROME_BROWSER_EXTENSIONS_NAVIGATION_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_install_error.cc ('k') | chrome/browser/extensions/navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698