summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/browser_actions_container.cc26
-rw-r--r--chrome/browser/views/browser_actions_container.h9
2 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index d089a40..5a1ae90 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -450,6 +450,9 @@ void BrowserActionsContainer::CreateBrowserActionViews() {
DCHECK(browser_action_views_.empty());
for (ExtensionList::iterator iter = model_->begin();
iter != model_->end(); ++iter) {
+ if (!ShouldDisplayBrowserAction(*iter))
+ continue;
+
BrowserActionView* view = new BrowserActionView(*iter, this);
browser_action_views_.push_back(view);
AddChildView(view);
@@ -673,6 +676,7 @@ void BrowserActionsContainer::ViewHierarchyChanged(bool is_add,
bool BrowserActionsContainer::GetDropFormats(
int* formats, std::set<OSExchangeData::CustomFormat>* custom_formats) {
custom_formats->insert(BrowserActionDragData::GetBrowserActionCustomFormat());
+
return true;
}
@@ -771,6 +775,9 @@ int BrowserActionsContainer::OnPerformDrop(
if (i > data.index())
--i;
+ if (profile_->IsOffTheRecord())
+ i = model_->IncognitoIndexToOriginal(i);
+
model_->MoveBrowserAction(dragging, i);
OnDragExited(); // Perform clean up after dragging.
@@ -933,6 +940,12 @@ void BrowserActionsContainer::BrowserActionAdded(Extension* extension,
CloseMenus();
+ if (!ShouldDisplayBrowserAction(extension))
+ return;
+
+ if (profile_->IsOffTheRecord())
+ index = model_->OriginalIndexToIncognito(index);
+
// Before we change anything, determine the number of visible browser actions.
size_t visible_actions = VisibleBrowserActions();
@@ -1011,6 +1024,12 @@ void BrowserActionsContainer::BrowserActionRemoved(Extension* extension) {
void BrowserActionsContainer::BrowserActionMoved(Extension* extension,
int index) {
+ if (!ShouldDisplayBrowserAction(extension))
+ return;
+
+ if (profile_->IsOffTheRecord())
+ index = model_->OriginalIndexToIncognito(index);
+
DCHECK(index >= 0 && index < static_cast<int>(browser_action_views_.size()));
DeleteBrowserActionViews();
@@ -1104,3 +1123,10 @@ void BrowserActionsContainer::NotifyMenuDeleted(
DCHECK(controller == overflow_menu_);
overflow_menu_ = NULL;
}
+
+bool BrowserActionsContainer::ShouldDisplayBrowserAction(Extension* extension) {
+ // Only display incognito-enabled extensions while in incognito mode.
+ return (!profile_->IsOffTheRecord() ||
+ profile_->GetExtensionsService()->
+ IsIncognitoEnabled(extension->id()));
+}
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
index a7a5b59ac..1ace12d 100644
--- a/chrome/browser/views/browser_actions_container.h
+++ b/chrome/browser/views/browser_actions_container.h
@@ -399,7 +399,14 @@ class BrowserActionsContainer
// all the padding that we normally show if there are icons.
int ContainerMinSize() const;
- // The vector of browser actions (icons/image buttons for each action).
+ // Returns true if this extension should be shown in this toolbar. This can
+ // return false if we are in an incognito window and the extension is disabled
+ // for incognito.
+ bool ShouldDisplayBrowserAction(Extension* extension);
+
+ // The vector of browser actions (icons/image buttons for each action). Note
+ // that not every BrowserAction in the ToolbarModel will necessarily be in
+ // this collection. Some extensions may be disabled in incognito windows.
BrowserActionViews browser_action_views_;
NotificationRegistrar registrar_;