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

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

Issue 368133005: Fixes for re-enabling more MSVC level 4 warnings: chrome/browser/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment Created 6 years, 5 months 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) 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 <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 for (ExtensionList::const_iterator iter_ext = toolbar_items_.begin(); 249 for (ExtensionList::const_iterator iter_ext = toolbar_items_.begin();
250 iter_ext < toolbar_items_.end(); ++iter_ext) { 250 iter_ext < toolbar_items_.end(); ++iter_ext) {
251 if ((*iter_ext)->id().compare(*iter_id) == 0) { 251 if ((*iter_ext)->id().compare(*iter_id) == 0) {
252 // This extension is visible, update the index value. 252 // This extension is visible, update the index value.
253 ++new_index; 253 ++new_index;
254 break; 254 break;
255 } 255 }
256 } 256 }
257 } 257 }
258 258
259 return -1; 259 // Position not found.
260 return toolbar_items_.size();
260 } 261 }
261 262
262 void ExtensionToolbarModel::AddExtension(const Extension* extension) { 263 void ExtensionToolbarModel::AddExtension(const Extension* extension) {
263 // We only care about extensions with browser actions. 264 // We only care about extensions with browser actions.
264 if (!ExtensionActionManager::Get(profile_)->GetBrowserAction(*extension)) 265 if (!ExtensionActionManager::Get(profile_)->GetBrowserAction(*extension))
265 return; 266 return;
266 267
267 size_t new_index = -1; 268 size_t new_index = toolbar_items_.size();
268 269
269 // See if we have a last known good position for this extension. 270 // See if we have a last known good position for this extension.
270 ExtensionIdList::iterator last_pos = std::find(last_known_positions_.begin(), 271 ExtensionIdList::iterator last_pos = std::find(last_known_positions_.begin(),
271 last_known_positions_.end(), 272 last_known_positions_.end(),
272 extension->id()); 273 extension->id());
273 if (last_pos != last_known_positions_.end()) { 274 if (last_pos != last_known_positions_.end()) {
274 new_index = FindNewPositionFromLastKnownGood(extension); 275 new_index = FindNewPositionFromLastKnownGood(extension);
275 if (new_index != toolbar_items_.size()) { 276 if (new_index != toolbar_items_.size()) {
276 toolbar_items_.insert(toolbar_items_.begin() + new_index, 277 toolbar_items_.insert(toolbar_items_.begin() + new_index,
277 make_scoped_refptr(extension)); 278 make_scoped_refptr(extension));
278 } else { 279 } else {
279 toolbar_items_.push_back(make_scoped_refptr(extension)); 280 toolbar_items_.push_back(make_scoped_refptr(extension));
280 } 281 }
281 } else { 282 } else {
282 // This is a never before seen extension, that was added to the end. Make 283 // This is a never before seen extension, that was added to the end. Make
283 // sure to reflect that. 284 // sure to reflect that. (|new_index| was set above.)
284 toolbar_items_.push_back(make_scoped_refptr(extension)); 285 toolbar_items_.push_back(make_scoped_refptr(extension));
285 last_known_positions_.push_back(extension->id()); 286 last_known_positions_.push_back(extension->id());
286 new_index = toolbar_items_.size() - 1;
287 UpdatePrefs(); 287 UpdatePrefs();
288 } 288 }
289 289
290 // If we're currently highlighting, then even though we add a browser action 290 // If we're currently highlighting, then even though we add a browser action
291 // to the full list (|toolbar_items_|, there won't be another *visible* 291 // to the full list (|toolbar_items_|, there won't be another *visible*
292 // browser action, which was what the observers care about. 292 // browser action, which was what the observers care about.
293 if (!is_highlighting_) { 293 if (!is_highlighting_) {
294 FOR_EACH_OBSERVER(Observer, observers_, 294 FOR_EACH_OBSERVER(Observer, observers_,
295 BrowserActionAdded(extension, new_index)); 295 BrowserActionAdded(extension, new_index));
296 } 296 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 is_highlighting_ = false; 582 is_highlighting_ = false;
583 if (old_visible_icon_count_ != visible_icon_count_) { 583 if (old_visible_icon_count_ != visible_icon_count_) {
584 SetVisibleIconCount(old_visible_icon_count_); 584 SetVisibleIconCount(old_visible_icon_count_);
585 FOR_EACH_OBSERVER(Observer, observers_, VisibleCountChanged()); 585 FOR_EACH_OBSERVER(Observer, observers_, VisibleCountChanged());
586 } 586 }
587 FOR_EACH_OBSERVER(Observer, observers_, HighlightModeChanged(false)); 587 FOR_EACH_OBSERVER(Observer, observers_, HighlightModeChanged(false));
588 } 588 }
589 } 589 }
590 590
591 } // namespace extensions 591 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/external_install_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698