| OLD | NEW |
| 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/extensions/extension_toolbar_model.h" | 5 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/browser_event_router.h" | 7 #include "chrome/browser/extensions/browser_event_router.h" |
| 8 #include "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } else { | 160 } else { |
| 161 extension = content::Details<const Extension>(details).ptr(); | 161 extension = content::Details<const Extension>(details).ptr(); |
| 162 } | 162 } |
| 163 ExtensionList* list_with_extension = FindListWithExtension(extension); | 163 ExtensionList* list_with_extension = FindListWithExtension(extension); |
| 164 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | 164 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { |
| 165 // We don't want to add the same extension twice. It may have already been | 165 // We don't want to add the same extension twice. It may have already been |
| 166 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user | 166 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user |
| 167 // hides the browser action and then disables and enables the extension. | 167 // hides the browser action and then disables and enables the extension. |
| 168 if (list_with_extension) | 168 if (list_with_extension) |
| 169 return; | 169 return; |
| 170 if (extensions::switch_utils::IsActionBoxEnabled()) | 170 if (extensions::switch_utils::IsExtensionsInActionBoxEnabled()) |
| 171 AddExtension(extension, &action_box_menu_items_); | 171 AddExtension(extension, &action_box_menu_items_); |
| 172 else if (service_->extension_prefs()->GetBrowserActionVisibility(extension)) | 172 else if (service_->extension_prefs()->GetBrowserActionVisibility(extension)) |
| 173 AddExtension(extension, &toolbar_items_); | 173 AddExtension(extension, &toolbar_items_); |
| 174 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 174 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 175 if (list_with_extension) | 175 if (list_with_extension) |
| 176 RemoveExtension(extension, list_with_extension); | 176 RemoveExtension(extension, list_with_extension); |
| 177 } else if (type == | 177 } else if (type == |
| 178 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) { | 178 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) { |
| 179 if (extensions::switch_utils::IsActionBoxEnabled()) { | 179 if (extensions::switch_utils::IsExtensionsInActionBoxEnabled()) { |
| 180 // TODO(yefim): Implement this when implementing drag & drop | 180 // TODO(yefim): Implement this when implementing drag & drop |
| 181 // for action box menu. | 181 // for action box menu. |
| 182 } else if ( | 182 } else if ( |
| 183 service_->extension_prefs()->GetBrowserActionVisibility(extension)) { | 183 service_->extension_prefs()->GetBrowserActionVisibility(extension)) { |
| 184 AddExtension(extension, &toolbar_items_); | 184 AddExtension(extension, &toolbar_items_); |
| 185 } else { | 185 } else { |
| 186 RemoveExtension(extension, &toolbar_items_); | 186 RemoveExtension(extension, &toolbar_items_); |
| 187 } | 187 } |
| 188 } else { | 188 } else { |
| 189 NOTREACHED() << "Received unexpected notification"; | 189 NOTREACHED() << "Received unexpected notification"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Combine the currently enabled extensions that have browser actions (which | 243 // Combine the currently enabled extensions that have browser actions (which |
| 244 // we get from the ExtensionService) with the ordering we get from the | 244 // we get from the ExtensionService) with the ordering we get from the |
| 245 // pref service. For robustness we use a somewhat inefficient process: | 245 // pref service. For robustness we use a somewhat inefficient process: |
| 246 // 1. Create a vector of extensions sorted by their pref values. This vector may | 246 // 1. Create a vector of extensions sorted by their pref values. This vector may |
| 247 // have holes. | 247 // have holes. |
| 248 // 2. Create a vector of extensions that did not have a pref value. | 248 // 2. Create a vector of extensions that did not have a pref value. |
| 249 // 3. Remove holes from the sorted vector and append the unsorted vector. | 249 // 3. Remove holes from the sorted vector and append the unsorted vector. |
| 250 void ExtensionToolbarModel::InitializeExtensionLists() { | 250 void ExtensionToolbarModel::InitializeExtensionLists() { |
| 251 DCHECK(service_->is_ready()); | 251 DCHECK(service_->is_ready()); |
| 252 | 252 |
| 253 if (extensions::switch_utils::IsActionBoxEnabled()) | 253 if (extensions::switch_utils::IsExtensionsInActionBoxEnabled()) |
| 254 PopulateForActionBoxMode(); | 254 PopulateForActionBoxMode(); |
| 255 else | 255 else |
| 256 PopulateForNonActionBoxMode(); | 256 PopulateForNonActionBoxMode(); |
| 257 | 257 |
| 258 UpdatePrefs(); | 258 UpdatePrefs(); |
| 259 | 259 |
| 260 extensions_initialized_ = true; | 260 extensions_initialized_ = true; |
| 261 FOR_EACH_OBSERVER(Observer, observers_, ModelLoaded()); | 261 FOR_EACH_OBSERVER(Observer, observers_, ModelLoaded()); |
| 262 } | 262 } |
| 263 | 263 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 for (ExtensionList::iterator iter = toolbar_items_.begin(); | 389 for (ExtensionList::iterator iter = toolbar_items_.begin(); |
| 390 iter != toolbar_items_.end(); | 390 iter != toolbar_items_.end(); |
| 391 ++iter, ++i) { | 391 ++iter, ++i) { |
| 392 if (original_index == i) | 392 if (original_index == i) |
| 393 break; | 393 break; |
| 394 if (service_->IsIncognitoEnabled((*iter)->id())) | 394 if (service_->IsIncognitoEnabled((*iter)->id())) |
| 395 ++incognito_index; | 395 ++incognito_index; |
| 396 } | 396 } |
| 397 return incognito_index; | 397 return incognito_index; |
| 398 } | 398 } |
| OLD | NEW |