| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 location_entry_->SetFocus(); | 394 location_entry_->SetFocus(); |
| 395 location_entry_->SelectAll(true); | 395 location_entry_->SelectAll(true); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void LocationBarViewGtk::FocusSearch() { | 398 void LocationBarViewGtk::FocusSearch() { |
| 399 location_entry_->SetFocus(); | 399 location_entry_->SetFocus(); |
| 400 location_entry_->SetForcedQuery(); | 400 location_entry_->SetForcedQuery(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 void LocationBarViewGtk::UpdatePageActions() { | 403 void LocationBarViewGtk::UpdatePageActions() { |
| 404 std::vector<PageAction*> page_actions; | 404 std::vector<ContextualAction*> page_actions; |
| 405 if (profile_->GetExtensionsService()) | 405 if (profile_->GetExtensionsService()) |
| 406 page_actions = profile_->GetExtensionsService()->GetPageActions(); | 406 page_actions = profile_->GetExtensionsService()->GetPageActions(); |
| 407 | 407 |
| 408 // Initialize on the first call, or re-inialize if more extensions have been | 408 // Initialize on the first call, or re-inialize if more extensions have been |
| 409 // loaded or added after startup. | 409 // loaded or added after startup. |
| 410 if (page_actions.size() != page_action_views_.size()) { | 410 if (page_actions.size() != page_action_views_.size()) { |
| 411 page_action_views_.reset(); // Delete the old views (if any). | 411 page_action_views_.reset(); // Delete the old views (if any). |
| 412 | 412 |
| 413 for (size_t i = 0; i < page_actions.size(); ++i) { | 413 for (size_t i = 0; i < page_actions.size(); ++i) { |
| 414 page_action_views_.push_back( | 414 page_action_views_.push_back( |
| 415 new PageActionViewGtk(this, profile_, page_actions[i])); | 415 new PageActionViewGtk(this, profile_, page_actions[i])); |
| 416 gtk_box_pack_end(GTK_BOX(page_action_hbox_), | 416 gtk_box_pack_end(GTK_BOX(page_action_hbox_), |
| 417 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 417 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 TabContents* contents = browser_->GetSelectedTabContents(); | 421 TabContents* contents = browser_->GetSelectedTabContents(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 return true; | 666 return true; |
| 667 } | 667 } |
| 668 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); | 668 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); |
| 669 return true; | 669 return true; |
| 670 } | 670 } |
| 671 | 671 |
| 672 //////////////////////////////////////////////////////////////////////////////// | 672 //////////////////////////////////////////////////////////////////////////////// |
| 673 // LocationBarViewGtk::PageActionViewGtk | 673 // LocationBarViewGtk::PageActionViewGtk |
| 674 | 674 |
| 675 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( | 675 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
| 676 LocationBarViewGtk* owner, Profile* profile, const PageAction* page_action) | 676 LocationBarViewGtk* owner, Profile* profile, |
| 677 const ContextualAction* page_action) |
| 677 : owner_(owner), | 678 : owner_(owner), |
| 678 profile_(profile), | 679 profile_(profile), |
| 679 page_action_(page_action) { | 680 page_action_(page_action) { |
| 680 event_box_.Own(gtk_event_box_new()); | 681 event_box_.Own(gtk_event_box_new()); |
| 681 // Make the event box not visible so it does not paint a background. | 682 // Make the event box not visible so it does not paint a background. |
| 682 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 683 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
| 683 g_signal_connect(event_box_.get(), "button-press-event", | 684 g_signal_connect(event_box_.get(), "button-press-event", |
| 684 G_CALLBACK(&OnButtonPressed), this); | 685 G_CALLBACK(&OnButtonPressed), this); |
| 685 | 686 |
| 686 image_.Own(gtk_image_new()); | 687 image_.Own(gtk_image_new()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 698 iter != icon_paths.end(); ++iter) { | 699 iter != icon_paths.end(); ++iter) { |
| 699 tracker_->PostLoadImageTask(extension->GetResourcePath(*iter)); | 700 tracker_->PostLoadImageTask(extension->GetResourcePath(*iter)); |
| 700 } | 701 } |
| 701 } | 702 } |
| 702 | 703 |
| 703 LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() { | 704 LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() { |
| 704 if (tracker_) | 705 if (tracker_) |
| 705 tracker_->StopTrackingImageLoad(); | 706 tracker_->StopTrackingImageLoad(); |
| 706 image_.Destroy(); | 707 image_.Destroy(); |
| 707 event_box_.Destroy(); | 708 event_box_.Destroy(); |
| 708 for (size_t i=0; i < pixbufs_.size(); ++i) { | 709 for (size_t i = 0; i < pixbufs_.size(); ++i) { |
| 709 if (pixbufs_[i]) | 710 if (pixbufs_[i]) |
| 710 g_object_unref(pixbufs_[i]); | 711 g_object_unref(pixbufs_[i]); |
| 711 } | 712 } |
| 712 } | 713 } |
| 713 | 714 |
| 714 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( | 715 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( |
| 715 TabContents* contents, GURL url) { | 716 TabContents* contents, GURL url) { |
| 716 // Save this off so we can pass it back to the extension when the action gets | 717 // Save this off so we can pass it back to the extension when the action gets |
| 717 // executed. See PageActionImageView::OnMousePressed. | 718 // executed. See PageActionImageView::OnMousePressed. |
| 718 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); | 719 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); |
| 719 current_url_ = url; | 720 current_url_ = url; |
| 720 | 721 |
| 721 const PageActionState* state = contents->GetPageActionState(page_action_); | 722 const ContextualActionState* state = |
| 723 contents->GetPageActionState(page_action_); |
| 722 bool visible = state != NULL; | 724 bool visible = state != NULL; |
| 723 if (visible) { | 725 if (visible) { |
| 724 // Set the tooltip. | 726 // Set the tooltip. |
| 725 if (state->title().empty()) | 727 if (state->title().empty()) |
| 726 gtk_widget_set_tooltip_text(event_box_.get(), | 728 gtk_widget_set_tooltip_text(event_box_.get(), |
| 727 page_action_->name().c_str()); | 729 page_action_->name().c_str()); |
| 728 else | 730 else |
| 729 gtk_widget_set_tooltip_text(event_box_.get(), state->title().c_str()); | 731 gtk_widget_set_tooltip_text(event_box_.get(), state->title().c_str()); |
| 730 // Set the image. | 732 // Set the image. |
| 731 int index = state->icon_index(); | 733 int index = state->icon_index(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 762 LocationBarViewGtk::PageActionViewGtk* page_action_view) { | 764 LocationBarViewGtk::PageActionViewGtk* page_action_view) { |
| 763 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 765 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
| 764 page_action_view->profile_, | 766 page_action_view->profile_, |
| 765 page_action_view->page_action_->extension_id(), | 767 page_action_view->page_action_->extension_id(), |
| 766 page_action_view->page_action_->id(), | 768 page_action_view->page_action_->id(), |
| 767 page_action_view->current_tab_id_, | 769 page_action_view->current_tab_id_, |
| 768 page_action_view->current_url_.spec(), | 770 page_action_view->current_url_.spec(), |
| 769 event->button); | 771 event->button); |
| 770 return true; | 772 return true; |
| 771 } | 773 } |
| OLD | NEW |