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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 registrar_.Add(this, 179 registrar_.Add(this,
180 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 180 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
181 content::Source<Profile>(browser->profile())); 181 content::Source<Profile>(browser->profile()));
182 registrar_.Add( 182 registrar_.Add(
183 this, 183 this,
184 extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC, 184 extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC,
185 content::Source<Profile>(browser->profile())); 185 content::Source<Profile>(browser->profile()));
186 } 186 }
187 187
188 // Overridden from content::NotificationObserver. 188 // Overridden from content::NotificationObserver.
189 virtual void Observe( 189 void Observe(int type,
190 int type, 190 const content::NotificationSource& source,
191 const content::NotificationSource& source, 191 const content::NotificationDetails& details) override {
192 const content::NotificationDetails& details) override {
193 switch (type) { 192 switch (type) {
194 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { 193 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
195 ExtensionPopupController* popup = [ExtensionPopupController popup]; 194 ExtensionPopupController* popup = [ExtensionPopupController popup];
196 if (popup && ![popup isClosing]) 195 if (popup && ![popup isClosing])
197 [popup close]; 196 [popup close];
198 197
199 break; 198 break;
200 } 199 }
201 case extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC: { 200 case extensions::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC: {
202 std::pair<const std::string, gfx::NativeWindow>* payload = 201 std::pair<const std::string, gfx::NativeWindow>* payload =
203 content::Details<std::pair<const std::string, gfx::NativeWindow> >( 202 content::Details<std::pair<const std::string, gfx::NativeWindow> >(
204 details).ptr(); 203 details).ptr();
205 std::string extension_id = payload->first; 204 std::string extension_id = payload->first;
206 gfx::NativeWindow window = payload->second; 205 gfx::NativeWindow window = payload->second;
207 if (window != browser_->window()->GetNativeWindow()) 206 if (window != browser_->window()->GetNativeWindow())
208 break; 207 break;
209 [owner_ activateBrowserAction:extension_id]; 208 [owner_ activateBrowserAction:extension_id];
210 break; 209 break;
211 } 210 }
212 default: 211 default:
213 NOTREACHED() << L"Unexpected notification"; 212 NOTREACHED() << L"Unexpected notification";
214 } 213 }
215 } 214 }
216 215
217 // extensions::ExtensionToolbarModel::Observer implementation. 216 // extensions::ExtensionToolbarModel::Observer implementation.
218 virtual void ToolbarExtensionAdded( 217 void ToolbarExtensionAdded(const Extension* extension, int index) override {
219 const Extension* extension,
220 int index) override {
221 [owner_ createActionButtonForExtension:extension withIndex:index]; 218 [owner_ createActionButtonForExtension:extension withIndex:index];
222 [owner_ resizeContainerAndAnimate:NO]; 219 [owner_ resizeContainerAndAnimate:NO];
223 } 220 }
224 221
225 virtual void ToolbarExtensionRemoved(const Extension* extension) override { 222 void ToolbarExtensionRemoved(const Extension* extension) override {
226 [owner_ removeActionButtonForExtension:extension]; 223 [owner_ removeActionButtonForExtension:extension];
227 [owner_ resizeContainerAndAnimate:NO]; 224 [owner_ resizeContainerAndAnimate:NO];
228 } 225 }
229 226
230 virtual void ToolbarExtensionMoved(const Extension* extension, 227 void ToolbarExtensionMoved(const Extension* extension, int index) override {}
231 int index) override {
232 }
233 228
234 virtual void ToolbarExtensionUpdated(const Extension* extension) override { 229 void ToolbarExtensionUpdated(const Extension* extension) override {
235 BrowserActionButton* button = [owner_ buttonForExtension:extension]; 230 BrowserActionButton* button = [owner_ buttonForExtension:extension];
236 if (button) 231 if (button)
237 [button updateState]; 232 [button updateState];
238 } 233 }
239 234
240 virtual bool ShowExtensionActionPopup(const Extension* extension, 235 bool ShowExtensionActionPopup(const Extension* extension,
241 bool grant_active_tab) override { 236 bool grant_active_tab) override {
242 // Do not override other popups and only show in active window. 237 // Do not override other popups and only show in active window.
243 ExtensionPopupController* popup = [ExtensionPopupController popup]; 238 ExtensionPopupController* popup = [ExtensionPopupController popup];
244 if (popup || !browser_->window()->IsActive()) 239 if (popup || !browser_->window()->IsActive())
245 return false; 240 return false;
246 241
247 BrowserActionButton* button = [owner_ buttonForExtension:extension]; 242 BrowserActionButton* button = [owner_ buttonForExtension:extension];
248 return button && [owner_ browserActionClicked:button 243 return button && [owner_ browserActionClicked:button
249 shouldGrant:grant_active_tab]; 244 shouldGrant:grant_active_tab];
250 } 245 }
251 246
252 virtual void ToolbarVisibleCountChanged() override { 247 void ToolbarVisibleCountChanged() override {}
253 }
254 248
255 virtual void ToolbarHighlightModeChanged(bool is_highlighting) override { 249 void ToolbarHighlightModeChanged(bool is_highlighting) override {}
256 }
257 250
258 virtual Browser* GetBrowser() override { 251 Browser* GetBrowser() override { return browser_; }
259 return browser_;
260 }
261 252
262 private: 253 private:
263 // The object we need to inform when we get a notification. Weak. Owns us. 254 // The object we need to inform when we get a notification. Weak. Owns us.
264 BrowserActionsController* owner_; 255 BrowserActionsController* owner_;
265 256
266 // The browser we listen for events from. Weak. 257 // The browser we listen for events from. Weak.
267 Browser* browser_; 258 Browser* browser_;
268 259
269 // Used for registering to receive notifications and automatic clean up. 260 // Used for registering to receive notifications and automatic clean up.
270 content::NotificationRegistrar registrar_; 261 content::NotificationRegistrar registrar_;
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 const extensions::ExtensionList& toolbar_items = 849 const extensions::ExtensionList& toolbar_items =
859 toolbarModel_->toolbar_items(); 850 toolbarModel_->toolbar_items();
860 if (index < toolbar_items.size()) { 851 if (index < toolbar_items.size()) {
861 const Extension* extension = toolbar_items[index].get(); 852 const Extension* extension = toolbar_items[index].get();
862 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; 853 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())];
863 } 854 }
864 return nil; 855 return nil;
865 } 856 }
866 857
867 @end 858 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698