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

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

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
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/browser_actions_toolbar_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/extensions/api/commands/command_service.h" 16 #include "chrome/browser/extensions/api/commands/command_service.h"
17 #include "chrome/browser/extensions/api/commands/command_service_factory.h" 17 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
18 #include "chrome/browser/extensions/extension_action.h" 18 #include "chrome/browser/extensions/extension_action.h"
19 #include "chrome/browser/extensions/extension_action_icon_factory.h" 19 #include "chrome/browser/extensions/extension_action_icon_factory.h"
20 #include "chrome/browser/extensions/extension_action_manager.h" 20 #include "chrome/browser/extensions/extension_action_manager.h"
21 #include "chrome/browser/extensions/extension_context_menu_model.h" 21 #include "chrome/browser/extensions/extension_context_menu_model.h"
22 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/extensions/extension_system.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sessions/session_tab_helper.h" 25 #include "chrome/browser/sessions/session_tab_helper.h"
25 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_tabstrip.h" 27 #include "chrome/browser/ui/browser_tabstrip.h"
27 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 28 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
28 #include "chrome/browser/ui/gtk/custom_button.h" 29 #include "chrome/browser/ui/gtk/custom_button.h"
29 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" 30 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
30 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 31 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
31 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" 32 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h"
32 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 33 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 theme_service_(GtkThemeService::GetFrom(browser->profile())), 496 theme_service_(GtkThemeService::GetFrom(browser->profile())),
496 model_(NULL), 497 model_(NULL),
497 hbox_(gtk_hbox_new(FALSE, 0)), 498 hbox_(gtk_hbox_new(FALSE, 0)),
498 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), 499 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)),
499 drag_button_(NULL), 500 drag_button_(NULL),
500 drop_index_(-1), 501 drop_index_(-1),
501 resize_animation_(this), 502 resize_animation_(this),
502 desired_width_(0), 503 desired_width_(0),
503 start_width_(0), 504 start_width_(0),
504 weak_factory_(this) { 505 weak_factory_(this) {
505 ExtensionService* extension_service = profile_->GetExtensionService(); 506 ExtensionService* extension_service =
506 // The |extension_service| can be NULL in Incognito. 507 extensions::ExtensionSystem::Get(profile_)->extension_service();
507 if (!extension_service) 508 if (!extension_service)
508 return; 509 return;
509 510
510 overflow_button_.reset(new CustomDrawButton( 511 overflow_button_.reset(new CustomDrawButton(
511 theme_service_, 512 theme_service_,
512 IDR_BROWSER_ACTIONS_OVERFLOW, 513 IDR_BROWSER_ACTIONS_OVERFLOW,
513 IDR_BROWSER_ACTIONS_OVERFLOW_P, 514 IDR_BROWSER_ACTIONS_OVERFLOW_P,
514 IDR_BROWSER_ACTIONS_OVERFLOW_H, 515 IDR_BROWSER_ACTIONS_OVERFLOW_H,
515 0, 516 0,
516 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); 517 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE)));
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 692 }
692 693
693 void BrowserActionsToolbarGtk::UpdateVisibility() { 694 void BrowserActionsToolbarGtk::UpdateVisibility() {
694 gtk_widget_set_visible(widget(), button_count() != 0); 695 gtk_widget_set_visible(widget(), button_count() != 0);
695 } 696 }
696 697
697 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( 698 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction(
698 const Extension* extension) { 699 const Extension* extension) {
699 // Only display incognito-enabled extensions while in incognito mode. 700 // Only display incognito-enabled extensions while in incognito mode.
700 return (!profile_->IsOffTheRecord() || 701 return (!profile_->IsOffTheRecord() ||
701 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); 702 extensions::ExtensionSystem::Get(profile_)->extension_service()->
703 IsIncognitoEnabled(extension->id()));
702 } 704 }
703 705
704 void BrowserActionsToolbarGtk::HidePopup() { 706 void BrowserActionsToolbarGtk::HidePopup() {
705 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup(); 707 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup();
706 if (popup) 708 if (popup)
707 popup->DestroyPopup(); 709 popup->DestroyPopup();
708 } 710 }
709 711
710 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { 712 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) {
711 desired_width_ = WidthForIconCount(count); 713 desired_width_ = WidthForIconCount(count);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1094
1093 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 1095 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
1094 event->time); 1096 event->time);
1095 return TRUE; 1097 return TRUE;
1096 } 1098 }
1097 1099
1098 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 1100 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
1099 if (!resize_animation_.is_animating()) 1101 if (!resize_animation_.is_animating())
1100 UpdateChevronVisibility(); 1102 UpdateChevronVisibility();
1101 } 1103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698