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

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

Issue 11418043: Remove TabContents from OmniboxEditController and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros Created 8 years, 1 month 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 | Annotate | Revision Log
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "chrome/browser/ui/gtk/gtk_util.h" 58 #include "chrome/browser/ui/gtk/gtk_util.h"
59 #include "chrome/browser/ui/gtk/nine_box.h" 59 #include "chrome/browser/ui/gtk/nine_box.h"
60 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" 60 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
61 #include "chrome/browser/ui/gtk/rounded_window.h" 61 #include "chrome/browser/ui/gtk/rounded_window.h"
62 #include "chrome/browser/ui/gtk/view_id_util.h" 62 #include "chrome/browser/ui/gtk/view_id_util.h"
63 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" 63 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h"
64 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 64 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
65 #include "chrome/browser/ui/omnibox/location_bar_util.h" 65 #include "chrome/browser/ui/omnibox/location_bar_util.h"
66 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 66 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
67 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 67 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
68 #include "chrome/browser/ui/tab_contents/tab_contents.h"
69 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h" 68 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h"
70 #include "chrome/browser/ui/zoom/zoom_controller.h" 69 #include "chrome/browser/ui/zoom/zoom_controller.h"
71 #include "chrome/common/chrome_notification_types.h" 70 #include "chrome/common/chrome_notification_types.h"
72 #include "chrome/common/chrome_switches.h" 71 #include "chrome/common/chrome_switches.h"
73 #include "chrome/common/extensions/extension.h" 72 #include "chrome/common/extensions/extension.h"
74 #include "chrome/common/extensions/extension_manifest_constants.h" 73 #include "chrome/common/extensions/extension_manifest_constants.h"
75 #include "chrome/common/extensions/extension_resource.h" 74 #include "chrome/common/extensions/extension_resource.h"
76 #include "chrome/common/extensions/feature_switch.h" 75 #include "chrome/common/extensions/feature_switch.h"
77 #include "chrome/common/pref_names.h" 76 #include "chrome/common/pref_names.h"
78 #include "content/public/browser/navigation_entry.h" 77 #include "content/public/browser/navigation_entry.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 172 }
174 173
175 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, 174 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk,
176 public BubbleDelegateGtk { 175 public BubbleDelegateGtk {
177 public: 176 public:
178 ContentSettingImageViewGtk(ContentSettingsType content_type, 177 ContentSettingImageViewGtk(ContentSettingsType content_type,
179 const LocationBarViewGtk* parent); 178 const LocationBarViewGtk* parent);
180 virtual ~ContentSettingImageViewGtk(); 179 virtual ~ContentSettingImageViewGtk();
181 180
182 // PageToolViewGtk 181 // PageToolViewGtk
183 virtual void Update(TabContents* tab_contents) OVERRIDE; 182 virtual void Update(WebContents* web_contents) OVERRIDE;
184 183
185 // ui::AnimationDelegate 184 // ui::AnimationDelegate
186 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 185 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
187 186
188 private: 187 private:
189 // PageToolViewGtk 188 // PageToolViewGtk
190 virtual GdkColor button_border_color() const OVERRIDE; 189 virtual GdkColor button_border_color() const OVERRIDE;
191 virtual GdkColor gradient_top_color() const OVERRIDE; 190 virtual GdkColor gradient_top_color() const OVERRIDE;
192 virtual GdkColor gradient_bottom_color() const OVERRIDE; 191 virtual GdkColor gradient_bottom_color() const OVERRIDE;
193 virtual void OnClick(GtkWidget* sender) OVERRIDE; 192 virtual void OnClick(GtkWidget* sender) OVERRIDE;
(...skipping 19 matching lines...) Expand all
213 content_type)), 212 content_type)),
214 content_setting_bubble_(NULL) { 213 content_setting_bubble_(NULL) {
215 animation_.SetSlideDuration(kContentSettingImageAnimationTime); 214 animation_.SetSlideDuration(kContentSettingImageAnimationTime);
216 } 215 }
217 216
218 ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { 217 ContentSettingImageViewGtk::~ContentSettingImageViewGtk() {
219 if (content_setting_bubble_) 218 if (content_setting_bubble_)
220 content_setting_bubble_->Close(); 219 content_setting_bubble_->Close();
221 } 220 }
222 221
223 void ContentSettingImageViewGtk::Update( 222 void ContentSettingImageViewGtk::Update(WebContents* web_contents) {
224 TabContents* tab_contents) { 223 if (web_contents)
225 if (tab_contents) { 224 content_setting_image_model_->UpdateFromWebContents(web_contents);
226 content_setting_image_model_->UpdateFromWebContents( 225
227 tab_contents->web_contents());
228 }
229 if (!content_setting_image_model_->is_visible()) { 226 if (!content_setting_image_model_->is_visible()) {
230 gtk_widget_hide(widget()); 227 gtk_widget_hide(widget());
231 return; 228 return;
232 } 229 }
233 230
234 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), 231 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
235 GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed( 232 GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed(
236 content_setting_image_model_->get_icon()).ToGdkPixbuf()); 233 content_setting_image_model_->get_icon()).ToGdkPixbuf());
237 234
238 gtk_widget_set_tooltip_text(widget(), 235 gtk_widget_set_tooltip_text(widget(),
239 content_setting_image_model_->get_tooltip().c_str()); 236 content_setting_image_model_->get_tooltip().c_str());
240 gtk_widget_show_all(widget()); 237 gtk_widget_show_all(widget());
241 238
242 if (!tab_contents) 239 if (!web_contents)
243 return; 240 return;
244 241
245 TabSpecificContentSettings* content_settings = 242 TabSpecificContentSettings* content_settings =
246 TabSpecificContentSettings::FromWebContents(tab_contents->web_contents()); 243 TabSpecificContentSettings::FromWebContents(web_contents);
247 if (!content_settings || content_settings->IsBlockageIndicated( 244 if (!content_settings || content_settings->IsBlockageIndicated(
248 content_setting_image_model_->get_content_settings_type())) 245 content_setting_image_model_->get_content_settings_type()))
249 return; 246 return;
250 247
251 // The content blockage was not yet indicated to the user. Start indication 248 // The content blockage was not yet indicated to the user. Start indication
252 // animation and clear "not yet shown" flag. 249 // animation and clear "not yet shown" flag.
253 content_settings->SetBlockageHasBeenIndicated( 250 content_settings->SetBlockageHasBeenIndicated(
254 content_setting_image_model_->get_content_settings_type()); 251 content_setting_image_model_->get_content_settings_type());
255 252
256 int label_string_id = 253 int label_string_id =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return kContentSettingTopColor; 286 return kContentSettingTopColor;
290 } 287 }
291 288
292 GdkColor ContentSettingImageViewGtk:: 289 GdkColor ContentSettingImageViewGtk::
293 gradient_bottom_color() const { 290 gradient_bottom_color() const {
294 return kContentSettingBottomColor; 291 return kContentSettingBottomColor;
295 } 292 }
296 293
297 void ContentSettingImageViewGtk::OnClick( 294 void ContentSettingImageViewGtk::OnClick(
298 GtkWidget* sender) { 295 GtkWidget* sender) {
299 TabContents* tab_contents = parent_->GetTabContents(); 296 WebContents* web_contents = parent_->GetWebContents();
300 if (!tab_contents) 297 if (!web_contents)
301 return; 298 return;
302 Profile* profile = parent_->browser()->profile(); 299 Profile* profile = parent_->browser()->profile();
303 content_setting_bubble_ = new ContentSettingBubbleGtk( 300 content_setting_bubble_ = new ContentSettingBubbleGtk(
304 sender, this, 301 sender, this,
305 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 302 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
306 parent_->browser()->content_setting_bubble_model_delegate(), 303 parent_->browser()->content_setting_bubble_model_delegate(),
307 tab_contents->web_contents(), 304 web_contents,
308 profile, 305 profile,
309 content_setting_image_model_->get_content_settings_type()), 306 content_setting_image_model_->get_content_settings_type()),
310 profile, tab_contents->web_contents()); 307 profile, web_contents);
311 return; 308 return;
312 } 309 }
313 310
314 void ContentSettingImageViewGtk::BubbleClosing( 311 void ContentSettingImageViewGtk::BubbleClosing(
315 BubbleGtk* bubble, 312 BubbleGtk* bubble,
316 bool closed_by_escape) { 313 bool closed_by_escape) {
317 content_setting_bubble_ = NULL; 314 content_setting_bubble_ = NULL;
318 } 315 }
319 316
320 class WebIntentsButtonViewGtk : public LocationBarViewGtk::PageToolViewGtk { 317 class WebIntentsButtonViewGtk : public LocationBarViewGtk::PageToolViewGtk {
321 public: 318 public:
322 explicit WebIntentsButtonViewGtk(const LocationBarViewGtk* parent) 319 explicit WebIntentsButtonViewGtk(const LocationBarViewGtk* parent)
323 : LocationBarViewGtk::PageToolViewGtk(parent) { 320 : LocationBarViewGtk::PageToolViewGtk(parent) {
324 animation_.SetSlideDuration(kWebIntentsButtonAnimationTime); 321 animation_.SetSlideDuration(kWebIntentsButtonAnimationTime);
325 } 322 }
326 virtual ~WebIntentsButtonViewGtk() {} 323 virtual ~WebIntentsButtonViewGtk() {}
327 324
328 // PageToolViewGtk 325 // PageToolViewGtk
329 virtual void Update(TabContents* tab_contents) OVERRIDE; 326 virtual void Update(WebContents* web_contents) OVERRIDE;
330 327
331 private: 328 private:
332 // PageToolViewGtk 329 // PageToolViewGtk
333 virtual GdkColor button_border_color() const OVERRIDE; 330 virtual GdkColor button_border_color() const OVERRIDE;
334 virtual GdkColor gradient_top_color() const OVERRIDE; 331 virtual GdkColor gradient_top_color() const OVERRIDE;
335 virtual GdkColor gradient_bottom_color() const OVERRIDE; 332 virtual GdkColor gradient_bottom_color() const OVERRIDE;
336 virtual void OnClick(GtkWidget* sender) OVERRIDE; 333 virtual void OnClick(GtkWidget* sender) OVERRIDE;
337 334
338 DISALLOW_COPY_AND_ASSIGN(WebIntentsButtonViewGtk); 335 DISALLOW_COPY_AND_ASSIGN(WebIntentsButtonViewGtk);
339 }; 336 };
340 337
341 void WebIntentsButtonViewGtk::Update(TabContents* tab_contents) { 338 void WebIntentsButtonViewGtk::Update(WebContents* web_contents) {
342 WebIntentPickerController* web_intent_picker_controller = 339 WebIntentPickerController* web_intent_picker_controller =
343 tab_contents ? WebIntentPickerController::FromWebContents( 340 web_contents ? WebIntentPickerController::FromWebContents(web_contents)
344 tab_contents->web_contents())
345 : NULL; 341 : NULL;
346 if (!web_intent_picker_controller || 342 if (!web_intent_picker_controller ||
347 !web_intent_picker_controller->ShowLocationBarPickerButton()) { 343 !web_intent_picker_controller->ShowLocationBarPickerButton()) {
348 gtk_widget_hide(widget()); 344 gtk_widget_hide(widget());
349 return; 345 return;
350 } 346 }
351 347
352 gtk_widget_set_tooltip_text(widget(), 348 gtk_widget_set_tooltip_text(widget(),
353 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); 349 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str());
354 gtk_widget_show_all(widget()); 350 gtk_widget_show_all(widget());
355 351
356 gtk_label_set_text(GTK_LABEL(label_.get()), 352 gtk_label_set_text(GTK_LABEL(label_.get()),
357 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); 353 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str());
358 354
359 StartAnimating(); 355 StartAnimating();
360 } 356 }
361 357
362 void WebIntentsButtonViewGtk::OnClick(GtkWidget* sender) { 358 void WebIntentsButtonViewGtk::OnClick(GtkWidget* sender) {
363 TabContents* tab_contents = parent_->GetTabContents(); 359 WebContents* web_contents = parent_->GetWebContents();
364 if (!tab_contents) 360 if (!web_contents)
365 return; 361 return;
366 362
367 WebIntentPickerController::FromWebContents(tab_contents->web_contents())-> 363 WebIntentPickerController::FromWebContents(web_contents)->
368 LocationBarPickerButtonClicked(); 364 LocationBarPickerButtonClicked();
369 } 365 }
370 366
371 GdkColor WebIntentsButtonViewGtk::button_border_color() const { 367 GdkColor WebIntentsButtonViewGtk::button_border_color() const {
372 return kGrayBorderColor; 368 return kGrayBorderColor;
373 } 369 }
374 370
375 GdkColor WebIntentsButtonViewGtk::gradient_top_color() const { 371 GdkColor WebIntentsButtonViewGtk::gradient_top_color() const {
376 return kTopColorGray; 372 return kTopColorGray;
377 } 373 }
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 883 }
888 884
889 string16 LocationBarViewGtk::GetTitle() const { 885 string16 LocationBarViewGtk::GetTitle() const {
890 return GetWebContents()->GetTitle(); 886 return GetWebContents()->GetTitle();
891 } 887 }
892 888
893 InstantController* LocationBarViewGtk::GetInstant() { 889 InstantController* LocationBarViewGtk::GetInstant() {
894 return browser_->instant_controller()->instant(); 890 return browser_->instant_controller()->instant();
895 } 891 }
896 892
897 TabContents* LocationBarViewGtk::GetTabContents() const {
898 return chrome::GetActiveTabContents(browser_);
899 }
900
901 void LocationBarViewGtk::ShowFirstRunBubble() { 893 void LocationBarViewGtk::ShowFirstRunBubble() {
902 // We need the browser window to be shown before we can show the bubble, but 894 // We need the browser window to be shown before we can show the bubble, but
903 // we get called before that's happened. 895 // we get called before that's happened.
904 MessageLoop::current()->PostTask( 896 MessageLoop::current()->PostTask(
905 FROM_HERE, 897 FROM_HERE,
906 base::Bind(&LocationBarViewGtk::ShowFirstRunBubbleInternal, 898 base::Bind(&LocationBarViewGtk::ShowFirstRunBubbleInternal,
907 weak_ptr_factory_.GetWeakPtr())); 899 weak_ptr_factory_.GetWeakPtr()));
908 } 900 }
909 901
910 void LocationBarViewGtk::SetInstantSuggestion( 902 void LocationBarViewGtk::SetInstantSuggestion(
(...skipping 27 matching lines...) Expand all
938 location_entry_->SetFocus(); 930 location_entry_->SetFocus();
939 location_entry_->SetForcedQuery(); 931 location_entry_->SetForcedQuery();
940 } 932 }
941 933
942 void LocationBarViewGtk::UpdateContentSettingsIcons() { 934 void LocationBarViewGtk::UpdateContentSettingsIcons() {
943 bool any_visible = false; 935 bool any_visible = false;
944 for (ScopedVector<PageToolViewGtk>::iterator i( 936 for (ScopedVector<PageToolViewGtk>::iterator i(
945 content_setting_views_.begin()); 937 content_setting_views_.begin());
946 i != content_setting_views_.end(); ++i) { 938 i != content_setting_views_.end(); ++i) {
947 (*i)->Update( 939 (*i)->Update(
948 toolbar_model_->GetInputInProgress() ? NULL : GetTabContents()); 940 toolbar_model_->GetInputInProgress() ? NULL : GetWebContents());
949 any_visible = (*i)->IsVisible() || any_visible; 941 any_visible = (*i)->IsVisible() || any_visible;
950 } 942 }
951 943
952 // If there are no visible content things, hide the top level box so it 944 // If there are no visible content things, hide the top level box so it
953 // doesn't mess with padding. 945 // doesn't mess with padding.
954 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); 946 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible);
955 } 947 }
956 948
957 void LocationBarViewGtk::UpdatePageActions() { 949 void LocationBarViewGtk::UpdatePageActions() {
958 std::vector<ExtensionAction*> new_page_actions; 950 std::vector<ExtensionAction*> new_page_actions;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 page_action_views_.clear(); 996 page_action_views_.clear();
1005 if (page_action_views_.size() != count_before) { 997 if (page_action_views_.size() != count_before) {
1006 content::NotificationService::current()->Notify( 998 content::NotificationService::current()->Notify(
1007 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, 999 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
1008 content::Source<LocationBar>(this), 1000 content::Source<LocationBar>(this),
1009 content::NotificationService::NoDetails()); 1001 content::NotificationService::NoDetails());
1010 } 1002 }
1011 } 1003 }
1012 1004
1013 void LocationBarViewGtk::UpdateWebIntentsButton() { 1005 void LocationBarViewGtk::UpdateWebIntentsButton() {
1014 web_intents_button_view_->Update(GetTabContents()); 1006 web_intents_button_view_->Update(GetWebContents());
1015 gtk_widget_set_visible(web_intents_hbox_.get(), 1007 gtk_widget_set_visible(web_intents_hbox_.get(),
1016 web_intents_button_view_->IsVisible()); 1008 web_intents_button_view_->IsVisible());
1017 } 1009 }
1018 1010
1019 void LocationBarViewGtk::UpdateOpenPDFInReaderPrompt() { 1011 void LocationBarViewGtk::UpdateOpenPDFInReaderPrompt() {
1020 // Not implemented on Gtk. 1012 // Not implemented on Gtk.
1021 } 1013 }
1022 1014
1023 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { 1015 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) {
1024 location_entry_->SaveStateToTab(contents); 1016 location_entry_->SaveStateToTab(contents);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 return starred_; 1083 return starred_;
1092 } 1084 }
1093 1085
1094 void LocationBarViewGtk::Observe(int type, 1086 void LocationBarViewGtk::Observe(int type,
1095 const content::NotificationSource& source, 1087 const content::NotificationSource& source,
1096 const content::NotificationDetails& details) { 1088 const content::NotificationDetails& details) {
1097 switch (type) { 1089 switch (type) {
1098 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: { 1090 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: {
1099 // Only update if the updated action box was for the active tab contents. 1091 // Only update if the updated action box was for the active tab contents.
1100 WebContents* target_tab = content::Details<WebContents>(details).ptr(); 1092 WebContents* target_tab = content::Details<WebContents>(details).ptr();
1101 if (target_tab == GetTabContents()->web_contents()) 1093 if (target_tab == GetWebContents())
1102 UpdatePageActions(); 1094 UpdatePageActions();
1103 break; 1095 break;
1104 } 1096 }
1105 1097
1106 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 1098 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
1107 if (theme_service_->UsingNativeTheme()) { 1099 if (theme_service_->UsingNativeTheme()) {
1108 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL); 1100 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL);
1109 1101
1110 GdkColor border_color = theme_service_->GetGdkColor( 1102 GdkColor border_color = theme_service_->GetGdkColor(
1111 ThemeService::COLOR_FRAME); 1103 ThemeService::COLOR_FRAME);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } 1556 }
1565 1557
1566 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) { 1558 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) {
1567 UpdateZoomIcon(); 1559 UpdateZoomIcon();
1568 1560
1569 if (can_show_bubble && gtk_widget_get_visible(zoom_.get())) 1561 if (can_show_bubble && gtk_widget_get_visible(zoom_.get()))
1570 ShowZoomBubble(); 1562 ShowZoomBubble();
1571 } 1563 }
1572 1564
1573 void LocationBarViewGtk::UpdateZoomIcon() { 1565 void LocationBarViewGtk::UpdateZoomIcon() {
1574 TabContents* tab_contents = GetTabContents(); 1566 WebContents* web_contents = GetWebContents();
1575 if (!zoom_.get() || !tab_contents) 1567 if (!zoom_.get() || !web_contents)
1576 return; 1568 return;
1577 1569
1578 ZoomController* zoom_controller = 1570 ZoomController* zoom_controller =
1579 ZoomController::FromWebContents(tab_contents->web_contents()); 1571 ZoomController::FromWebContents(web_contents);
1580 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || 1572 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() ||
1581 toolbar_model_->GetInputInProgress()) { 1573 toolbar_model_->GetInputInProgress()) {
1582 gtk_widget_hide(zoom_.get()); 1574 gtk_widget_hide(zoom_.get());
1583 ZoomBubbleGtk::Close(); 1575 ZoomBubbleGtk::Close();
1584 return; 1576 return;
1585 } 1577 }
1586 1578
1587 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); 1579 const int zoom_resource = zoom_controller->GetResourceForZoomLevel();
1588 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), 1580 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_),
1589 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf()); 1581 theme_service_->GetImageNamed(zoom_resource).ToGdkPixbuf());
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 LocationBarViewGtk* owner, 1816 LocationBarViewGtk* owner,
1825 ExtensionAction* page_action) 1817 ExtensionAction* page_action)
1826 : owner_(NULL), 1818 : owner_(NULL),
1827 page_action_(page_action), 1819 page_action_(page_action),
1828 current_tab_id_(-1), 1820 current_tab_id_(-1),
1829 window_(NULL), 1821 window_(NULL),
1830 accel_group_(NULL), 1822 accel_group_(NULL),
1831 preview_enabled_(false), 1823 preview_enabled_(false),
1832 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_( 1824 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_(
1833 page_action->GetIconAnimation( 1825 page_action->GetIconAnimation(
1834 SessionID::IdForTab(owner->GetTabContents()->web_contents())), 1826 SessionID::IdForTab(owner->GetWebContents())),
1835 this)) { 1827 this)) {
1836 event_box_.Own(gtk_event_box_new()); 1828 event_box_.Own(gtk_event_box_new());
1837 gtk_widget_set_size_request(event_box_.get(), 1829 gtk_widget_set_size_request(event_box_.get(),
1838 Extension::kPageActionIconMaxSize, 1830 Extension::kPageActionIconMaxSize,
1839 Extension::kPageActionIconMaxSize); 1831 Extension::kPageActionIconMaxSize);
1840 1832
1841 // Make the event box not visible so it does not paint a background. 1833 // Make the event box not visible so it does not paint a background.
1842 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); 1834 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
1843 g_signal_connect(event_box_.get(), "button-press-event", 1835 g_signal_connect(event_box_.get(), "button-press-event",
1844 G_CALLBACK(&OnButtonPressedThunk), this); 1836 G_CALLBACK(&OnButtonPressedThunk), this);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 if (visible != old_visible) { 1898 if (visible != old_visible) {
1907 content::NotificationService::current()->Notify( 1899 content::NotificationService::current()->Notify(
1908 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 1900 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
1909 content::Source<ExtensionAction>(page_action_), 1901 content::Source<ExtensionAction>(page_action_),
1910 content::Details<WebContents>(contents)); 1902 content::Details<WebContents>(contents));
1911 } 1903 }
1912 } 1904 }
1913 1905
1914 void LocationBarViewGtk::PageActionViewGtk::OnIconUpdated() { 1906 void LocationBarViewGtk::PageActionViewGtk::OnIconUpdated() {
1915 // If we have no owner, that means this class is still being constructed. 1907 // If we have no owner, that means this class is still being constructed.
1916 TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL; 1908 WebContents* web_contents = owner_ ? owner_->GetWebContents() : NULL;
1917 if (tab_contents) 1909 if (web_contents)
1918 UpdateVisibility(tab_contents->web_contents(), current_url_); 1910 UpdateVisibility(web_contents, current_url_);
1919 } 1911 }
1920 1912
1921 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { 1913 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() {
1922 GdkEventButton event = {}; 1914 GdkEventButton event = {};
1923 event.type = GDK_BUTTON_PRESS; 1915 event.type = GDK_BUTTON_PRESS;
1924 event.button = 1; 1916 event.button = 1;
1925 OnButtonPressed(widget(), &event); 1917 OnButtonPressed(widget(), &event);
1926 } 1918 }
1927 1919
1928 void LocationBarViewGtk::PageActionViewGtk::Observe( 1920 void LocationBarViewGtk::PageActionViewGtk::Observe(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 2023
2032 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( 2024 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed(
2033 GtkWidget* sender, 2025 GtkWidget* sender,
2034 GdkEventButton* event) { 2026 GdkEventButton* event) {
2035 // Double and triple-clicks generate both a GDK_BUTTON_PRESS and a 2027 // Double and triple-clicks generate both a GDK_BUTTON_PRESS and a
2036 // GDK_[23]BUTTON_PRESS event. We don't want to double-trigger by acting on 2028 // GDK_[23]BUTTON_PRESS event. We don't want to double-trigger by acting on
2037 // both. 2029 // both.
2038 if (event->type != GDK_BUTTON_PRESS) 2030 if (event->type != GDK_BUTTON_PRESS)
2039 return TRUE; 2031 return TRUE;
2040 2032
2041 TabContents* tab_contents = owner_->GetTabContents(); 2033 WebContents* web_contents = owner_->GetWebContents();
2042 if (!tab_contents) 2034 if (!web_contents)
2043 return TRUE; 2035 return TRUE;
2044 2036
2045 ExtensionService* extension_service = 2037 ExtensionService* extension_service =
2046 owner_->browser()->profile()->GetExtensionService(); 2038 owner_->browser()->profile()->GetExtensionService();
2047 if (!extension_service) 2039 if (!extension_service)
2048 return TRUE; 2040 return TRUE;
2049 2041
2050 const Extension* extension = 2042 const Extension* extension =
2051 extension_service->extensions()->GetByID(page_action()->extension_id()); 2043 extension_service->extensions()->GetByID(page_action()->extension_id());
2052 if (!extension) 2044 if (!extension)
2053 return TRUE; 2045 return TRUE;
2054 2046
2055 LocationBarController* controller = 2047 LocationBarController* controller =
2056 extensions::TabHelper::FromWebContents(tab_contents->web_contents())-> 2048 extensions::TabHelper::FromWebContents(web_contents)->
2057 location_bar_controller(); 2049 location_bar_controller();
2058 2050
2059 switch (controller->OnClicked(extension->id(), event->button)) { 2051 switch (controller->OnClicked(extension->id(), event->button)) {
2060 case LocationBarController::ACTION_NONE: 2052 case LocationBarController::ACTION_NONE:
2061 break; 2053 break;
2062 2054
2063 case LocationBarController::ACTION_SHOW_POPUP: 2055 case LocationBarController::ACTION_SHOW_POPUP:
2064 ExtensionPopupGtk::Show( 2056 ExtensionPopupGtk::Show(
2065 page_action_->GetPopupUrl(current_tab_id_), 2057 page_action_->GetPopupUrl(current_tab_id_),
2066 owner_->browser_, 2058 owner_->browser_,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 } 2125 }
2134 2126
2135 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2127 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2136 ExtensionAction* action) { 2128 ExtensionAction* action) {
2137 ExtensionPopupGtk::Show( 2129 ExtensionPopupGtk::Show(
2138 action->GetPopupUrl(current_tab_id_), 2130 action->GetPopupUrl(current_tab_id_),
2139 owner_->browser_, 2131 owner_->browser_,
2140 event_box_.get(), 2132 event_box_.get(),
2141 ExtensionPopupGtk::SHOW_AND_INSPECT); 2133 ExtensionPopupGtk::SHOW_AND_INSPECT);
2142 } 2134 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/omnibox/omnibox_edit_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698