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

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

Issue 10690042: GTK: Changes to Extension Commands now take effect immediately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 G_CALLBACK(OnRealize), this); 157 G_CALLBACK(OnRealize), this);
158 } 158 }
159 159
160 registrar_.Add( 160 registrar_.Add(
161 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 161 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
162 content::Source<ExtensionAction>(extension->browser_action())); 162 content::Source<ExtensionAction>(extension->browser_action()));
163 registrar_.Add( 163 registrar_.Add(
164 this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 164 this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
165 content::Source<Profile>( 165 content::Source<Profile>(
166 toolbar->browser()->profile()->GetOriginalProfile())); 166 toolbar->browser()->profile()->GetOriginalProfile()));
167 registrar_.Add(
168 this, chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED,
169 content::Source<Profile>(
170 toolbar->browser()->profile()->GetOriginalProfile()));
171 registrar_.Add(
172 this, chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED,
173 content::Source<Profile>(
174 toolbar->browser()->profile()->GetOriginalProfile()));
167 } 175 }
168 176
169 ~BrowserActionButton() { 177 ~BrowserActionButton() {
170 DisconnectBrowserActionPopupAccelerator(); 178 DisconnectBrowserActionPopupAccelerator();
171 179
172 if (tab_specific_icon_) 180 if (tab_specific_icon_)
173 g_object_unref(tab_specific_icon_); 181 g_object_unref(tab_specific_icon_);
174 182
175 if (default_icon_) 183 if (default_icon_)
176 g_object_unref(default_icon_); 184 g_object_unref(default_icon_);
(...skipping 12 matching lines...) Expand all
189 const content::NotificationSource& source, 197 const content::NotificationSource& source,
190 const content::NotificationDetails& details) { 198 const content::NotificationDetails& details) {
191 switch (type) { 199 switch (type) {
192 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED: 200 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED:
193 UpdateState(); 201 UpdateState();
194 break; 202 break;
195 case chrome::NOTIFICATION_EXTENSION_UNLOADED: 203 case chrome::NOTIFICATION_EXTENSION_UNLOADED:
196 case chrome::NOTIFICATION_WINDOW_CLOSED: 204 case chrome::NOTIFICATION_WINDOW_CLOSED:
197 DisconnectBrowserActionPopupAccelerator(); 205 DisconnectBrowserActionPopupAccelerator();
198 break; 206 break;
207 case chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED:
208 case chrome::NOTIFICATION_EXTENSION_COMMAND_REMOVED: {
209 std::pair<const std::string, const std::string>* payload =
210 content::Details<std::pair<const std::string, const std::string> >(
211 details).ptr();
212 if (extension_->id() == payload->first &&
Yoyo Zhou 2012/06/29 18:30:58 nit: looks funny to have these comparisons be diff
213 payload->second ==
214 extension_manifest_values::kBrowserActionKeybindingEvent) {
215 if (type == chrome::NOTIFICATION_EXTENSION_COMMAND_ADDED)
216 ConnectBrowserActionPopupAccelerator();
217 else
218 DisconnectBrowserActionPopupAccelerator();
219 }
220 break;
221 }
199 default: 222 default:
200 NOTREACHED(); 223 NOTREACHED();
201 break; 224 break;
202 } 225 }
203 } 226 }
204 227
205 // ImageLoadingTracker::Observer implementation. 228 // ImageLoadingTracker::Observer implementation.
206 void OnImageLoaded(const gfx::Image& image, 229 void OnImageLoaded(const gfx::Image& image,
207 const std::string& extension_id, 230 const std::string& extension_id,
208 int index) OVERRIDE { 231 int index) OVERRIDE {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 gfx::NativeWindow window = 448 gfx::NativeWindow window =
426 toolbar_->browser()->window()->GetNativeWindow(); 449 toolbar_->browser()->window()->GetNativeWindow();
427 gtk_accel_group_disconnect_key( 450 gtk_accel_group_disconnect_key(
428 accel_group_, 451 accel_group_,
429 keybinding_.get()->GetGdkKeyCode(), 452 keybinding_.get()->GetGdkKeyCode(),
430 static_cast<GdkModifierType>(keybinding_.get()->modifiers())); 453 static_cast<GdkModifierType>(keybinding_.get()->modifiers()));
431 gtk_window_remove_accel_group(window, accel_group_); 454 gtk_window_remove_accel_group(window, accel_group_);
432 g_object_unref(accel_group_); 455 g_object_unref(accel_group_);
433 accel_group_ = NULL; 456 accel_group_ = NULL;
434 keybinding_.reset(NULL); 457 keybinding_.reset(NULL);
458
459 // We've removed the accelerator, so no need to listen to this anymore.
460 registrar_.Remove(this,
461 chrome::NOTIFICATION_WINDOW_CLOSED,
462 content::Source<GtkWindow>(window));
Finnur 2012/06/29 14:35:38 If we don't remove this, then double registration
Yoyo Zhou 2012/06/29 18:30:58 Yup.
435 } 463 }
436 } 464 }
437 465
438 // The toolbar containing this button. 466 // The toolbar containing this button.
439 BrowserActionsToolbarGtk* toolbar_; 467 BrowserActionsToolbarGtk* toolbar_;
440 468
441 // The extension that contains this browser action. 469 // The extension that contains this browser action.
442 const Extension* extension_; 470 const Extension* extension_;
443 471
444 // The button for this browser action. 472 // The button for this browser action.
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1111
1084 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 1112 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
1085 event->time); 1113 event->time);
1086 return TRUE; 1114 return TRUE;
1087 } 1115 }
1088 1116
1089 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 1117 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
1090 if (!resize_animation_.is_animating()) 1118 if (!resize_animation_.is_animating())
1091 UpdateChevronVisibility(); 1119 UpdateChevronVisibility();
1092 } 1120 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698