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

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

Issue 9169096: Remove a bunch of GetProfileSyncService callers to use the new factory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm todos Created 8 years, 11 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/profile_sync_service.h"
22 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/sync/sync_global_error.h" 23 #include "chrome/browser/sync/sync_global_error.h"
22 #include "chrome/browser/sync/sync_ui_util.h" 24 #include "chrome/browser/sync/sync_ui_util.h"
23 #include "chrome/browser/tabs/tab_strip_model.h" 25 #include "chrome/browser/tabs/tab_strip_model.h"
24 #include "chrome/browser/task_manager/task_manager.h" 26 #include "chrome/browser/task_manager/task_manager.h"
25 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/global_error.h" 29 #include "chrome/browser/ui/global_error.h"
28 #include "chrome/browser/ui/global_error_service.h" 30 #include "chrome/browser/ui/global_error_service.h"
29 #include "chrome/browser/ui/global_error_service_factory.h" 31 #include "chrome/browser/ui/global_error_service_factory.h"
30 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 32 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 case IDC_VIEW_BACKGROUND_PAGES: { 255 case IDC_VIEW_BACKGROUND_PAGES: {
254 string16 num_background_pages = base::FormatNumber( 256 string16 num_background_pages = base::FormatNumber(
255 TaskManager::GetBackgroundPageCount()); 257 TaskManager::GetBackgroundPageCount());
256 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES, 258 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES,
257 num_background_pages); 259 num_background_pages);
258 } 260 }
259 case IDC_UPGRADE_DIALOG: 261 case IDC_UPGRADE_DIALOG:
260 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); 262 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW);
261 case IDC_SHOW_SYNC_SETUP: { 263 case IDC_SHOW_SYNC_SETUP: {
262 ProfileSyncService* service = 264 ProfileSyncService* service =
263 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); 265 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
266 browser_->GetProfile()->GetOriginalProfile());
264 SyncGlobalError* error = service->sync_global_error(); 267 SyncGlobalError* error = service->sync_global_error();
265 if (error && error->HasCustomizedSyncMenuItem()) 268 if (error && error->HasCustomizedSyncMenuItem())
266 return error->MenuItemLabel(); 269 return error->MenuItemLabel();
267 if (service->HasSyncSetupCompleted()) { 270 if (service->HasSyncSetupCompleted()) {
268 std::string username = browser_->GetProfile()->GetPrefs()->GetString( 271 std::string username = browser_->GetProfile()->GetPrefs()->GetString(
269 prefs::kGoogleServicesUsername); 272 prefs::kGoogleServicesUsername);
270 if (!username.empty()) { 273 if (!username.empty()) {
271 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, 274 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL,
272 UTF8ToUTF16(username)); 275 UTF8ToUTF16(username));
273 } 276 }
(...skipping 15 matching lines...) Expand all
289 if (UpgradeDetector::GetInstance()->notify_upgrade()) { 292 if (UpgradeDetector::GetInstance()->notify_upgrade()) {
290 *icon = rb.GetNativeImageNamed( 293 *icon = rb.GetNativeImageNamed(
291 UpgradeDetector::GetInstance()->GetIconResourceID( 294 UpgradeDetector::GetInstance()->GetIconResourceID(
292 UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON)); 295 UpgradeDetector::UPGRADE_ICON_TYPE_MENU_ICON));
293 return true; 296 return true;
294 } 297 }
295 return false; 298 return false;
296 } 299 }
297 case IDC_SHOW_SYNC_SETUP: { 300 case IDC_SHOW_SYNC_SETUP: {
298 ProfileSyncService* service = 301 ProfileSyncService* service =
299 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); 302 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
303 browser_->GetProfile()->GetOriginalProfile());
300 SyncGlobalError* error = service->sync_global_error(); 304 SyncGlobalError* error = service->sync_global_error();
301 if (error && error->HasCustomizedSyncMenuItem()) { 305 if (error && error->HasCustomizedSyncMenuItem()) {
302 int icon_id = error->MenuItemIconResourceID(); 306 int icon_id = error->MenuItemIconResourceID();
303 if (icon_id) { 307 if (icon_id) {
304 *icon = rb.GetNativeImageNamed(icon_id); 308 *icon = rb.GetNativeImageNamed(icon_id);
305 return true; 309 return true;
306 } 310 }
307 } 311 }
308 return false; 312 return false;
309 } 313 }
310 default: 314 default:
311 break; 315 break;
312 } 316 }
313 return false; 317 return false;
314 } 318 }
315 319
316 void WrenchMenuModel::ExecuteCommand(int command_id) { 320 void WrenchMenuModel::ExecuteCommand(int command_id) {
317 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( 321 GlobalError* error = GlobalErrorServiceFactory::GetForProfile(
318 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); 322 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id);
319 if (error) { 323 if (error) {
320 error->ExecuteMenuItem(browser_); 324 error->ExecuteMenuItem(browser_);
321 return; 325 return;
322 } 326 }
323 327
324 if (command_id == IDC_SHOW_SYNC_SETUP) { 328 if (command_id == IDC_SHOW_SYNC_SETUP) {
325 ProfileSyncService* service = 329 ProfileSyncService* service =
326 browser_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); 330 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
331 browser_->GetProfile()->GetOriginalProfile());
327 SyncGlobalError* error = service->sync_global_error(); 332 SyncGlobalError* error = service->sync_global_error();
328 if (error && error->HasCustomizedSyncMenuItem()) { 333 if (error && error->HasCustomizedSyncMenuItem()) {
329 error->ExecuteMenuItem(browser_); 334 error->ExecuteMenuItem(browser_);
330 return; 335 return;
331 } 336 }
332 } 337 }
333 338
334 if (command_id == IDC_HELP_PAGE) 339 if (command_id == IDC_HELP_PAGE)
335 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); 340 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu"));
336 341
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 int zoom_percent = 100; 588 int zoom_percent = 100;
584 if (browser_->GetSelectedWebContents()) { 589 if (browser_->GetSelectedWebContents()) {
585 zoom_percent = browser_->GetSelectedWebContents()->GetZoomPercent( 590 zoom_percent = browser_->GetSelectedWebContents()->GetZoomPercent(
586 &enable_increment, &enable_decrement); 591 &enable_increment, &enable_decrement);
587 } 592 }
588 zoom_label_ = l10n_util::GetStringFUTF16( 593 zoom_label_ = l10n_util::GetStringFUTF16(
589 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 594 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
590 } 595 }
591 596
592 string16 WrenchMenuModel::GetSyncMenuLabel() const { 597 string16 WrenchMenuModel::GetSyncMenuLabel() const {
593 return sync_ui_util::GetSyncMenuLabel( 598 return sync_ui_util::GetSyncMenuLabel(ProfileSyncServiceFactory::
594 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); 599 GetInstance()->GetForProfile(browser_->profile()->GetOriginalProfile()));
595 } 600 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698