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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), 324 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(),
325 FALSE, FALSE, 0); 325 FALSE, FALSE, 0);
326 326
327 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s 327 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s
328 // size-allocate so we can do proper resizing and eliding on 328 // size-allocate so we can do proper resizing and eliding on
329 // |security_info_label_|. 329 // |security_info_label_|.
330 g_signal_connect(hbox_.get(), "size-allocate", 330 g_signal_connect(hbox_.get(), "size-allocate",
331 G_CALLBACK(&OnHboxSizeAllocateThunk), this); 331 G_CALLBACK(&OnHboxSizeAllocateThunk), this);
332 332
333 registrar_.Add(this, 333 registrar_.Add(this,
334 NotificationType::BROWSER_THEME_CHANGED, 334 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
335 NotificationService::AllSources()); 335 NotificationService::AllSources());
336 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, 336 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
337 profile_->GetPrefs(), this); 337 profile_->GetPrefs(), this);
338 338
339 theme_service_->InitThemesFor(this); 339 theme_service_->InitThemesFor(this);
340 } 340 }
341 341
342 void LocationBarViewGtk::BuildSiteTypeArea() { 342 void LocationBarViewGtk::BuildSiteTypeArea() {
343 location_icon_image_ = gtk_image_new(); 343 location_icon_image_ = gtk_image_new();
344 gtk_widget_set_name(location_icon_image_, "chrome-location-icon"); 344 gtk_widget_set_name(location_icon_image_, "chrome-location-icon");
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 void LocationBarViewGtk::OnKillFocus() { 552 void LocationBarViewGtk::OnKillFocus() {
553 } 553 }
554 554
555 void LocationBarViewGtk::OnSetFocus() { 555 void LocationBarViewGtk::OnSetFocus() {
556 AccessibilityTextBoxInfo info( 556 AccessibilityTextBoxInfo info(
557 profile_, 557 profile_,
558 l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION).c_str(), 558 l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION).c_str(),
559 false); 559 false);
560 NotificationService::current()->Notify( 560 NotificationService::current()->Notify(
561 NotificationType::ACCESSIBILITY_CONTROL_FOCUSED, 561 chrome::ACCESSIBILITY_CONTROL_FOCUSED,
562 Source<Profile>(profile_), 562 Source<Profile>(profile_),
563 Details<AccessibilityTextBoxInfo>(&info)); 563 Details<AccessibilityTextBoxInfo>(&info));
564 564
565 // Update the keyword and search hint states. 565 // Update the keyword and search hint states.
566 OnChanged(); 566 OnChanged();
567 } 567 }
568 568
569 SkBitmap LocationBarViewGtk::GetFavicon() const { 569 SkBitmap LocationBarViewGtk::GetFavicon() const {
570 return GetTabContentsWrapper()->favicon_tab_helper()->GetFavicon(); 570 return GetTabContentsWrapper()->favicon_tab_helper()->GetFavicon();
571 } 571 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (page_actions.size() != page_action_views_.size()) { 655 if (page_actions.size() != page_action_views_.size()) {
656 page_action_views_.reset(); // Delete the old views (if any). 656 page_action_views_.reset(); // Delete the old views (if any).
657 657
658 for (size_t i = 0; i < page_actions.size(); ++i) { 658 for (size_t i = 0; i < page_actions.size(); ++i) {
659 page_action_views_.push_back( 659 page_action_views_.push_back(
660 new PageActionViewGtk(this, profile_, page_actions[i])); 660 new PageActionViewGtk(this, profile_, page_actions[i]));
661 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), 661 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()),
662 page_action_views_[i]->widget(), FALSE, FALSE, 0); 662 page_action_views_[i]->widget(), FALSE, FALSE, 0);
663 } 663 }
664 NotificationService::current()->Notify( 664 NotificationService::current()->Notify(
665 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, 665 chrome::EXTENSION_PAGE_ACTION_COUNT_CHANGED,
666 Source<LocationBar>(this), 666 Source<LocationBar>(this),
667 NotificationService::NoDetails()); 667 NotificationService::NoDetails());
668 } 668 }
669 669
670 TabContents* contents = GetTabContents(); 670 TabContents* contents = GetTabContents();
671 if (!page_action_views_.empty() && contents) { 671 if (!page_action_views_.empty() && contents) {
672 GURL url = GURL(WideToUTF8(toolbar_model_->GetText())); 672 GURL url = GURL(WideToUTF8(toolbar_model_->GetText()));
673 673
674 for (size_t i = 0; i < page_action_views_.size(); i++) { 674 for (size_t i = 0; i < page_action_views_.size(); i++) {
675 page_action_views_[i]->UpdateVisibility( 675 page_action_views_[i]->UpdateVisibility(
676 toolbar_model_->input_in_progress() ? NULL : contents, url); 676 toolbar_model_->input_in_progress() ? NULL : contents, url);
677 } 677 }
678 } 678 }
679 679
680 // If there are no visible page actions, hide the hbox too, so that it does 680 // If there are no visible page actions, hide the hbox too, so that it does
681 // not affect the padding in the location bar. 681 // not affect the padding in the location bar.
682 gtk_widget_set_visible(page_action_hbox_.get(), 682 gtk_widget_set_visible(page_action_hbox_.get(),
683 PageActionVisibleCount() && !ShouldOnlyShowLocation()); 683 PageActionVisibleCount() && !ShouldOnlyShowLocation());
684 } 684 }
685 685
686 void LocationBarViewGtk::InvalidatePageActions() { 686 void LocationBarViewGtk::InvalidatePageActions() {
687 size_t count_before = page_action_views_.size(); 687 size_t count_before = page_action_views_.size();
688 page_action_views_.reset(); 688 page_action_views_.reset();
689 if (page_action_views_.size() != count_before) { 689 if (page_action_views_.size() != count_before) {
690 NotificationService::current()->Notify( 690 NotificationService::current()->Notify(
691 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, 691 chrome::EXTENSION_PAGE_ACTION_COUNT_CHANGED,
692 Source<LocationBar>(this), 692 Source<LocationBar>(this),
693 NotificationService::NoDetails()); 693 NotificationService::NoDetails());
694 } 694 }
695 } 695 }
696 696
697 void LocationBarViewGtk::SaveStateToContents(TabContents* contents) { 697 void LocationBarViewGtk::SaveStateToContents(TabContents* contents) {
698 location_entry_->SaveStateToTab(contents); 698 location_entry_->SaveStateToTab(contents);
699 } 699 }
700 700
701 void LocationBarViewGtk::Revert() { 701 void LocationBarViewGtk::Revert() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 749
750 void LocationBarViewGtk::TestPageActionPressed(size_t index) { 750 void LocationBarViewGtk::TestPageActionPressed(size_t index) {
751 if (index >= page_action_views_.size()) { 751 if (index >= page_action_views_.size()) {
752 NOTREACHED(); 752 NOTREACHED();
753 return; 753 return;
754 } 754 }
755 755
756 page_action_views_[index]->TestActivatePageAction(); 756 page_action_views_[index]->TestActivatePageAction();
757 } 757 }
758 758
759 void LocationBarViewGtk::Observe(NotificationType type, 759 void LocationBarViewGtk::Observe(int type,
760 const NotificationSource& source, 760 const NotificationSource& source,
761 const NotificationDetails& details) { 761 const NotificationDetails& details) {
762 if (type.value == NotificationType::PREF_CHANGED) { 762 if (type == chrome::PREF_CHANGED) {
763 UpdateStarIcon(); 763 UpdateStarIcon();
764 return; 764 return;
765 } 765 }
766 766
767 DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); 767 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
768 768
769 if (theme_service_->UsingNativeTheme()) { 769 if (theme_service_->UsingNativeTheme()) {
770 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL); 770 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, NULL);
771 771
772 GdkColor border_color = theme_service_->GetGdkColor( 772 GdkColor border_color = theme_service_->GetGdkColor(
773 ThemeService::COLOR_FRAME); 773 ThemeService::COLOR_FRAME);
774 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color); 774 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color);
775 775
776 gtk_util::UndoForceFontSize(security_info_label_); 776 gtk_util::UndoForceFontSize(security_info_label_);
777 gtk_util::UndoForceFontSize(tab_to_search_full_label_); 777 gtk_util::UndoForceFontSize(tab_to_search_full_label_);
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 } 1516 }
1517 1517
1518 bool old_visible = IsVisible(); 1518 bool old_visible = IsVisible();
1519 if (visible) 1519 if (visible)
1520 gtk_widget_show_all(event_box_.get()); 1520 gtk_widget_show_all(event_box_.get());
1521 else 1521 else
1522 gtk_widget_hide_all(event_box_.get()); 1522 gtk_widget_hide_all(event_box_.get());
1523 1523
1524 if (visible != old_visible) { 1524 if (visible != old_visible) {
1525 NotificationService::current()->Notify( 1525 NotificationService::current()->Notify(
1526 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 1526 chrome::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
1527 Source<ExtensionAction>(page_action_), 1527 Source<ExtensionAction>(page_action_),
1528 Details<TabContents>(contents)); 1528 Details<TabContents>(contents));
1529 } 1529 }
1530 } 1530 }
1531 1531
1532 void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded( 1532 void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded(
1533 SkBitmap* image, const ExtensionResource& resource, int index) { 1533 SkBitmap* image, const ExtensionResource& resource, int index) {
1534 // We loaded icons()->size() icons, plus one extra if the page action had 1534 // We loaded icons()->size() icons, plus one extra if the page action had
1535 // a default icon. 1535 // a default icon.
1536 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); 1536 int total_icons = static_cast<int>(page_action_->icon_paths()->size());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1620
1621 std::string badge_text = page_action_->GetBadgeText(tab_id); 1621 std::string badge_text = page_action_->GetBadgeText(tab_id);
1622 if (badge_text.empty()) 1622 if (badge_text.empty())
1623 return FALSE; 1623 return FALSE;
1624 1624
1625 gfx::CanvasSkiaPaint canvas(event, false); 1625 gfx::CanvasSkiaPaint canvas(event, false);
1626 gfx::Rect bounding_rect(widget->allocation); 1626 gfx::Rect bounding_rect(widget->allocation);
1627 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); 1627 page_action_->PaintBadge(&canvas, bounding_rect, tab_id);
1628 return FALSE; 1628 return FALSE;
1629 } 1629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698