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/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.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/logging.h" | 13 #include "base/logging.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
16 #include "chrome/browser/accessibility_events.h" | 16 #include "chrome/browser/accessibility_events.h" |
17 #include "chrome/browser/alternate_nav_url_fetcher.h" | 17 #include "chrome/browser/alternate_nav_url_fetcher.h" |
18 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 18 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
20 #include "chrome/browser/browser_list.h" | 20 #include "chrome/browser/browser_list.h" |
21 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
22 #include "chrome/browser/content_setting_bubble_model.h" | 22 #include "chrome/browser/content_setting_bubble_model.h" |
23 #include "chrome/browser/content_setting_image_model.h" | 23 #include "chrome/browser/content_setting_image_model.h" |
24 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" | 24 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" |
25 #include "chrome/browser/extensions/extension_action_context_menu_model.h" | |
26 #include "chrome/browser/extensions/extension_browser_event_router.h" | 25 #include "chrome/browser/extensions/extension_browser_event_router.h" |
27 #include "chrome/browser/extensions/extension_tabs_module.h" | 26 #include "chrome/browser/extensions/extension_tabs_module.h" |
28 #include "chrome/browser/extensions/extensions_service.h" | 27 #include "chrome/browser/extensions/extensions_service.h" |
29 #include "chrome/browser/gtk/cairo_cached_surface.h" | 28 #include "chrome/browser/gtk/cairo_cached_surface.h" |
30 #include "chrome/browser/gtk/content_blocked_bubble_gtk.h" | 29 #include "chrome/browser/gtk/content_blocked_bubble_gtk.h" |
31 #include "chrome/browser/gtk/extension_popup_gtk.h" | 30 #include "chrome/browser/gtk/extension_popup_gtk.h" |
32 #include "chrome/browser/gtk/first_run_bubble.h" | 31 #include "chrome/browser/gtk/first_run_bubble.h" |
33 #include "chrome/browser/gtk/gtk_theme_provider.h" | 32 #include "chrome/browser/gtk/gtk_theme_provider.h" |
34 #include "chrome/browser/gtk/gtk_util.h" | 33 #include "chrome/browser/gtk/gtk_util.h" |
35 #include "chrome/browser/gtk/rounded_window.h" | 34 #include "chrome/browser/gtk/rounded_window.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // LocationBarViewGtk | 129 // LocationBarViewGtk |
131 | 130 |
132 // static | 131 // static |
133 const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { | 132 const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { |
134 GDK_COLOR_RGB(255, 245, 195), // SecurityLevel SECURE: Yellow. | 133 GDK_COLOR_RGB(255, 245, 195), // SecurityLevel SECURE: Yellow. |
135 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel NORMAL: White. | 134 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel NORMAL: White. |
136 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel INSECURE: White. | 135 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel INSECURE: White. |
137 }; | 136 }; |
138 | 137 |
139 LocationBarViewGtk::LocationBarViewGtk( | 138 LocationBarViewGtk::LocationBarViewGtk( |
140 CommandUpdater* command_updater, | |
141 ToolbarModel* toolbar_model, | |
142 const BubblePositioner* bubble_positioner, | 139 const BubblePositioner* bubble_positioner, |
143 Browser* browser) | 140 Browser* browser) |
144 : security_icon_event_box_(NULL), | 141 : security_icon_event_box_(NULL), |
145 security_lock_icon_image_(NULL), | 142 security_lock_icon_image_(NULL), |
146 security_warning_icon_image_(NULL), | 143 security_warning_icon_image_(NULL), |
147 info_label_(NULL), | 144 info_label_(NULL), |
148 tab_to_search_box_(NULL), | 145 tab_to_search_box_(NULL), |
149 tab_to_search_full_label_(NULL), | 146 tab_to_search_full_label_(NULL), |
150 tab_to_search_partial_label_(NULL), | 147 tab_to_search_partial_label_(NULL), |
151 tab_to_search_hint_(NULL), | 148 tab_to_search_hint_(NULL), |
152 tab_to_search_hint_leading_label_(NULL), | 149 tab_to_search_hint_leading_label_(NULL), |
153 tab_to_search_hint_icon_(NULL), | 150 tab_to_search_hint_icon_(NULL), |
154 tab_to_search_hint_trailing_label_(NULL), | 151 tab_to_search_hint_trailing_label_(NULL), |
155 type_to_search_hint_(NULL), | 152 type_to_search_hint_(NULL), |
156 profile_(NULL), | 153 profile_(NULL), |
157 command_updater_(command_updater), | 154 command_updater_(browser->command_updater()), |
158 toolbar_model_(toolbar_model), | 155 toolbar_model_(browser->toolbar_model()), |
159 browser_(browser), | 156 browser_(browser), |
160 bubble_positioner_(bubble_positioner), | 157 bubble_positioner_(bubble_positioner), |
161 disposition_(CURRENT_TAB), | 158 disposition_(CURRENT_TAB), |
162 transition_(PageTransition::TYPED), | 159 transition_(PageTransition::TYPED), |
163 first_run_bubble_(this), | 160 first_run_bubble_(this), |
164 popup_window_mode_(false), | 161 popup_window_mode_(false), |
165 theme_provider_(NULL), | 162 theme_provider_(NULL), |
166 entry_box_width_(0), | 163 entry_box_width_(0), |
167 show_selected_keyword_(false), | 164 show_selected_keyword_(false), |
168 show_keyword_hint_(false), | 165 show_keyword_hint_(false), |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 | 1185 |
1189 owner_->UpdatePageActions(); | 1186 owner_->UpdatePageActions(); |
1190 } | 1187 } |
1191 | 1188 |
1192 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { | 1189 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { |
1193 GdkEvent event; | 1190 GdkEvent event; |
1194 event.button.button = 1; | 1191 event.button.button = 1; |
1195 OnButtonPressed(widget(), &event); | 1192 OnButtonPressed(widget(), &event); |
1196 } | 1193 } |
1197 | 1194 |
| 1195 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 1196 ExtensionAction* action) { |
| 1197 // TODO(estade): http://crbug.com/24477 |
| 1198 NOTIMPLEMENTED(); |
| 1199 } |
| 1200 |
1198 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( | 1201 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( |
1199 GtkWidget* sender, | 1202 GtkWidget* sender, |
1200 GdkEvent* event) { | 1203 GdkEvent* event) { |
1201 if (event->button.button != 3) { | 1204 if (event->button.button != 3) { |
1202 if (page_action_->HasPopup(current_tab_id_)) { | 1205 if (page_action_->HasPopup(current_tab_id_)) { |
1203 ExtensionPopupGtk::Show( | 1206 ExtensionPopupGtk::Show( |
1204 page_action_->GetPopupUrl(current_tab_id_), | 1207 page_action_->GetPopupUrl(current_tab_id_), |
1205 owner_->browser_, | 1208 owner_->browser_, |
1206 gtk_util::GetWidgetRectRelativeToToplevel(event_box_.get())); | 1209 gtk_util::GetWidgetRectRelativeToToplevel(event_box_.get())); |
1207 } else { | 1210 } else { |
1208 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 1211 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
1209 profile_, | 1212 profile_, |
1210 page_action_->extension_id(), | 1213 page_action_->extension_id(), |
1211 page_action_->id(), | 1214 page_action_->id(), |
1212 current_tab_id_, | 1215 current_tab_id_, |
1213 current_url_.spec(), | 1216 current_url_.spec(), |
1214 event->button.button); | 1217 event->button.button); |
1215 } | 1218 } |
1216 } else { | 1219 } else { |
1217 Extension* extension = profile_->GetExtensionsService()->GetExtensionById( | 1220 Extension* extension = profile_->GetExtensionsService()->GetExtensionById( |
1218 page_action()->extension_id(), false); | 1221 page_action()->extension_id(), false); |
1219 | 1222 |
1220 // TODO(rafaelw): support inspecting popups. | 1223 context_menu_model_.reset( |
1221 if (!context_menu_model_.get()) | 1224 new ExtensionContextMenuModel(extension, owner_->browser_, this)); |
1222 context_menu_model_.reset(new ExtensionActionContextMenuModel(extension, | |
1223 page_action_, profile_->GetPrefs(), NULL)); | |
1224 | |
1225 context_menu_.reset( | 1225 context_menu_.reset( |
1226 new MenuGtk(NULL, context_menu_model_.get())); | 1226 new MenuGtk(NULL, context_menu_model_.get())); |
1227 context_menu_->Popup(sender, event); | 1227 context_menu_->Popup(sender, event); |
1228 } | 1228 } |
1229 | 1229 |
1230 return TRUE; | 1230 return TRUE; |
1231 } | 1231 } |
1232 | 1232 |
1233 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( | 1233 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( |
1234 GtkWidget* widget, GdkEventExpose* event) { | 1234 GtkWidget* widget, GdkEventExpose* event) { |
1235 TabContents* contents = owner_->GetTabContents(); | 1235 TabContents* contents = owner_->GetTabContents(); |
1236 if (!contents) | 1236 if (!contents) |
1237 return FALSE; | 1237 return FALSE; |
1238 | 1238 |
1239 int tab_id = ExtensionTabUtil::GetTabId(contents); | 1239 int tab_id = ExtensionTabUtil::GetTabId(contents); |
1240 if (tab_id < 0) | 1240 if (tab_id < 0) |
1241 return FALSE; | 1241 return FALSE; |
1242 | 1242 |
1243 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1243 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1244 if (badge_text.empty()) | 1244 if (badge_text.empty()) |
1245 return FALSE; | 1245 return FALSE; |
1246 | 1246 |
1247 gfx::CanvasPaint canvas(event, false); | 1247 gfx::CanvasPaint canvas(event, false); |
1248 gfx::Rect bounding_rect(widget->allocation); | 1248 gfx::Rect bounding_rect(widget->allocation); |
1249 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1249 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1250 return FALSE; | 1250 return FALSE; |
1251 } | 1251 } |
OLD | NEW |