OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "ui/views/controls/image_view.h" | |
13 #include "ui/views/controls/label.h" | |
14 #include "ui/views/controls/link_listener.h" | |
15 #include "ui/views/view.h" | |
16 #include "ui/views/window/dialog_delegate.h" | |
17 | |
18 #if defined(OS_WIN) && !defined(USE_AURA) | |
19 #include "chrome/browser/google/google_update_win.h" | |
20 #endif | |
21 | |
22 namespace views { | |
23 class Textfield; | |
24 class Throbber; | |
25 } | |
26 | |
27 class Browser; | |
28 | |
29 //////////////////////////////////////////////////////////////////////////////// | |
30 // | |
31 // The AboutChromeView class is responsible for drawing the UI controls of the | |
32 // About Chrome dialog that allows the user to see what version is installed | |
33 // and check for updates. | |
34 // | |
35 //////////////////////////////////////////////////////////////////////////////// | |
36 class AboutChromeView : public views::DialogDelegateView, | |
37 public views::LinkListener | |
38 #if defined(OS_WIN) && !defined(USE_AURA) | |
39 , public GoogleUpdateStatusListener | |
40 #endif | |
41 { | |
42 public: | |
43 explicit AboutChromeView(Browser* browser); | |
44 virtual ~AboutChromeView(); | |
45 | |
46 // Initialize the controls on the dialog. | |
47 void Init(); | |
48 | |
49 // Overridden from views::View: | |
50 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
51 virtual void Layout() OVERRIDE; | |
52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
53 virtual void ViewHierarchyChanged(bool is_add, | |
54 views::View* parent, | |
55 views::View* child) OVERRIDE; | |
56 | |
57 // Overridden from views::DialogDelegate: | |
58 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | |
59 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; | |
60 virtual bool IsDialogButtonVisible(ui::DialogButton button) const OVERRIDE; | |
61 virtual int GetDefaultDialogButton() const OVERRIDE; | |
62 virtual bool CanResize() const OVERRIDE; | |
63 virtual bool CanMaximize() const OVERRIDE; | |
64 virtual ui::ModalType GetModalType() const OVERRIDE; | |
65 virtual string16 GetWindowTitle() const OVERRIDE; | |
66 virtual bool Accept() OVERRIDE; | |
67 virtual views::View* GetContentsView() OVERRIDE; | |
68 | |
69 // Overridden from views::LinkListener: | |
70 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | |
71 | |
72 #if defined(OS_WIN) && !defined(USE_AURA) | |
73 // Overridden from GoogleUpdateStatusListener: | |
74 virtual void OnReportResults(GoogleUpdateUpgradeResult result, | |
75 GoogleUpdateErrorCode error_code, | |
76 const string16& error_message, | |
77 const string16& version) OVERRIDE; | |
78 #endif | |
79 | |
80 private: | |
81 #if defined(OS_WIN) && !defined(USE_AURA) | |
82 // Update the UI to show the status of the upgrade. | |
83 void UpdateStatus(GoogleUpdateUpgradeResult result, | |
84 GoogleUpdateErrorCode error_code, | |
85 const string16& error_message); | |
86 | |
87 // Update the size of the window containing this view to account for more | |
88 // text being displayed (error messages, etc). Returns how many pixels the | |
89 // window was increased by (if any). | |
90 int EnlargeWindowSizeIfNeeded(); | |
91 #endif | |
92 | |
93 Browser* browser_; | |
94 | |
95 // UI elements on the dialog. | |
96 views::ImageView* about_dlg_background_logo_; | |
97 views::Label* about_title_label_; | |
98 views::Textfield* version_label_; | |
99 views::Label* copyright_label_; | |
100 views::Label* main_text_label_; | |
101 int main_text_label_height_; | |
102 views::Link* chromium_url_; | |
103 gfx::Rect chromium_url_rect_; | |
104 views::Link* open_source_url_; | |
105 gfx::Rect open_source_url_rect_; | |
106 views::Link* terms_of_service_url_; | |
107 gfx::Rect terms_of_service_url_rect_; | |
108 // NULL in non-official builds. | |
109 views::Label* error_label_; | |
110 // UI elements we add to the parent view. | |
111 scoped_ptr<views::Throbber> throbber_; | |
112 views::ImageView success_indicator_; | |
113 views::ImageView update_available_indicator_; | |
114 views::ImageView timeout_indicator_; | |
115 views::Label update_label_; | |
116 | |
117 // The dialog dimensions. | |
118 gfx::Size dialog_dimensions_; | |
119 | |
120 // Keeps track of the visible state of the Restart Now button. | |
121 bool restart_button_visible_; | |
122 | |
123 // The text to display as the main label of the About box. We draw this text | |
124 // word for word with the help of the WordIterator, and make room for URLs | |
125 // which are drawn using views::Link. See also |url_offsets_|. | |
126 string16 main_label_chunk1_; | |
127 string16 main_label_chunk2_; | |
128 string16 main_label_chunk3_; | |
129 string16 main_label_chunk4_; | |
130 string16 main_label_chunk5_; | |
131 // Determines the order of the two links we draw in the main label. | |
132 bool chromium_url_appears_first_; | |
133 | |
134 #if defined(OS_WIN) && !defined(USE_AURA) | |
135 // The class that communicates with Google Update to find out if an update is | |
136 // available and asks it to start an upgrade. | |
137 scoped_refptr<GoogleUpdate> google_updater_; | |
138 #endif | |
139 | |
140 // The version Google Update reports is available to us. | |
141 string16 new_version_available_; | |
142 | |
143 // Whether text direction is left-to-right or right-to-left. | |
144 bool text_direction_is_rtl_; | |
145 | |
146 DISALLOW_COPY_AND_ASSIGN(AboutChromeView); | |
147 }; | |
148 | |
149 #endif // CHROME_BROWSER_UI_VIEWS_ABOUT_CHROME_VIEW_H_ | |
OLD | NEW |