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

Unified Diff: chrome/browser/gtk/browser_actions_toolbar_gtk.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/gtk/browser_actions_toolbar_gtk.h ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/browser_actions_toolbar_gtk.cc
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index ef115be0f28d1dbc9473fac41e010f814b1bde43..c1921cd5f19a6ded5ba3381025ac0b131688aa64 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -332,6 +332,12 @@ void BrowserActionsToolbarGtk::CreateAllButtons() {
void BrowserActionsToolbarGtk::CreateButtonForExtension(Extension* extension,
int index) {
+ if (!ShouldDisplayBrowserAction(extension))
+ return;
+
+ if (profile_->IsOffTheRecord())
+ index = model_->OriginalIndexToIncognito(index);
+
RemoveButtonForExtension(extension);
linked_ptr<BrowserActionButton> button(
new BrowserActionButton(this, extension));
@@ -374,6 +380,14 @@ void BrowserActionsToolbarGtk::UpdateVisibility() {
gtk_widget_show(widget());
}
+bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction(
+ Extension* extension) {
+ // Only display incognito-enabled extensions while in incognito mode.
+ return (!profile_->IsOffTheRecord() ||
+ profile_->GetExtensionsService()->
+ IsIncognitoEnabled(extension->id()));
+}
+
void BrowserActionsToolbarGtk::HidePopup() {
ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup();
if (popup)
@@ -402,10 +416,14 @@ void BrowserActionsToolbarGtk::BrowserActionMoved(Extension* extension,
BrowserActionButton* button = extension_button_map_[extension->id()].get();
if (!button) {
- NOTREACHED();
+ if (ShouldDisplayBrowserAction(extension))
+ NOTREACHED();
return;
}
+ if (profile_->IsOffTheRecord())
+ index = model_->OriginalIndexToIncognito(index);
+
gtk_box_reorder_child(GTK_BOX(hbox_.get()), button->widget(), index);
}
@@ -428,6 +446,9 @@ gboolean BrowserActionsToolbarGtk::OnDragMotion(GtkWidget* widget,
return FALSE;
drop_index_ = x < kButtonSize ? 0 : x / (kButtonSize + kButtonPadding);
+ if (profile_->IsOffTheRecord())
+ drop_index_ = model_->IncognitoIndexToOriginal(drop_index_);
+
// We will go ahead and reorder the child in order to provide visual feedback
// to the user. We don't inform the model that it has moved until the drag
// ends.
« no previous file with comments | « chrome/browser/gtk/browser_actions_toolbar_gtk.h ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698