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

Unified Diff: chrome/browser/views/browser_actions_container.cc

Issue 567037: Initial work on making extensions work in incognito mode. (Closed)
Patch Set: added experimental requirement Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/browser_actions_container.cc
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index 6786ed6f738c12bf645f16c8229925ff5cce16dd..d5dd123326a7fb4b5e7fb7aea887620adc1bce5e 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -443,6 +443,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);
@@ -666,6 +669,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;
}
@@ -766,6 +770,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.
@@ -928,6 +935,12 @@ void BrowserActionsContainer::BrowserActionAdded(Extension* extension,
CloseOverflowMenu();
+ 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();
@@ -1006,6 +1019,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();
@@ -1099,3 +1118,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()));
+}
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698