Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_test_notification_observer.h
blob14636b6675b22757e26c54261eeba94b37b30b52
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/omnibox/location_bar.h"
14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_types.h"
18 namespace content {
19 class WindowedNotificationObserver;
22 // Test helper class for observing extension-related events.
23 class ExtensionTestNotificationObserver : public content::NotificationObserver {
24 public:
25 explicit ExtensionTestNotificationObserver(Browser* browser);
26 virtual ~ExtensionTestNotificationObserver();
28 // Wait for the total number of page actions to change to |count|.
29 bool WaitForPageActionCountChangeTo(int count);
31 // Wait for the number of visible page actions to change to |count|.
32 bool WaitForPageActionVisibilityChangeTo(int count);
34 // Waits until an extension is installed and loaded. Returns true if an
35 // install happened before timeout.
36 bool WaitForExtensionInstall();
38 // Wait for an extension install error to be raised. Returns true if an
39 // error was raised.
40 bool WaitForExtensionInstallError();
42 // Waits until an extension is loaded and all view have loaded.
43 void WaitForExtensionAndViewLoad();
45 // Waits until an extension is loaded.
46 void WaitForExtensionLoad();
48 // Waits for an extension load error. Returns true if the error really
49 // happened.
50 bool WaitForExtensionLoadError();
52 // Wait for the specified extension to crash. Returns true if it really
53 // crashed.
54 bool WaitForExtensionCrash(const std::string& extension_id);
56 // Wait for the crx installer to be done. Returns true if it really is done.
57 bool WaitForCrxInstallerDone();
59 // Wait for all extension views to load.
60 bool WaitForExtensionViewsToLoad();
62 // Watch for the given event type from the given source.
63 // After calling this method, call Wait() to ensure that RunMessageLoop() is
64 // called appropriately and cleanup is performed.
65 void Watch(int type, const content::NotificationSource& source);
67 // After registering one or more event types with Watch(), call
68 // this method to run the message loop and perform cleanup.
69 void Wait();
71 const std::string& last_loaded_extension_id() {
72 return last_loaded_extension_id_;
74 void set_last_loaded_extension_id(std::string last_loaded_extension_id) {
75 last_loaded_extension_id_ = last_loaded_extension_id;
78 // content::NotificationObserver
79 virtual void Observe(int type,
80 const content::NotificationSource& source,
81 const content::NotificationDetails& details) OVERRIDE;
83 private:
84 Profile* GetProfile();
86 void WaitForNotification(int notification_type);
88 Browser* browser_;
89 Profile* profile_;
91 content::NotificationRegistrar registrar_;
92 scoped_ptr<content::WindowedNotificationObserver> observer_;
94 std::string last_loaded_extension_id_;
95 int extension_installs_observed_;
96 int extension_load_errors_observed_;
97 int crx_installers_done_observed_;
100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_NOTIFICATION_OBSERVER_H_