OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
18 #include "chrome/browser/accessibility_events.h" | 18 #include "chrome/browser/accessibility_events.h" |
19 #include "chrome/browser/alternate_nav_url_fetcher.h" | 19 #include "chrome/browser/alternate_nav_url_fetcher.h" |
20 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 20 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
21 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 21 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
22 #include "chrome/browser/browser_list.h" | 22 #include "chrome/browser/browser_list.h" |
23 #include "chrome/browser/command_updater.h" | 23 #include "chrome/browser/command_updater.h" |
24 #include "chrome/browser/content_setting_bubble_model.h" | 24 #include "chrome/browser/content_setting_bubble_model.h" |
25 #include "chrome/browser/content_setting_image_model.h" | 25 #include "chrome/browser/content_setting_image_model.h" |
26 #include "chrome/browser/defaults.h" | 26 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/extensions/extension_browser_event_router.h" | 27 #include "chrome/browser/extensions/extension_browser_event_router.h" |
28 #include "chrome/browser/extensions/extension_tabs_module.h" | 28 #include "chrome/browser/extensions/extension_tabs_module.h" |
29 #include "chrome/browser/extensions/extensions_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/gtk/bookmark_bubble_gtk.h" | 30 #include "chrome/browser/gtk/bookmark_bubble_gtk.h" |
31 #include "chrome/browser/gtk/bookmark_utils_gtk.h" | 31 #include "chrome/browser/gtk/bookmark_utils_gtk.h" |
32 #include "chrome/browser/gtk/cairo_cached_surface.h" | 32 #include "chrome/browser/gtk/cairo_cached_surface.h" |
33 #include "chrome/browser/gtk/content_setting_bubble_gtk.h" | 33 #include "chrome/browser/gtk/content_setting_bubble_gtk.h" |
34 #include "chrome/browser/gtk/extension_popup_gtk.h" | 34 #include "chrome/browser/gtk/extension_popup_gtk.h" |
35 #include "chrome/browser/gtk/first_run_bubble.h" | 35 #include "chrome/browser/gtk/first_run_bubble.h" |
36 #include "chrome/browser/gtk/gtk_theme_provider.h" | 36 #include "chrome/browser/gtk/gtk_theme_provider.h" |
37 #include "chrome/browser/gtk/gtk_util.h" | 37 #include "chrome/browser/gtk/gtk_util.h" |
38 #include "chrome/browser/gtk/nine_box.h" | 38 #include "chrome/browser/gtk/nine_box.h" |
39 #include "chrome/browser/gtk/rounded_window.h" | 39 #include "chrome/browser/gtk/rounded_window.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // If there are no visible content things, hide the top level box so it | 673 // If there are no visible content things, hide the top level box so it |
674 // doesn't mess with padding. | 674 // doesn't mess with padding. |
675 if (any_visible) | 675 if (any_visible) |
676 gtk_widget_show(content_setting_hbox_.get()); | 676 gtk_widget_show(content_setting_hbox_.get()); |
677 else | 677 else |
678 gtk_widget_hide(content_setting_hbox_.get()); | 678 gtk_widget_hide(content_setting_hbox_.get()); |
679 } | 679 } |
680 | 680 |
681 void LocationBarViewGtk::UpdatePageActions() { | 681 void LocationBarViewGtk::UpdatePageActions() { |
682 std::vector<ExtensionAction*> page_actions; | 682 std::vector<ExtensionAction*> page_actions; |
683 ExtensionsService* service = profile_->GetExtensionsService(); | 683 ExtensionService* service = profile_->GetExtensionService(); |
684 if (!service) | 684 if (!service) |
685 return; | 685 return; |
686 | 686 |
687 // Find all the page actions. | 687 // Find all the page actions. |
688 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 688 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
689 if (service->extensions()->at(i)->page_action()) | 689 if (service->extensions()->at(i)->page_action()) |
690 page_actions.push_back(service->extensions()->at(i)->page_action()); | 690 page_actions.push_back(service->extensions()->at(i)->page_action()); |
691 } | 691 } |
692 | 692 |
693 // Initialize on the first call, or re-inialize if more extensions have been | 693 // Initialize on the first call, or re-inialize if more extensions have been |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 WideToUTF8(full_name).c_str()); | 988 WideToUTF8(full_name).c_str()); |
989 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), | 989 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), |
990 WideToUTF8(partial_name).c_str()); | 990 WideToUTF8(partial_name).c_str()); |
991 | 991 |
992 if (last_keyword_ != keyword) { | 992 if (last_keyword_ != keyword) { |
993 last_keyword_ = keyword; | 993 last_keyword_ = keyword; |
994 | 994 |
995 if (is_extension_keyword) { | 995 if (is_extension_keyword) { |
996 const TemplateURL* template_url = | 996 const TemplateURL* template_url = |
997 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); | 997 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); |
998 const SkBitmap& bitmap = profile_->GetExtensionsService()-> | 998 const SkBitmap& bitmap = profile_->GetExtensionService()-> |
999 GetOmniboxIcon(template_url->GetExtensionId()); | 999 GetOmniboxIcon(template_url->GetExtensionId()); |
1000 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); | 1000 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); |
1001 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); | 1001 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); |
1002 g_object_unref(pixbuf); | 1002 g_object_unref(pixbuf); |
1003 } else { | 1003 } else { |
1004 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1004 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1005 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), | 1005 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), |
1006 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); | 1006 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); |
1007 } | 1007 } |
1008 } | 1008 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 // Make the event box not visible so it does not paint a background. | 1341 // Make the event box not visible so it does not paint a background. |
1342 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 1342 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
1343 g_signal_connect(event_box_.get(), "button-press-event", | 1343 g_signal_connect(event_box_.get(), "button-press-event", |
1344 G_CALLBACK(&OnButtonPressedThunk), this); | 1344 G_CALLBACK(&OnButtonPressedThunk), this); |
1345 g_signal_connect_after(event_box_.get(), "expose-event", | 1345 g_signal_connect_after(event_box_.get(), "expose-event", |
1346 G_CALLBACK(OnExposeEventThunk), this); | 1346 G_CALLBACK(OnExposeEventThunk), this); |
1347 | 1347 |
1348 image_.Own(gtk_image_new()); | 1348 image_.Own(gtk_image_new()); |
1349 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); | 1349 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); |
1350 | 1350 |
1351 const Extension* extension = profile->GetExtensionsService()-> | 1351 const Extension* extension = profile->GetExtensionService()-> |
1352 GetExtensionById(page_action->extension_id(), false); | 1352 GetExtensionById(page_action->extension_id(), false); |
1353 DCHECK(extension); | 1353 DCHECK(extension); |
1354 | 1354 |
1355 // Load all the icons declared in the manifest. This is the contents of the | 1355 // Load all the icons declared in the manifest. This is the contents of the |
1356 // icons array, plus the default_icon property, if any. | 1356 // icons array, plus the default_icon property, if any. |
1357 std::vector<std::string> icon_paths(*page_action->icon_paths()); | 1357 std::vector<std::string> icon_paths(*page_action->icon_paths()); |
1358 if (!page_action_->default_icon_path().empty()) | 1358 if (!page_action_->default_icon_path().empty()) |
1359 icon_paths.push_back(page_action_->default_icon_path()); | 1359 icon_paths.push_back(page_action_->default_icon_path()); |
1360 | 1360 |
1361 for (std::vector<std::string>::iterator iter = icon_paths.begin(); | 1361 for (std::vector<std::string>::iterator iter = icon_paths.begin(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 if (!ShowPopup(false)) { | 1505 if (!ShowPopup(false)) { |
1506 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 1506 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
1507 profile_, | 1507 profile_, |
1508 page_action_->extension_id(), | 1508 page_action_->extension_id(), |
1509 page_action_->id(), | 1509 page_action_->id(), |
1510 current_tab_id_, | 1510 current_tab_id_, |
1511 current_url_.spec(), | 1511 current_url_.spec(), |
1512 event->button.button); | 1512 event->button.button); |
1513 } | 1513 } |
1514 } else { | 1514 } else { |
1515 const Extension* extension = profile_->GetExtensionsService()-> | 1515 const Extension* extension = profile_->GetExtensionService()-> |
1516 GetExtensionById(page_action()->extension_id(), false); | 1516 GetExtensionById(page_action()->extension_id(), false); |
1517 | 1517 |
1518 context_menu_model_ = | 1518 context_menu_model_ = |
1519 new ExtensionContextMenuModel(extension, owner_->browser_, this); | 1519 new ExtensionContextMenuModel(extension, owner_->browser_, this); |
1520 context_menu_.reset( | 1520 context_menu_.reset( |
1521 new MenuGtk(NULL, context_menu_model_.get())); | 1521 new MenuGtk(NULL, context_menu_model_.get())); |
1522 context_menu_->Popup(sender, event); | 1522 context_menu_->Popup(sender, event); |
1523 } | 1523 } |
1524 | 1524 |
1525 return TRUE; | 1525 return TRUE; |
(...skipping 11 matching lines...) Expand all Loading... |
1537 | 1537 |
1538 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1538 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1539 if (badge_text.empty()) | 1539 if (badge_text.empty()) |
1540 return FALSE; | 1540 return FALSE; |
1541 | 1541 |
1542 gfx::CanvasSkiaPaint canvas(event, false); | 1542 gfx::CanvasSkiaPaint canvas(event, false); |
1543 gfx::Rect bounding_rect(widget->allocation); | 1543 gfx::Rect bounding_rect(widget->allocation); |
1544 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1544 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1545 return FALSE; | 1545 return FALSE; |
1546 } | 1546 } |
OLD | NEW |