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/profiles/avatar_menu_model.h" | 5 #include "chrome/browser/profiles/avatar_menu_model.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/avatar_menu_model_observer.h" | 9 #include "chrome/browser/profiles/avatar_menu_model_observer.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 AvatarMenuModel::Item::Item(size_t model_index, const gfx::Image& icon) | 65 AvatarMenuModel::Item::Item(size_t model_index, const gfx::Image& icon) |
66 : icon(icon), | 66 : icon(icon), |
67 model_index(model_index) { | 67 model_index(model_index) { |
68 } | 68 } |
69 | 69 |
70 AvatarMenuModel::Item::~Item() { | 70 AvatarMenuModel::Item::~Item() { |
71 } | 71 } |
72 | 72 |
73 void AvatarMenuModel::SwichToProfile(size_t index) { | 73 void AvatarMenuModel::SwitchToProfile(size_t index) { |
74 const Item& item = GetItemAt(index); | 74 const Item& item = GetItemAt(index); |
75 FilePath path = profile_info_->GetPathOfProfileAtIndex(item.model_index); | 75 FilePath path = profile_info_->GetPathOfProfileAtIndex(item.model_index); |
76 | 76 |
77 // This will be deleted by the manager after the profile is ready. | 77 // This will be deleted by the manager after the profile is ready. |
78 ProfileSwitchObserver* observer = new ProfileSwitchObserver(); | 78 ProfileSwitchObserver* observer = new ProfileSwitchObserver(); |
79 g_browser_process->profile_manager()->CreateProfileAsync( | 79 g_browser_process->profile_manager()->CreateProfileAsync( |
80 path, observer); | 80 path, observer); |
81 } | 81 } |
82 | 82 |
83 void AvatarMenuModel::EditProfile(size_t index) { | 83 void AvatarMenuModel::EditProfile(size_t index) { |
(...skipping 28 matching lines...) Expand all Loading... |
112 for (size_t i = 0; i < count; ++i) { | 112 for (size_t i = 0; i < count; ++i) { |
113 Item* item = new Item(i, profile_info_->GetAvatarIconOfProfileAtIndex(i)); | 113 Item* item = new Item(i, profile_info_->GetAvatarIconOfProfileAtIndex(i)); |
114 item->name = profile_info_->GetNameOfProfileAtIndex(i); | 114 item->name = profile_info_->GetNameOfProfileAtIndex(i); |
115 if (browser_) { | 115 if (browser_) { |
116 FilePath path = profile_info_->GetPathOfProfileAtIndex(i); | 116 FilePath path = profile_info_->GetPathOfProfileAtIndex(i); |
117 item->active = browser_->profile()->GetPath() == path; | 117 item->active = browser_->profile()->GetPath() == path; |
118 } | 118 } |
119 items_.push_back(item); | 119 items_.push_back(item); |
120 } | 120 } |
121 | 121 |
122 observer_->OnAvatarMenuModelChanged(); | 122 observer_->OnAvatarMenuModelChanged(this); |
123 } | 123 } |
124 | 124 |
125 void AvatarMenuModel::ClearMenu() { | 125 void AvatarMenuModel::ClearMenu() { |
126 STLDeleteContainerPointers(items_.begin(), items_.end()); | 126 STLDeleteContainerPointers(items_.begin(), items_.end()); |
127 items_.clear(); | 127 items_.clear(); |
128 } | 128 } |
OLD | NEW |