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

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

Issue 496403003: Remove NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_TEST_NOTIFICATION_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
12 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/location_bar/location_bar.h" 15 #include "chrome/browser/ui/location_bar/location_bar.h"
14 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
17 19
18 namespace content { 20 namespace content {
19 class WindowedNotificationObserver; 21 class WindowedNotificationObserver;
20 } 22 }
21 23
22 // Test helper class for observing extension-related events. 24 // Test helper class for observing extension-related events.
23 class ExtensionTestNotificationObserver : public content::NotificationObserver { 25 class ExtensionTestNotificationObserver
26 : public content::NotificationObserver,
27 public extensions::ExtensionActionAPI::Observer {
24 public: 28 public:
25 explicit ExtensionTestNotificationObserver(Browser* browser); 29 explicit ExtensionTestNotificationObserver(Browser* browser);
26 virtual ~ExtensionTestNotificationObserver(); 30 virtual ~ExtensionTestNotificationObserver();
27 31
28 // Wait for the total number of page actions to change to |count|.
29 bool WaitForPageActionCountChangeTo(int count);
30
31 // Wait for the number of visible page actions to change to |count|. 32 // Wait for the number of visible page actions to change to |count|.
32 bool WaitForPageActionVisibilityChangeTo(int count); 33 bool WaitForPageActionVisibilityChangeTo(int count);
33 34
34 // Waits until an extension is installed and loaded. Returns true if an 35 // Waits until an extension is installed and loaded. Returns true if an
35 // install happened before timeout. 36 // install happened before timeout.
36 bool WaitForExtensionInstall(); 37 bool WaitForExtensionInstall();
37 38
38 // Wait for an extension install error to be raised. Returns true if an 39 // Wait for an extension install error to be raised. Returns true if an
39 // error was raised. 40 // error was raised.
40 bool WaitForExtensionInstallError(); 41 bool WaitForExtensionInstallError();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const std::string& last_loaded_extension_id) { 76 const std::string& last_loaded_extension_id) {
76 last_loaded_extension_id_ = last_loaded_extension_id; 77 last_loaded_extension_id_ = last_loaded_extension_id;
77 } 78 }
78 79
79 // content::NotificationObserver 80 // content::NotificationObserver
80 virtual void Observe(int type, 81 virtual void Observe(int type,
81 const content::NotificationSource& source, 82 const content::NotificationSource& source,
82 const content::NotificationDetails& details) OVERRIDE; 83 const content::NotificationDetails& details) OVERRIDE;
83 84
84 private: 85 private:
86 class NotificationSet;
87
85 Profile* GetProfile(); 88 Profile* GetProfile();
86 89
87 void WaitForNotification(int notification_type); 90 void WaitForNotification(int notification_type);
88 91
92 // Wait for |condition_| to be met. |notification_set| is the set of
93 // notifications to wait for and to check |condition| when observing. This
94 // can be NULL if we are instead waiting for a different observer method, like
95 // OnPageActionsUpdated().
96 void WaitForCondition(const base::Callback<bool(void)>& condition,
97 NotificationSet* notification_set);
98
99 // Quits the message loop if |condition_| is met.
100 void MaybeQuit();
101
102 // extensions::ExtensionActionAPI::Observer:
103 virtual void OnPageActionsUpdated(content::WebContents* contents) OVERRIDE;
104
89 Browser* browser_; 105 Browser* browser_;
90 Profile* profile_; 106 Profile* profile_;
91 107
92 content::NotificationRegistrar registrar_; 108 content::NotificationRegistrar registrar_;
93 scoped_ptr<content::WindowedNotificationObserver> observer_; 109 scoped_ptr<content::WindowedNotificationObserver> observer_;
94 110
95 std::string last_loaded_extension_id_; 111 std::string last_loaded_extension_id_;
96 int extension_installs_observed_; 112 int extension_installs_observed_;
97 int extension_load_errors_observed_; 113 int extension_load_errors_observed_;
98 int crx_installers_done_observed_; 114 int crx_installers_done_observed_;
115
116 // The condition for which we are waiting. This should be checked in any
117 // observing methods that could trigger it.
118 base::Callback<bool(void)> condition_;
119
120 // The closure to quit the currently-running message loop.
121 base::Closure quit_closure_;
99 }; 122 };
100 123
101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_ 124 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698