OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 | 12 |
13 // Wraps the state needed by the renderers. | 13 // Wraps the state needed by the renderers. |
14 struct TabRendererData { | 14 struct TabRendererData { |
15 // Different types of network activity for a tab. The NetworkState of a tab | 15 // Different types of network activity for a tab. The NetworkState of a tab |
16 // may be used to alter the UI (e.g. show different kinds of loading | 16 // may be used to alter the UI (e.g. show different kinds of loading |
17 // animations). | 17 // animations). |
18 enum NetworkState { | 18 enum NetworkState { |
19 NETWORK_STATE_NONE, // no network activity. | 19 NETWORK_STATE_NONE, // no network activity. |
20 NETWORK_STATE_WAITING, // waiting for a connection. | 20 NETWORK_STATE_WAITING, // waiting for a connection. |
21 NETWORK_STATE_LOADING, // connected, transferring data. | 21 NETWORK_STATE_LOADING, // connected, transferring data. |
22 }; | 22 }; |
23 | 23 |
24 TabRendererData() | 24 TabRendererData(); |
25 : network_state(NETWORK_STATE_NONE), | 25 ~TabRendererData(); |
26 loading(false), | |
27 crashed_status(base::TERMINATION_STATUS_STILL_RUNNING), | |
28 off_the_record(false), | |
29 show_icon(true), | |
30 mini(false), | |
31 blocked(false), | |
32 app(false) { | |
33 } | |
34 | 26 |
35 // This interprets the crashed status to decide whether or not this | 27 // This interprets the crashed status to decide whether or not this |
36 // render data represents a tab that is "crashed" (i.e. the render | 28 // render data represents a tab that is "crashed" (i.e. the render |
37 // process died unexpectedly). | 29 // process died unexpectedly). |
38 bool IsCrashed() const { | 30 bool IsCrashed() const { |
39 return (crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || | 31 return (crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || |
40 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED || | 32 crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
41 crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION); | 33 crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION); |
42 } | 34 } |
43 | 35 |
44 // Returns true if the TabRendererData is same as given |data|. Two favicons | 36 // Returns true if the TabRendererData is same as given |data|. Two favicons |
45 // are considered equals if two SkBitmaps point to the same SkPixelRef object. | 37 // are considered equals if two SkBitmaps point to the same SkPixelRef object. |
46 bool Equals(const TabRendererData& data) { | 38 bool Equals(const TabRendererData& data); |
47 return | |
48 favicon.pixelRef() && | |
49 favicon.pixelRef() == data.favicon.pixelRef() && | |
50 favicon.pixelRefOffset() == data.favicon.pixelRefOffset() && | |
51 network_state == data.network_state && | |
52 title == data.title && | |
53 loading == data.loading && | |
54 crashed_status == data.crashed_status && | |
55 off_the_record == data.off_the_record && | |
56 show_icon == data.show_icon && | |
57 mini == data.mini && | |
58 blocked == data.blocked && | |
59 app == data.app; | |
60 } | |
61 | 39 |
62 SkBitmap favicon; | 40 SkBitmap favicon; |
63 NetworkState network_state; | 41 NetworkState network_state; |
64 string16 title; | 42 string16 title; |
65 bool loading; | 43 bool loading; |
66 base::TerminationStatus crashed_status; | 44 base::TerminationStatus crashed_status; |
67 bool off_the_record; | 45 bool off_the_record; |
68 bool show_icon; | 46 bool show_icon; |
69 bool mini; | 47 bool mini; |
70 bool blocked; | 48 bool blocked; |
71 bool app; | 49 bool app; |
72 }; | 50 }; |
73 | 51 |
74 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ | 52 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_ |
OLD | NEW |