OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/compiler_specific.h" | |
10 #include "content/public/browser/notification_observer.h" | |
11 #include "content/public/browser/notification_registrar.h" | |
12 | |
13 class RenderViewHost; | |
14 class TabContents; | |
15 | |
16 namespace chromeos { | |
17 | |
18 // This class watches given TabContent's loading and rendering state change. | |
19 // TODO(xiyuan): Move this to a proper place and share with HTMLDialogView. | |
20 class TabFirstRenderWatcher : public content::NotificationObserver { | |
21 public: | |
22 class Delegate { | |
23 public: | |
24 virtual void OnRenderHostCreated(RenderViewHost* host) = 0; | |
25 virtual void OnTabMainFrameLoaded() = 0; | |
26 virtual void OnTabMainFrameFirstRender() = 0; | |
27 }; | |
28 | |
29 TabFirstRenderWatcher(TabContents* tab, Delegate* delegate); | |
30 | |
31 private: | |
32 // Overridden from content::NotificationObserver | |
33 virtual void Observe(int type, | |
34 const content::NotificationSource& source, | |
35 const content::NotificationDetails& details) OVERRIDE; | |
36 | |
37 enum State { | |
38 NONE, | |
39 LOADED, // Renderer loaded the page. | |
40 FIRST_PAINT, // 1st paint event after the page is loaded. | |
41 }; | |
42 State state_; | |
43 | |
44 // TabContents that this class watches. | |
45 TabContents* tab_contents_; | |
46 | |
47 // Delegate to notify. | |
48 Delegate* delegate_; | |
49 | |
50 content::NotificationRegistrar registrar_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(TabFirstRenderWatcher); | |
53 }; | |
54 | |
55 } // namespace chromeos | |
56 | |
57 #endif // CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_ | |
OLD | NEW |