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

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

Issue 489183005: Make a ShowExtensionActionPopup function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's Created 6 years, 3 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
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 if (last_known_positions_.size() > pref_position_size) { 562 if (last_known_positions_.size() > pref_position_size) {
563 // Need to update pref because we have extra icons. But can't call 563 // Need to update pref because we have extra icons. But can't call
564 // UpdatePrefs() directly within observation closure. 564 // UpdatePrefs() directly within observation closure.
565 base::MessageLoop::current()->PostTask( 565 base::MessageLoop::current()->PostTask(
566 FROM_HERE, 566 FROM_HERE,
567 base::Bind(&ExtensionToolbarModel::UpdatePrefs, 567 base::Bind(&ExtensionToolbarModel::UpdatePrefs,
568 weak_ptr_factory_.GetWeakPtr())); 568 weak_ptr_factory_.GetWeakPtr()));
569 } 569 }
570 } 570 }
571 571
572 bool ExtensionToolbarModel::ShowBrowserActionPopup(const Extension* extension) { 572 bool ExtensionToolbarModel::ShowExtensionActionPopup(
573 const Extension* extension,
574 Browser* browser,
575 bool grant_active_tab) {
573 ObserverListBase<Observer>::Iterator it(observers_); 576 ObserverListBase<Observer>::Iterator it(observers_);
574 Observer* obs = NULL; 577 Observer* obs = NULL;
578 // Look for the Observer associated with the browser.
579 // This would be cleaner if we had an abstract class for the Toolbar UI
580 // (like we do for LocationBar), but sadly, we don't.
575 while ((obs = it.GetNext()) != NULL) { 581 while ((obs = it.GetNext()) != NULL) {
576 // Stop after first popup since it should only show in the active window. 582 if (obs->GetBrowser() == browser)
577 if (obs->ShowExtensionActionPopup(extension)) 583 return obs->ShowExtensionActionPopup(extension, grant_active_tab);
578 return true;
579 } 584 }
580 return false; 585 return false;
581 } 586 }
582 587
583 void ExtensionToolbarModel::EnsureVisibility( 588 void ExtensionToolbarModel::EnsureVisibility(
584 const ExtensionIdList& extension_ids) { 589 const ExtensionIdList& extension_ids) {
585 if (visible_icon_count_ == -1) 590 if (visible_icon_count_ == -1)
586 return; // Already showing all. 591 return; // Already showing all.
587 592
588 // Otherwise, make sure we have enough room to show all the extensions 593 // Otherwise, make sure we have enough room to show all the extensions
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false)); 664 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false));
660 } 665 }
661 } 666 }
662 667
663 void ExtensionToolbarModel::SetVisibleIconCountForTest(size_t visible_icons) { 668 void ExtensionToolbarModel::SetVisibleIconCountForTest(size_t visible_icons) {
664 SetVisibleIconCount(visible_icons); 669 SetVisibleIconCount(visible_icons);
665 FOR_EACH_OBSERVER(Observer, observers_, ToolbarVisibleCountChanged()); 670 FOR_EACH_OBSERVER(Observer, observers_, ToolbarVisibleCountChanged());
666 } 671 }
667 672
668 } // namespace extensions 673 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.h ('k') | chrome/browser/extensions/extension_toolbar_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698