Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 7906013: Show bubble and wrench menu item for sync error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/i18n/number_formatting.h" 11 #include "base/i18n/number_formatting.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/sync/sync_ui_util.h" 21 #include "chrome/browser/sync/sync_ui_util.h"
22 #include "chrome/browser/sync/sync_global_error.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 23 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "chrome/browser/task_manager/task_manager.h" 24 #include "chrome/browser/task_manager/task_manager.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/global_error.h" 27 #include "chrome/browser/ui/global_error.h"
27 #include "chrome/browser/ui/global_error_service.h" 28 #include "chrome/browser/ui/global_error_service.h"
28 #include "chrome/browser/ui/global_error_service_factory.h" 29 #include "chrome/browser/ui/global_error_service_factory.h"
29 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 30 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
30 #include "chrome/browser/upgrade_detector.h" 31 #include "chrome/browser/upgrade_detector.h"
31 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); 285 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME);
285 #else 286 #else
286 const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 287 const string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
287 #endif 288 #endif
288 289
289 return l10n_util::GetStringFUTF16(IDS_UPDATE_NOW, product_name); 290 return l10n_util::GetStringFUTF16(IDS_UPDATE_NOW, product_name);
290 } 291 }
291 case IDC_SHOW_SYNC_SETUP: { 292 case IDC_SHOW_SYNC_SETUP: {
292 ProfileSyncService* service = 293 ProfileSyncService* service =
293 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); 294 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService();
295 SyncGlobalError* error = service->sync_global_error();
296 if (error && error->HasCustomizedSyncMenuItem())
297 return error->MenuItemLabel();
294 if (service->HasSyncSetupCompleted()) { 298 if (service->HasSyncSetupCompleted()) {
295 std::string username = browser_->GetProfile()->GetPrefs()->GetString( 299 std::string username = browser_->GetProfile()->GetPrefs()->GetString(
296 prefs::kGoogleServicesUsername); 300 prefs::kGoogleServicesUsername);
297 if (!username.empty()) { 301 if (!username.empty()) {
298 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP_USERNAME, 302 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP_USERNAME,
299 UTF8ToUTF16(username)); 303 UTF8ToUTF16(username));
300 } 304 }
301 } 305 }
302 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP, 306 return l10n_util::GetStringFUTF16(IDS_SHOW_SYNC_SETUP,
303 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); 307 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
304 } 308 }
305 default: 309 default:
306 NOTREACHED(); 310 NOTREACHED();
307 return string16(); 311 return string16();
308 } 312 }
309 } 313 }
310 314
311 bool WrenchMenuModel::GetIconForCommandId(int command_id, 315 bool WrenchMenuModel::GetIconForCommandId(int command_id,
312 SkBitmap* icon) const { 316 SkBitmap* icon) const {
313 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 317 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
314 switch (command_id) { 318 switch (command_id) {
315 case IDC_UPGRADE_DIALOG: { 319 case IDC_UPGRADE_DIALOG: {
316 if (UpgradeDetector::GetInstance()->notify_upgrade()) { 320 if (UpgradeDetector::GetInstance()->notify_upgrade()) {
317 *icon = rb.GetNativeImageNamed( 321 *icon = rb.GetNativeImageNamed(
318 UpgradeDetector::GetInstance()->GetIconResourceID( 322 UpgradeDetector::GetInstance()->GetIconResourceID(
319 UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON)); 323 UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON));
320 return true; 324 return true;
321 } 325 }
326 return false;
327 }
328 case IDC_SHOW_SYNC_SETUP: {
329 ProfileSyncService* service =
330 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService();
331 SyncGlobalError* error = service->sync_global_error();
332 if (error && error->HasCustomizedSyncMenuItem()) {
333 int icon_id = error->MenuItemIconResourceID();
334 if (icon_id) {
335 *icon = rb.GetNativeImageNamed(icon_id);
336 return true;
337 }
338 }
339 return false;
322 } 340 }
323 default: 341 default:
324 break; 342 break;
325 } 343 }
326 return false; 344 return false;
327 } 345 }
328 346
329 void WrenchMenuModel::ExecuteCommand(int command_id) { 347 void WrenchMenuModel::ExecuteCommand(int command_id) {
330 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( 348 GlobalError* error = GlobalErrorServiceFactory::GetForProfile(
331 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); 349 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id);
332 if (error) { 350 if (error) {
333 error->ExecuteMenuItem(browser_); 351 error->ExecuteMenuItem(browser_);
334 return; 352 return;
335 } 353 }
336 354
355 if (command_id == IDC_SHOW_SYNC_SETUP) {
356 ProfileSyncService* service =
357 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService();
358 SyncGlobalError* error = service->sync_global_error();
359 if (error && error->HasCustomizedSyncMenuItem()) {
360 error->ExecuteMenuItem(browser_);
361 return;
362 }
363 }
364
337 if (command_id == IDC_HELP_PAGE) 365 if (command_id == IDC_HELP_PAGE)
338 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); 366 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu"));
339 367
340 browser_->ExecuteCommand(command_id); 368 browser_->ExecuteCommand(command_id);
341 } 369 }
342 370
343 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { 371 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const {
344 if (command_id == IDC_SHOW_BOOKMARK_BAR) { 372 if (command_id == IDC_SHOW_BOOKMARK_BAR) {
345 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); 373 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
346 } else if (command_id == IDC_PROFILING_ENABLED) { 374 } else if (command_id == IDC_PROFILING_ENABLED) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 &enable_increment, &enable_decrement); 613 &enable_increment, &enable_decrement);
586 } 614 }
587 zoom_label_ = l10n_util::GetStringFUTF16( 615 zoom_label_ = l10n_util::GetStringFUTF16(
588 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 616 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
589 } 617 }
590 618
591 string16 WrenchMenuModel::GetSyncMenuLabel() const { 619 string16 WrenchMenuModel::GetSyncMenuLabel() const {
592 return sync_ui_util::GetSyncMenuLabel( 620 return sync_ui_util::GetSyncMenuLabel(
593 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); 621 browser_->profile()->GetOriginalProfile()->GetProfileSyncService());
594 } 622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698