#include <cmath>
#include <string>
-#include "base/prefs/pref_service.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#import "chrome/browser/ui/cocoa/menu_button.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
-#include "chrome/common/pref_names.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/browser/pref_names.h"
+#include "extensions/browser/extension_registry.h"
#include "grit/theme_resources.h"
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h"
ExtensionServiceObserverBridge(BrowserActionsController* owner,
Browser* browser)
: owner_(owner), browser_(browser) {
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
- content::Source<Profile>(browser->profile()));
registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC,
+ extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
content::Source<Profile>(browser->profile()));
+ registrar_.Add(
+ this,
+ extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC,
+ content::Source<Profile>(browser->profile()));
}
// Overridden from content::NotificationObserver.
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
switch (type) {
- case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
+ case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
ExtensionPopupController* popup = [ExtensionPopupController popup];
if (popup && ![popup isClosing])
[popup close];
break;
}
- case chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC: {
+ case extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC: {
std::pair<const std::string, gfx::NativeWindow>* payload =
content::Details<std::pair<const std::string, gfx::NativeWindow> >(
details).ptr();
- (CGFloat)savedWidth {
if (!toolbarModel_)
return 0;
- if (!profile_->GetPrefs()->HasPrefPath(
- extensions::pref_names::kToolbarSize)) {
- // Migration code to the new VisibleIconCount pref.
- // TODO(mpcomplete): remove this at some point.
- double predefinedWidth = profile_->GetPrefs()->GetDouble(
- extensions::pref_names::kBrowserActionContainerWidth);
- if (predefinedWidth != 0) {
- int iconWidth = kBrowserActionWidth + kBrowserActionButtonPadding;
- int extraWidth = kChevronWidth;
- toolbarModel_->SetVisibleIconCount(
- (predefinedWidth - extraWidth) / iconWidth);
- }
- }
int savedButtonCount = toolbarModel_->GetVisibleIconCount();
if (savedButtonCount < 0 || // all icons are visible
}
- (void)activateBrowserAction:(const std::string&)extension_id {
- ExtensionService* service = browser_->profile()->GetExtensionService();
- if (!service)
- return;
-
- const Extension* extension = service->GetExtensionById(extension_id, false);
+ const Extension* extension = extensions::ExtensionRegistry::Get(
+ browser_->profile())->enabled_extensions().GetByID(extension_id);
if (!extension)
return;
GURL popupUrl;
switch (toolbarModel_->ExecuteBrowserAction(extension, browser_, &popupUrl,
shouldGrant)) {
- case extensions::ExtensionToolbarModel::ACTION_NONE:
+ case ExtensionAction::ACTION_NONE:
break;
- case extensions::ExtensionToolbarModel::ACTION_SHOW_POPUP: {
+ case ExtensionAction::ACTION_SHOW_POPUP: {
NSPoint arrowPoint = [self popupPointForBrowserAction:extension];
[ExtensionPopupController showURL:popupUrl
inBrowser:browser_