OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/views/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
12 #include "chrome/browser/background_page_tracker.h" | 13 #include "chrome/browser/background_page_tracker.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/themes/browser_theme_provider.h" | 16 #include "chrome/browser/themes/browser_theme_provider.h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 19 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
19 #include "chrome/browser/ui/view_ids.h" | 20 #include "chrome/browser/ui/view_ids.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 wrench_menu_2_.reset( | 148 wrench_menu_2_.reset( |
148 chromeos::WrenchMenuUI::CreateMenu2(wrench_menu_model_.get())); | 149 chromeos::WrenchMenuUI::CreateMenu2(wrench_menu_model_.get())); |
149 } | 150 } |
150 #endif | 151 #endif |
151 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); | 152 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); |
152 back_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 153 back_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
153 views::Event::EF_MIDDLE_BUTTON_DOWN); | 154 views::Event::EF_MIDDLE_BUTTON_DOWN); |
154 back_->set_tag(IDC_BACK); | 155 back_->set_tag(IDC_BACK); |
155 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, | 156 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, |
156 views::ImageButton::ALIGN_TOP); | 157 views::ImageButton::ALIGN_TOP); |
157 back_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_BACK)); | 158 back_->SetTooltipText( |
158 back_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BACK)); | 159 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK))); |
| 160 back_->SetAccessibleName( |
| 161 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK))); |
159 back_->SetID(VIEW_ID_BACK_BUTTON); | 162 back_->SetID(VIEW_ID_BACK_BUTTON); |
160 | 163 |
161 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); | 164 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); |
162 forward_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 165 forward_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
163 views::Event::EF_MIDDLE_BUTTON_DOWN); | 166 views::Event::EF_MIDDLE_BUTTON_DOWN); |
164 forward_->set_tag(IDC_FORWARD); | 167 forward_->set_tag(IDC_FORWARD); |
165 forward_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_FORWARD)); | 168 forward_->SetTooltipText( |
166 forward_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_FORWARD)); | 169 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD))); |
| 170 forward_->SetAccessibleName( |
| 171 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD))); |
167 forward_->SetID(VIEW_ID_FORWARD_BUTTON); | 172 forward_->SetID(VIEW_ID_FORWARD_BUTTON); |
168 | 173 |
169 // Have to create this before |reload_| as |reload_|'s constructor needs it. | 174 // Have to create this before |reload_| as |reload_|'s constructor needs it. |
170 location_bar_ = new LocationBarView(profile, browser_->command_updater(), | 175 location_bar_ = new LocationBarView(profile, browser_->command_updater(), |
171 model_, this, (display_mode_ == DISPLAYMODE_LOCATION) ? | 176 model_, this, (display_mode_ == DISPLAYMODE_LOCATION) ? |
172 LocationBarView::POPUP : LocationBarView::NORMAL); | 177 LocationBarView::POPUP : LocationBarView::NORMAL); |
173 | 178 |
174 reload_ = new ReloadButton(location_bar_, browser_); | 179 reload_ = new ReloadButton(location_bar_, browser_); |
175 reload_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 180 reload_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
176 views::Event::EF_MIDDLE_BUTTON_DOWN); | 181 views::Event::EF_MIDDLE_BUTTON_DOWN); |
177 reload_->set_tag(IDC_RELOAD); | 182 reload_->set_tag(IDC_RELOAD); |
178 reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD)); | 183 reload_->SetTooltipText( |
179 reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD)); | 184 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD))); |
| 185 reload_->SetAccessibleName( |
| 186 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD))); |
180 reload_->SetID(VIEW_ID_RELOAD_BUTTON); | 187 reload_->SetID(VIEW_ID_RELOAD_BUTTON); |
181 | 188 |
182 #if defined(OS_CHROMEOS) | 189 #if defined(OS_CHROMEOS) |
183 feedback_ = new views::ImageButton(this); | 190 feedback_ = new views::ImageButton(this); |
184 feedback_->set_tag(IDC_FEEDBACK); | 191 feedback_->set_tag(IDC_FEEDBACK); |
185 feedback_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 192 feedback_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
186 views::Event::EF_MIDDLE_BUTTON_DOWN); | 193 views::Event::EF_MIDDLE_BUTTON_DOWN); |
187 feedback_->set_tag(IDC_FEEDBACK); | 194 feedback_->set_tag(IDC_FEEDBACK); |
188 feedback_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_FEEDBACK)); | 195 feedback_->SetTooltipText( |
| 196 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_FEEDBACK))); |
189 feedback_->SetID(VIEW_ID_FEEDBACK_BUTTON); | 197 feedback_->SetID(VIEW_ID_FEEDBACK_BUTTON); |
190 #endif | 198 #endif |
191 | 199 |
192 home_ = new views::ImageButton(this); | 200 home_ = new views::ImageButton(this); |
193 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 201 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
194 views::Event::EF_MIDDLE_BUTTON_DOWN); | 202 views::Event::EF_MIDDLE_BUTTON_DOWN); |
195 home_->set_tag(IDC_HOME); | 203 home_->set_tag(IDC_HOME); |
196 home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME)); | 204 home_->SetTooltipText( |
197 home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME)); | 205 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_HOME))); |
| 206 home_->SetAccessibleName( |
| 207 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_HOME))); |
198 home_->SetID(VIEW_ID_HOME_BUTTON); | 208 home_->SetID(VIEW_ID_HOME_BUTTON); |
199 | 209 |
200 browser_actions_ = new BrowserActionsContainer(browser_, this); | 210 browser_actions_ = new BrowserActionsContainer(browser_, this); |
201 | 211 |
202 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); | 212 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); |
203 app_menu_->set_border(NULL); | 213 app_menu_->set_border(NULL); |
204 app_menu_->EnableCanvasFlippingForRTLUI(true); | 214 app_menu_->EnableCanvasFlippingForRTLUI(true); |
205 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); | 215 app_menu_->SetAccessibleName( |
206 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, | 216 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_APP))); |
207 l10n_util::GetString(IDS_PRODUCT_NAME))); | 217 app_menu_->SetTooltipText(UTF16ToWide(l10n_util::GetStringFUTF16( |
| 218 IDS_APPMENU_TOOLTIP, |
| 219 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)))); |
208 app_menu_->SetID(VIEW_ID_APP_MENU); | 220 app_menu_->SetID(VIEW_ID_APP_MENU); |
209 | 221 |
210 // Add any necessary badges to the menu item based on the system state. | 222 // Add any necessary badges to the menu item based on the system state. |
211 if (IsUpgradeRecommended() || ShouldShowIncompatibilityWarning() || | 223 if (IsUpgradeRecommended() || ShouldShowIncompatibilityWarning() || |
212 ShouldShowBackgroundPageBadge()) { | 224 ShouldShowBackgroundPageBadge()) { |
213 UpdateAppMenuBadge(); | 225 UpdateAppMenuBadge(); |
214 } | 226 } |
215 LoadImages(); | 227 LoadImages(); |
216 | 228 |
217 // Always add children in order from left to right, for accessibility. | 229 // Always add children in order from left to right, for accessibility. |
218 AddChildView(back_); | 230 AddChildView(back_); |
219 AddChildView(forward_); | 231 AddChildView(forward_); |
220 AddChildView(reload_); | 232 AddChildView(reload_); |
221 AddChildView(home_); | 233 AddChildView(home_); |
222 AddChildView(location_bar_); | 234 AddChildView(location_bar_); |
223 AddChildView(browser_actions_); | 235 AddChildView(browser_actions_); |
224 #if defined(OS_CHROMEOS) | 236 #if defined(OS_CHROMEOS) |
225 AddChildView(feedback_); | 237 AddChildView(feedback_); |
226 #endif | 238 #endif |
227 AddChildView(app_menu_); | 239 AddChildView(app_menu_); |
228 | 240 |
229 location_bar_->Init(); | 241 location_bar_->Init(); |
230 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); | 242 show_home_button_.Init(prefs::kShowHomeButton, profile->GetPrefs(), this); |
231 browser_actions_->Init(); | 243 browser_actions_->Init(); |
232 | 244 |
233 SetProfile(profile); | 245 SetProfile(profile); |
234 | 246 |
235 // Accessibility specific tooltip text. | 247 // Accessibility specific tooltip text. |
236 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { | 248 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { |
237 back_->SetTooltipText(l10n_util::GetString(IDS_ACCNAME_TOOLTIP_BACK)); | 249 back_->SetTooltipText( |
238 forward_->SetTooltipText(l10n_util::GetString(IDS_ACCNAME_TOOLTIP_FORWARD)); | 250 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK))); |
| 251 forward_->SetTooltipText( |
| 252 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD))); |
239 } | 253 } |
240 } | 254 } |
241 | 255 |
242 void ToolbarView::SetProfile(Profile* profile) { | 256 void ToolbarView::SetProfile(Profile* profile) { |
243 if (profile != profile_) { | 257 if (profile != profile_) { |
244 profile_ = profile; | 258 profile_ = profile; |
245 location_bar_->SetProfile(profile); | 259 location_bar_->SetProfile(profile); |
246 } | 260 } |
247 } | 261 } |
248 | 262 |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 SkBitmap* badge = tp->GetBitmapNamed(IDR_BACKGROUND_BADGE); | 776 SkBitmap* badge = tp->GetBitmapNamed(IDR_BACKGROUND_BADGE); |
763 string16 badge_text = base::FormatNumber( | 777 string16 badge_text = base::FormatNumber( |
764 BackgroundPageTracker::GetInstance()->GetBackgroundPageCount()); | 778 BackgroundPageTracker::GetInstance()->GetBackgroundPageCount()); |
765 return badge_util::DrawBadgeIconOverlay( | 779 return badge_util::DrawBadgeIconOverlay( |
766 *badge, | 780 *badge, |
767 kBadgeTextFontSize, | 781 kBadgeTextFontSize, |
768 badge_text, | 782 badge_text, |
769 l10n_util::GetStringUTF16(IDS_BACKGROUND_PAGE_BADGE_OVERFLOW)); | 783 l10n_util::GetStringUTF16(IDS_BACKGROUND_PAGE_BADGE_OVERFLOW)); |
770 } | 784 } |
771 | 785 |
OLD | NEW |