| 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/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 454 } | 454 } | 
| 455 | 455 | 
| 456 WebContents* LocationBarViewGtk::GetWebContents() const { | 456 WebContents* LocationBarViewGtk::GetWebContents() const { | 
| 457   return browser_->GetActiveWebContents(); | 457   return browser_->GetActiveWebContents(); | 
| 458 } | 458 } | 
| 459 | 459 | 
| 460 void LocationBarViewGtk::SetPreviewEnabledPageAction( | 460 void LocationBarViewGtk::SetPreviewEnabledPageAction( | 
| 461     ExtensionAction *page_action, | 461     ExtensionAction *page_action, | 
| 462     bool preview_enabled) { | 462     bool preview_enabled) { | 
| 463   DCHECK(page_action); | 463   DCHECK(page_action); | 
| 464   UpdatePageActions(); |  | 
| 465   for (ScopedVector<PageActionViewGtk>::iterator iter = | 464   for (ScopedVector<PageActionViewGtk>::iterator iter = | 
| 466        page_action_views_.begin(); iter != page_action_views_.end(); | 465        page_action_views_.begin(); iter != page_action_views_.end(); | 
| 467        ++iter) { | 466        ++iter) { | 
| 468     if ((*iter)->page_action() == page_action) { | 467     if ((*iter)->page_action() == page_action) { | 
| 469       (*iter)->set_preview_enabled(preview_enabled); | 468       (*iter)->set_preview_enabled(preview_enabled); | 
| 470       UpdatePageActions(); | 469       UpdatePageActions(); | 
| 471       return; | 470       return; | 
| 472     } | 471     } | 
| 473   } | 472   } | 
| 474 } | 473 } | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 715         toolbar_model_->input_in_progress() ? NULL : web_contents); | 714         toolbar_model_->input_in_progress() ? NULL : web_contents); | 
| 716     any_visible = (*i)->IsVisible() || any_visible; | 715     any_visible = (*i)->IsVisible() || any_visible; | 
| 717   } | 716   } | 
| 718 | 717 | 
| 719   // If there are no visible content things, hide the top level box so it | 718   // If there are no visible content things, hide the top level box so it | 
| 720   // doesn't mess with padding. | 719   // doesn't mess with padding. | 
| 721   gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 720   gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 
| 722 } | 721 } | 
| 723 | 722 | 
| 724 void LocationBarViewGtk::UpdatePageActions() { | 723 void LocationBarViewGtk::UpdatePageActions() { | 
| 725   std::vector<ExtensionAction*> page_actions; | 724   std::vector<ExtensionAction*> new_page_actions; | 
| 726 | 725 | 
| 727   TabContents* tab_contents = GetTabContents(); | 726   TabContents* tab_contents = GetTabContents(); | 
| 728   if (tab_contents) { | 727   if (tab_contents) { | 
| 729     LocationBarController* controller = | 728     LocationBarController* controller = | 
| 730         tab_contents->extension_tab_helper()->location_bar_controller(); | 729         tab_contents->extension_tab_helper()->location_bar_controller(); | 
| 731     page_actions.swap(*controller->GetCurrentActions()); | 730     new_page_actions = controller->GetCurrentActions(); | 
| 732   } | 731   } | 
| 733 | 732 | 
| 734   // Initialize on the first call, or re-inialize if more extensions have been | 733   // Initialize on the first call, or re-initialize if more extensions have been | 
| 735   // loaded or added after startup. | 734   // loaded or added after startup. | 
| 736   if (page_actions.size() != page_action_views_.size()) { | 735   if (new_page_actions != page_actions_) { | 
| 737     page_action_views_.reset();  // Delete the old views (if any). | 736     page_actions_.swap(new_page_actions); | 
|  | 737     page_action_views_.reset(); | 
| 738 | 738 | 
| 739     for (size_t i = 0; i < page_actions.size(); ++i) { | 739     for (size_t i = 0; i < page_actions_.size(); ++i) { | 
| 740       page_action_views_.push_back( | 740       page_action_views_.push_back( | 
| 741           new PageActionViewGtk(this, page_actions[i])); | 741           new PageActionViewGtk(this, page_actions_[i])); | 
| 742       gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), | 742       gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), | 
| 743                        page_action_views_[i]->widget(), FALSE, FALSE, 0); | 743                        page_action_views_[i]->widget(), FALSE, FALSE, 0); | 
| 744     } | 744     } | 
| 745     content::NotificationService::current()->Notify( | 745     content::NotificationService::current()->Notify( | 
| 746         chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 746         chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 
| 747         content::Source<LocationBar>(this), | 747         content::Source<LocationBar>(this), | 
| 748         content::NotificationService::NoDetails()); | 748         content::NotificationService::NoDetails()); | 
| 749   } | 749   } | 
| 750 | 750 | 
| 751   WebContents* contents = GetWebContents(); | 751   WebContents* contents = GetWebContents(); | 
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1926     GdkModifierType modifier, | 1926     GdkModifierType modifier, | 
| 1927     void* user_data) { | 1927     void* user_data) { | 
| 1928   PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); | 1928   PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); | 
| 1929   if (!gtk_widget_get_visible(view->widget())) | 1929   if (!gtk_widget_get_visible(view->widget())) | 
| 1930     return FALSE; | 1930     return FALSE; | 
| 1931 | 1931 | 
| 1932   GdkEventButton event = {}; | 1932   GdkEventButton event = {}; | 
| 1933   event.button = 1; | 1933   event.button = 1; | 
| 1934   return view->OnButtonPressed(view->widget(), &event); | 1934   return view->OnButtonPressed(view->widget(), &event); | 
| 1935 } | 1935 } | 
| OLD | NEW | 
|---|