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

Side by Side Diff: chrome/browser/extensions/extension_toolbar_model.cc

Issue 5168004: Revert 66646 - Add "open as window" menu item to NTP app menu.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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) 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/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 void ExtensionToolbarModel::Observe(NotificationType type, 85 void ExtensionToolbarModel::Observe(NotificationType type,
86 const NotificationSource& source, 86 const NotificationSource& source,
87 const NotificationDetails& details) { 87 const NotificationDetails& details) {
88 if (type == NotificationType::EXTENSIONS_READY) { 88 if (type == NotificationType::EXTENSIONS_READY) {
89 InitializeExtensionList(); 89 InitializeExtensionList();
90 return; 90 return;
91 } 91 }
92 92
93 if (!service_->is_ready())
94 return;
95
93 const Extension* extension = Details<const Extension>(details).ptr(); 96 const Extension* extension = Details<const Extension>(details).ptr();
94 if (type == NotificationType::EXTENSION_LOADED) { 97 if (type == NotificationType::EXTENSION_LOADED) {
95 AddExtension(extension); 98 AddExtension(extension);
96 } else if (type == NotificationType::EXTENSION_UNLOADED || 99 } else if (type == NotificationType::EXTENSION_UNLOADED ||
97 type == NotificationType::EXTENSION_UNLOADED_DISABLED) { 100 type == NotificationType::EXTENSION_UNLOADED_DISABLED) {
98 RemoveExtension(extension); 101 RemoveExtension(extension);
99 } else { 102 } else {
100 NOTREACHED() << "Received unexpected notification"; 103 NOTREACHED() << "Received unexpected notification";
101 } 104 }
102 } 105 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 144 }
142 145
143 // Combine the currently enabled extensions that have browser actions (which 146 // Combine the currently enabled extensions that have browser actions (which
144 // we get from the ExtensionsService) with the ordering we get from the 147 // we get from the ExtensionsService) with the ordering we get from the
145 // pref service. For robustness we use a somewhat inefficient process: 148 // pref service. For robustness we use a somewhat inefficient process:
146 // 1. Create a vector of extensions sorted by their pref values. This vector may 149 // 1. Create a vector of extensions sorted by their pref values. This vector may
147 // have holes. 150 // have holes.
148 // 2. Create a vector of extensions that did not have a pref value. 151 // 2. Create a vector of extensions that did not have a pref value.
149 // 3. Remove holes from the sorted vector and append the unsorted vector. 152 // 3. Remove holes from the sorted vector and append the unsorted vector.
150 void ExtensionToolbarModel::InitializeExtensionList() { 153 void ExtensionToolbarModel::InitializeExtensionList() {
154 DCHECK(service_->is_ready());
155
151 std::vector<std::string> pref_order = service_->extension_prefs()-> 156 std::vector<std::string> pref_order = service_->extension_prefs()->
152 GetToolbarOrder(); 157 GetToolbarOrder();
153 // Items that have a pref for their position. 158 // Items that have a pref for their position.
154 ExtensionList sorted; 159 ExtensionList sorted;
155 sorted.resize(pref_order.size(), NULL); 160 sorted.resize(pref_order.size(), NULL);
156 // The items that don't have a pref for their position. 161 // The items that don't have a pref for their position.
157 ExtensionList unsorted; 162 ExtensionList unsorted;
158 163
159 // Create the lists. 164 // Create the lists.
160 for (size_t i = 0; i < service_->extensions()->size(); ++i) { 165 for (size_t i = 0; i < service_->extensions()->size(); ++i) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 int incognito_index = 0, i = 0; 230 int incognito_index = 0, i = 0;
226 for (ExtensionList::iterator iter = begin(); iter != end(); 231 for (ExtensionList::iterator iter = begin(); iter != end();
227 ++iter, ++i) { 232 ++iter, ++i) {
228 if (original_index == i) 233 if (original_index == i)
229 break; 234 break;
230 if (service_->IsIncognitoEnabled(*iter)) 235 if (service_->IsIncognitoEnabled(*iter))
231 ++incognito_index; 236 ++incognito_index;
232 } 237 }
233 return incognito_index; 238 return incognito_index;
234 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_startup_browsertest.cc ('k') | chrome/browser/extensions/extensions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698