OLD | NEW |
1 // Copyright (c) 2011 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 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS; | 238 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS; |
239 } | 239 } |
240 | 240 |
241 bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const { | 241 bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const { |
242 return command_id == IDC_ZOOM_PERCENT_DISPLAY || | 242 return command_id == IDC_ZOOM_PERCENT_DISPLAY || |
243 #if defined(OS_MACOSX) | 243 #if defined(OS_MACOSX) |
244 command_id == IDC_FULLSCREEN || | 244 command_id == IDC_FULLSCREEN || |
245 #endif | 245 #endif |
246 command_id == IDC_SYNC_BOOKMARKS || | 246 command_id == IDC_SYNC_BOOKMARKS || |
247 command_id == IDC_VIEW_BACKGROUND_PAGES || | 247 command_id == IDC_VIEW_BACKGROUND_PAGES || |
248 command_id == IDC_UPGRADE_DIALOG; | 248 command_id == IDC_UPGRADE_DIALOG || |
| 249 command_id == IDC_SHOW_SYNC_SETUP; |
249 } | 250 } |
250 | 251 |
251 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { | 252 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { |
252 switch (command_id) { | 253 switch (command_id) { |
253 case IDC_SYNC_BOOKMARKS: | 254 case IDC_SYNC_BOOKMARKS: |
254 return GetSyncMenuLabel(); | 255 return GetSyncMenuLabel(); |
255 case IDC_ZOOM_PERCENT_DISPLAY: | 256 case IDC_ZOOM_PERCENT_DISPLAY: |
256 return zoom_label_; | 257 return zoom_label_; |
257 #if defined(OS_MACOSX) | 258 #if defined(OS_MACOSX) |
258 case IDC_FULLSCREEN: { | 259 case IDC_FULLSCREEN: { |
(...skipping 13 matching lines...) Expand all Loading... |
272 case IDC_UPGRADE_DIALOG: { | 273 case IDC_UPGRADE_DIALOG: { |
273 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
274 const string16 product_name = | 275 const string16 product_name = |
275 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); | 276 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); |
276 #else | 277 #else |
277 const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 278 const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
278 #endif | 279 #endif |
279 | 280 |
280 return l10n_util::GetStringFUTF16(IDS_UPDATE_NOW, product_name); | 281 return l10n_util::GetStringFUTF16(IDS_UPDATE_NOW, product_name); |
281 } | 282 } |
| 283 case IDC_SHOW_SYNC_SETUP: { |
| 284 std::string username = browser_->GetProfile()->GetPrefs()->GetString( |
| 285 prefs::kGoogleServicesUsername); |
| 286 string16 short_product_name = |
| 287 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 288 if (username.empty()) { |
| 289 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP, |
| 290 short_product_name); |
| 291 } |
| 292 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP_USERNAME, |
| 293 short_product_name, |
| 294 UTF8ToUTF16(username)); |
| 295 } |
282 default: | 296 default: |
283 NOTREACHED(); | 297 NOTREACHED(); |
284 return string16(); | 298 return string16(); |
285 } | 299 } |
286 } | 300 } |
287 | 301 |
288 bool WrenchMenuModel::GetIconForCommandId(int command_id, | 302 bool WrenchMenuModel::GetIconForCommandId(int command_id, |
289 SkBitmap* icon) const { | 303 SkBitmap* icon) const { |
290 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 304 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
291 switch (command_id) { | 305 switch (command_id) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 &enable_increment, &enable_decrement); | 569 &enable_increment, &enable_decrement); |
556 } | 570 } |
557 zoom_label_ = l10n_util::GetStringFUTF16( | 571 zoom_label_ = l10n_util::GetStringFUTF16( |
558 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 572 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
559 } | 573 } |
560 | 574 |
561 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 575 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
562 return sync_ui_util::GetSyncMenuLabel( | 576 return sync_ui_util::GetSyncMenuLabel( |
563 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 577 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
564 } | 578 } |
OLD | NEW |