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

Side by Side Diff: chrome/browser/ui/profile_menu_model.cc

Issue 7621031: Revert 97049 - Trying to see if it fixes sync_integration_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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/profile_menu_model.h" 5 #include "chrome/browser/ui/profile_menu_model.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_info_cache.h" 9 #include "chrome/browser/profiles/profile_info_cache.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 virtual bool DeleteAfter() OVERRIDE { return true; } 58 virtual bool DeleteAfter() OVERRIDE { return true; }
59 }; 59 };
60 60
61 SwitchProfileMenuModel::SwitchProfileMenuModel( 61 SwitchProfileMenuModel::SwitchProfileMenuModel(
62 ui::SimpleMenuModel::Delegate* delegate, 62 ui::SimpleMenuModel::Delegate* delegate,
63 Browser* browser) 63 Browser* browser)
64 : SimpleMenuModel(this), 64 : SimpleMenuModel(this),
65 browser_(browser), 65 browser_(browser),
66 delegate_(delegate) { 66 delegate_(delegate) {
67 ProfileInfoInterface& cache = 67 ProfileInfoCache& cache =
68 g_browser_process->profile_manager()->GetProfileInfo(); 68 g_browser_process->profile_manager()->GetProfileInfoCache();
69 size_t count = cache.GetNumberOfProfiles(); 69 size_t count = cache.GetNumberOfProfiles();
70 for (size_t i = 0; i < count; ++i) { 70 for (size_t i = 0; i < count; ++i) {
71 AddCheckItem(ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE + i, 71 AddCheckItem(ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE + i,
72 cache.GetNameOfProfileAtIndex(i)); 72 cache.GetNameOfProfileAtIndex(i));
73 } 73 }
74 74
75 AddSeparator(); 75 AddSeparator();
76 76
77 AddItemWithStringId(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE, 77 AddItemWithStringId(ProfileMenuModel::COMMAND_CREATE_NEW_PROFILE,
78 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION); 78 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION);
79 } 79 }
80 80
81 void SwitchProfileMenuModel::ExecuteCommand(int command_id) { 81 void SwitchProfileMenuModel::ExecuteCommand(int command_id) {
82 ProfileInfoInterface& cache = 82 ProfileInfoCache& cache =
83 g_browser_process->profile_manager()->GetProfileInfo(); 83 g_browser_process->profile_manager()->GetProfileInfoCache();
84 if (IsSwitchProfileCommand(command_id)) { 84 if (IsSwitchProfileCommand(command_id)) {
85 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); 85 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id);
86 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); 86 FilePath profile_path = cache.GetPathOfProfileAtIndex(index);
87 ProfileSwitchObserver* observer = new ProfileSwitchObserver; 87 ProfileSwitchObserver* observer = new ProfileSwitchObserver;
88 // The observer is deleted by the manager when profile creation is finished. 88 // The observer is deleted by the manager when profile creation is finished.
89 g_browser_process->profile_manager()->CreateProfileAsync( 89 g_browser_process->profile_manager()->CreateProfileAsync(
90 profile_path, observer); 90 profile_path, observer);
91 } else { 91 } else {
92 delegate_->ExecuteCommand(command_id); 92 delegate_->ExecuteCommand(command_id);
93 } 93 }
94 } 94 }
95 95
96 bool SwitchProfileMenuModel::IsCommandIdChecked(int command_id) const { 96 bool SwitchProfileMenuModel::IsCommandIdChecked(int command_id) const {
97 ProfileInfoInterface& cache = 97 ProfileInfoCache& cache =
98 g_browser_process->profile_manager()->GetProfileInfo(); 98 g_browser_process->profile_manager()->GetProfileInfoCache();
99 if (IsSwitchProfileCommand(command_id)) { 99 if (IsSwitchProfileCommand(command_id)) {
100 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id); 100 size_t index = GetProfileIndexFromSwitchProfileCommand(command_id);
101 FilePath userDataFolder; 101 FilePath userDataFolder;
102 PathService::Get(chrome::DIR_USER_DATA, &userDataFolder); 102 PathService::Get(chrome::DIR_USER_DATA, &userDataFolder);
103 FilePath profile_path = cache.GetPathOfProfileAtIndex(index); 103 FilePath profile_path = cache.GetPathOfProfileAtIndex(index);
104 return browser_->GetProfile()->GetPath() == profile_path; 104 return browser_->GetProfile()->GetPath() == profile_path;
105 } 105 }
106 return delegate_->IsCommandIdChecked(command_id); 106 return delegate_->IsCommandIdChecked(command_id);
107 } 107 }
108 108
(...skipping 19 matching lines...) Expand all
128 int command_id) const { 128 int command_id) const {
129 DCHECK(IsSwitchProfileCommand(command_id)); 129 DCHECK(IsSwitchProfileCommand(command_id));
130 return command_id - ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE; 130 return command_id - ProfileMenuModel::COMMAND_SWITCH_TO_PROFILE;
131 } 131 }
132 132
133 } // namespace 133 } // namespace
134 134
135 ProfileMenuModel::ProfileMenuModel(Browser* browser) 135 ProfileMenuModel::ProfileMenuModel(Browser* browser)
136 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 136 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
137 browser_(browser) { 137 browser_(browser) {
138 ProfileInfoInterface& cache = 138 ProfileInfoCache& cache =
139 g_browser_process->profile_manager()->GetProfileInfo(); 139 g_browser_process->profile_manager()->GetProfileInfoCache();
140 size_t profile_index = cache.GetIndexOfProfileWithPath( 140 size_t profile_index = cache.GetIndexOfProfileWithPath(
141 browser_->profile()->GetPath()); 141 browser_->profile()->GetPath());
142 AddItem(COMMAND_PROFILE_NAME, cache.GetNameOfProfileAtIndex(profile_index)); 142 AddItem(COMMAND_PROFILE_NAME, cache.GetNameOfProfileAtIndex(profile_index));
143 143
144 // TODO(sail): Need to implement an icon chooser on other platforms too. 144 // TODO(sail): Need to implement an icon chooser on other platforms too.
145 #if defined(TOOLKIT_VIEWS) 145 #if defined(TOOLKIT_VIEWS)
146 AddItem(COMMAND_CHOOSE_AVATAR_ICON, string16()); 146 AddItem(COMMAND_CHOOSE_AVATAR_ICON, string16());
147 #endif 147 #endif
148 148
149 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE, 149 AddItemWithStringId(COMMAND_CUSTOMIZE_PROFILE,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 case COMMAND_CHOOSE_AVATAR_ICON: 192 case COMMAND_CHOOSE_AVATAR_ICON:
193 break; 193 break;
194 case COMMAND_CREATE_NEW_PROFILE: 194 case COMMAND_CREATE_NEW_PROFILE:
195 ProfileManager::CreateMultiProfileAsync(); 195 ProfileManager::CreateMultiProfileAsync();
196 break; 196 break;
197 default: 197 default:
198 NOTREACHED(); 198 NOTREACHED();
199 break; 199 break;
200 } 200 }
201 } 201 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_titlebar.cc ('k') | chrome/browser/ui/views/avatar_menu_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698