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

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 10544185: Order the script badges in the location bar consistently (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 6 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/ui/gtk/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 442 }
443 443
444 WebContents* LocationBarViewGtk::GetWebContents() const { 444 WebContents* LocationBarViewGtk::GetWebContents() const {
445 return browser_->GetActiveWebContents(); 445 return browser_->GetActiveWebContents();
446 } 446 }
447 447
448 void LocationBarViewGtk::SetPreviewEnabledPageAction( 448 void LocationBarViewGtk::SetPreviewEnabledPageAction(
449 ExtensionAction *page_action, 449 ExtensionAction *page_action,
450 bool preview_enabled) { 450 bool preview_enabled) {
451 DCHECK(page_action); 451 DCHECK(page_action);
452 UpdatePageActions();
453 for (ScopedVector<PageActionViewGtk>::iterator iter = 452 for (ScopedVector<PageActionViewGtk>::iterator iter =
454 page_action_views_.begin(); iter != page_action_views_.end(); 453 page_action_views_.begin(); iter != page_action_views_.end();
455 ++iter) { 454 ++iter) {
456 if ((*iter)->page_action() == page_action) { 455 if ((*iter)->page_action() == page_action) {
457 (*iter)->set_preview_enabled(preview_enabled); 456 (*iter)->set_preview_enabled(preview_enabled);
458 UpdatePageActions(); 457 UpdatePageActions();
459 return; 458 return;
460 } 459 }
461 } 460 }
462 } 461 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 toolbar_model_->input_in_progress() ? NULL : web_contents); 682 toolbar_model_->input_in_progress() ? NULL : web_contents);
684 any_visible = (*i)->IsVisible() || any_visible; 683 any_visible = (*i)->IsVisible() || any_visible;
685 } 684 }
686 685
687 // If there are no visible content things, hide the top level box so it 686 // If there are no visible content things, hide the top level box so it
688 // doesn't mess with padding. 687 // doesn't mess with padding.
689 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); 688 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible);
690 } 689 }
691 690
692 void LocationBarViewGtk::UpdatePageActions() { 691 void LocationBarViewGtk::UpdatePageActions() {
693 std::vector<ExtensionAction*> page_actions; 692 std::vector<ExtensionAction*> new_page_actions;
694 693
695 TabContents* tab_contents = GetTabContents(); 694 TabContents* tab_contents = GetTabContents();
696 if (tab_contents) { 695 if (tab_contents) {
697 LocationBarController* controller = 696 LocationBarController* controller =
698 tab_contents->extension_tab_helper()->location_bar_controller(); 697 tab_contents->extension_tab_helper()->location_bar_controller();
699 page_actions.swap(*controller->GetCurrentActions()); 698 new_page_actions.swap(*controller->GetCurrentActions());
700 } 699 }
701 700
702 // Initialize on the first call, or re-inialize if more extensions have been 701 // Initialize on the first call, or re-initialize if more extensions have been
703 // loaded or added after startup. 702 // loaded or added after startup.
704 if (page_actions.size() != page_action_views_.size()) { 703 if (new_page_actions != page_actions_) {
Evan Stade 2012/06/16 00:42:46 I've never actually tried to use comparison operat
Jeffrey Yasskin 2012/06/16 00:53:25 Yes: http://en.cppreference.com/w/cpp/container/ve
not at google - send to devlin 2012/06/18 17:50:27 Yep I assumed it did. Thanks Jeffrey for finding
705 page_action_views_.reset(); // Delete the old views (if any). 704 page_actions_.swap(new_page_actions);
705 page_action_views_.reset();
706 706
707 for (size_t i = 0; i < page_actions.size(); ++i) { 707 for (size_t i = 0; i < page_actions_.size(); ++i) {
708 page_action_views_.push_back( 708 page_action_views_.push_back(
709 new PageActionViewGtk(this, page_actions[i])); 709 new PageActionViewGtk(this, page_actions_[i]));
710 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), 710 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()),
711 page_action_views_[i]->widget(), FALSE, FALSE, 0); 711 page_action_views_[i]->widget(), FALSE, FALSE, 0);
712 } 712 }
713 content::NotificationService::current()->Notify( 713 content::NotificationService::current()->Notify(
714 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, 714 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
715 content::Source<LocationBar>(this), 715 content::Source<LocationBar>(this),
716 content::NotificationService::NoDetails()); 716 content::NotificationService::NoDetails());
717 } 717 }
718 718
719 WebContents* contents = GetWebContents(); 719 WebContents* contents = GetWebContents();
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 GdkModifierType modifier, 1824 GdkModifierType modifier,
1825 void* user_data) { 1825 void* user_data) {
1826 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); 1826 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data);
1827 if (!gtk_widget_get_visible(view->widget())) 1827 if (!gtk_widget_get_visible(view->widget()))
1828 return FALSE; 1828 return FALSE;
1829 1829
1830 GdkEventButton event = {}; 1830 GdkEventButton event = {};
1831 event.button = 1; 1831 event.button = 1;
1832 return view->OnButtonPressed(view->widget(), &event); 1832 return view->OnButtonPressed(view->widget(), &event);
1833 } 1833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698