OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_toolbar_model.h" | 5 #include "chrome/browser/extensions/extension_toolbar_model.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_prefs.h" | 7 #include "chrome/browser/extensions/extension_prefs.h" |
8 #include "chrome/browser/extensions/extensions_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 | 14 |
15 ExtensionToolbarModel::ExtensionToolbarModel(ExtensionsService* service) | 15 ExtensionToolbarModel::ExtensionToolbarModel(ExtensionService* service) |
16 : service_(service), | 16 : service_(service), |
17 prefs_(service->profile()->GetPrefs()), | 17 prefs_(service->profile()->GetPrefs()), |
18 extensions_initialized_(false) { | 18 extensions_initialized_(false) { |
19 DCHECK(service_); | 19 DCHECK(service_); |
20 | 20 |
21 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 21 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
22 Source<Profile>(service_->profile())); | 22 Source<Profile>(service_->profile())); |
23 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 23 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
24 Source<Profile>(service_->profile())); | 24 Source<Profile>(service_->profile())); |
25 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, | 25 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 last_extension_removed_index_ = pos - begin(); | 153 last_extension_removed_index_ = pos - begin(); |
154 | 154 |
155 toolitems_.erase(pos); | 155 toolitems_.erase(pos); |
156 FOR_EACH_OBSERVER(Observer, observers_, | 156 FOR_EACH_OBSERVER(Observer, observers_, |
157 BrowserActionRemoved(extension)); | 157 BrowserActionRemoved(extension)); |
158 | 158 |
159 UpdatePrefs(); | 159 UpdatePrefs(); |
160 } | 160 } |
161 | 161 |
162 // Combine the currently enabled extensions that have browser actions (which | 162 // Combine the currently enabled extensions that have browser actions (which |
163 // we get from the ExtensionsService) with the ordering we get from the | 163 // we get from the ExtensionService) with the ordering we get from the |
164 // pref service. For robustness we use a somewhat inefficient process: | 164 // pref service. For robustness we use a somewhat inefficient process: |
165 // 1. Create a vector of extensions sorted by their pref values. This vector may | 165 // 1. Create a vector of extensions sorted by their pref values. This vector may |
166 // have holes. | 166 // have holes. |
167 // 2. Create a vector of extensions that did not have a pref value. | 167 // 2. Create a vector of extensions that did not have a pref value. |
168 // 3. Remove holes from the sorted vector and append the unsorted vector. | 168 // 3. Remove holes from the sorted vector and append the unsorted vector. |
169 void ExtensionToolbarModel::InitializeExtensionList() { | 169 void ExtensionToolbarModel::InitializeExtensionList() { |
170 DCHECK(service_->is_ready()); | 170 DCHECK(service_->is_ready()); |
171 | 171 |
172 std::vector<std::string> pref_order = service_->extension_prefs()-> | 172 std::vector<std::string> pref_order = service_->extension_prefs()-> |
173 GetToolbarOrder(); | 173 GetToolbarOrder(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 int incognito_index = 0, i = 0; | 248 int incognito_index = 0, i = 0; |
249 for (ExtensionList::iterator iter = begin(); iter != end(); | 249 for (ExtensionList::iterator iter = begin(); iter != end(); |
250 ++iter, ++i) { | 250 ++iter, ++i) { |
251 if (original_index == i) | 251 if (original_index == i) |
252 break; | 252 break; |
253 if (service_->IsIncognitoEnabled(*iter)) | 253 if (service_->IsIncognitoEnabled(*iter)) |
254 ++incognito_index; | 254 ++incognito_index; |
255 } | 255 } |
256 return incognito_index; | 256 return incognito_index; |
257 } | 257 } |
OLD | NEW |