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/extensions_service.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void ExtensionToolbarModel::UpdatePrefs() { | 180 void ExtensionToolbarModel::UpdatePrefs() { |
181 if (!service_->extension_prefs()) | 181 if (!service_->extension_prefs()) |
182 return; | 182 return; |
183 | 183 |
184 std::vector<std::string> ids; | 184 std::vector<std::string> ids; |
185 ids.reserve(toolitems_.size()); | 185 ids.reserve(toolitems_.size()); |
186 for (ExtensionList::iterator iter = begin(); iter != end(); ++iter) | 186 for (ExtensionList::iterator iter = begin(); iter != end(); ++iter) |
187 ids.push_back((*iter)->id()); | 187 ids.push_back((*iter)->id()); |
188 service_->extension_prefs()->SetToolbarOrder(ids); | 188 service_->extension_prefs()->SetToolbarOrder(ids); |
189 } | 189 } |
| 190 |
| 191 int ExtensionToolbarModel::IncognitoIndexToOriginal(int incognito_index) { |
| 192 int original_index = 0, i = 0; |
| 193 for (ExtensionList::iterator iter = begin(); iter != end(); |
| 194 ++iter, ++original_index) { |
| 195 if (service_->IsIncognitoEnabled((*iter)->id())) { |
| 196 if (incognito_index == i) |
| 197 break; |
| 198 ++i; |
| 199 } |
| 200 } |
| 201 return original_index; |
| 202 } |
| 203 |
| 204 int ExtensionToolbarModel::OriginalIndexToIncognito(int original_index) { |
| 205 int incognito_index = 0, i = 0; |
| 206 for (ExtensionList::iterator iter = begin(); iter != end(); |
| 207 ++iter, ++i) { |
| 208 if (original_index == i) |
| 209 break; |
| 210 if (service_->IsIncognitoEnabled((*iter)->id())) |
| 211 ++incognito_index; |
| 212 } |
| 213 return incognito_index; |
| 214 } |
OLD | NEW |