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 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/instant/instant_controller.h" | 35 #include "chrome/browser/instant/instant_controller.h" |
36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/search_engines/template_url.h" | 37 #include "chrome/browser/search_engines/template_url.h" |
38 #include "chrome/browser/search_engines/template_url_service.h" | 38 #include "chrome/browser/search_engines/template_url_service.h" |
39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 39 #include "chrome/browser/search_engines/template_url_service_factory.h" |
40 #include "chrome/browser/ui/browser.h" | 40 #include "chrome/browser/ui/browser.h" |
41 #include "chrome/browser/ui/browser_command_controller.h" | 41 #include "chrome/browser/ui/browser_command_controller.h" |
42 #include "chrome/browser/ui/browser_commands.h" | 42 #include "chrome/browser/ui/browser_commands.h" |
43 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" | 43 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
44 #include "chrome/browser/ui/browser_list.h" | 44 #include "chrome/browser/ui/browser_list.h" |
| 45 #include "chrome/browser/ui/browser_tabstrip.h" |
45 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 46 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
46 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 47 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
47 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" | 48 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" |
48 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 49 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
49 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 50 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
50 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h" | 51 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h" |
51 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" | 52 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" |
52 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 53 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
53 #include "chrome/browser/ui/gtk/first_run_bubble.h" | 54 #include "chrome/browser/ui/gtk/first_run_bubble.h" |
54 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 55 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 455 |
455 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, | 456 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, |
456 NULL, 0, GDK_ACTION_COPY); | 457 NULL, 0, GDK_ACTION_COPY); |
457 ui::SetSourceTargetListFromCodeMask(site_type_event_box_, | 458 ui::SetSourceTargetListFromCodeMask(site_type_event_box_, |
458 ui::TEXT_PLAIN | | 459 ui::TEXT_PLAIN | |
459 ui::TEXT_URI_LIST | | 460 ui::TEXT_URI_LIST | |
460 ui::CHROME_NAMED_URL); | 461 ui::CHROME_NAMED_URL); |
461 } | 462 } |
462 | 463 |
463 WebContents* LocationBarViewGtk::GetWebContents() const { | 464 WebContents* LocationBarViewGtk::GetWebContents() const { |
464 return browser_->GetActiveWebContents(); | 465 return chrome::GetActiveWebContents(browser_); |
465 } | 466 } |
466 | 467 |
467 void LocationBarViewGtk::SetPreviewEnabledPageAction( | 468 void LocationBarViewGtk::SetPreviewEnabledPageAction( |
468 ExtensionAction *page_action, | 469 ExtensionAction *page_action, |
469 bool preview_enabled) { | 470 bool preview_enabled) { |
470 DCHECK(page_action); | 471 DCHECK(page_action); |
471 for (ScopedVector<PageActionViewGtk>::iterator iter = | 472 for (ScopedVector<PageActionViewGtk>::iterator iter = |
472 page_action_views_.begin(); iter != page_action_views_.end(); | 473 page_action_views_.begin(); iter != page_action_views_.end(); |
473 ++iter) { | 474 ++iter) { |
474 if ((*iter)->page_action() == page_action) { | 475 if ((*iter)->page_action() == page_action) { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 | 661 |
661 string16 LocationBarViewGtk::GetTitle() const { | 662 string16 LocationBarViewGtk::GetTitle() const { |
662 return GetWebContents()->GetTitle(); | 663 return GetWebContents()->GetTitle(); |
663 } | 664 } |
664 | 665 |
665 InstantController* LocationBarViewGtk::GetInstant() { | 666 InstantController* LocationBarViewGtk::GetInstant() { |
666 return browser_->instant(); | 667 return browser_->instant(); |
667 } | 668 } |
668 | 669 |
669 TabContents* LocationBarViewGtk::GetTabContents() const { | 670 TabContents* LocationBarViewGtk::GetTabContents() const { |
670 return browser_->GetActiveTabContents(); | 671 return chrome::GetActiveTabContents(browser_); |
671 } | 672 } |
672 | 673 |
673 void LocationBarViewGtk::ShowFirstRunBubble() { | 674 void LocationBarViewGtk::ShowFirstRunBubble() { |
674 // We need the browser window to be shown before we can show the bubble, but | 675 // We need the browser window to be shown before we can show the bubble, but |
675 // we get called before that's happened. | 676 // we get called before that's happened. |
676 MessageLoop::current()->PostTask( | 677 MessageLoop::current()->PostTask( |
677 FROM_HERE, | 678 FROM_HERE, |
678 base::Bind(&LocationBarViewGtk::ShowFirstRunBubbleInternal, | 679 base::Bind(&LocationBarViewGtk::ShowFirstRunBubbleInternal, |
679 weak_ptr_factory_.GetWeakPtr())); | 680 weak_ptr_factory_.GetWeakPtr())); |
680 } | 681 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 751 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
751 } | 752 } |
752 content::NotificationService::current()->Notify( | 753 content::NotificationService::current()->Notify( |
753 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 754 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
754 content::Source<LocationBar>(this), | 755 content::Source<LocationBar>(this), |
755 content::NotificationService::NoDetails()); | 756 content::NotificationService::NoDetails()); |
756 } | 757 } |
757 | 758 |
758 WebContents* contents = GetWebContents(); | 759 WebContents* contents = GetWebContents(); |
759 if (!page_action_views_.empty() && contents) { | 760 if (!page_action_views_.empty() && contents) { |
760 GURL url = browser()->GetActiveWebContents()->GetURL(); | 761 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); |
761 | 762 |
762 for (size_t i = 0; i < page_action_views_.size(); i++) { | 763 for (size_t i = 0; i < page_action_views_.size(); i++) { |
763 page_action_views_[i]->UpdateVisibility( | 764 page_action_views_[i]->UpdateVisibility( |
764 toolbar_model_->input_in_progress() ? NULL : contents, url); | 765 toolbar_model_->input_in_progress() ? NULL : contents, url); |
765 } | 766 } |
766 } | 767 } |
767 | 768 |
768 // If there are no visible page actions, hide the hbox too, so that it does | 769 // If there are no visible page actions, hide the hbox too, so that it does |
769 // not affect the padding in the location bar. | 770 // not affect the padding in the location bar. |
770 gtk_widget_set_visible(page_action_hbox_.get(), | 771 gtk_widget_set_visible(page_action_hbox_.get(), |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 } | 1974 } |
1974 | 1975 |
1975 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 1976 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
1976 ExtensionAction* action) { | 1977 ExtensionAction* action) { |
1977 ExtensionPopupGtk::Show( | 1978 ExtensionPopupGtk::Show( |
1978 action->GetPopupUrl(current_tab_id_), | 1979 action->GetPopupUrl(current_tab_id_), |
1979 owner_->browser_, | 1980 owner_->browser_, |
1980 event_box_.get(), | 1981 event_box_.get(), |
1981 ExtensionPopupGtk::SHOW_AND_INSPECT); | 1982 ExtensionPopupGtk::SHOW_AND_INSPECT); |
1982 } | 1983 } |
OLD | NEW |