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

Issue 10911300: Move ExtensionAction from common/ to browser/. (Closed)

Created:
8 years, 3 months ago by Jeffrey Yasskin
Modified:
8 years, 2 months ago
Reviewers:
Aaron Boodman, tbarzic
CC:
chromium-reviews, mihaip-chromium-reviews_chromium.org, tfarina, kkania, robertshield, darin-cc_chromium.org, Matt Perry, not at google - send to devlin
Visibility:
Public.

Description

Move ExtensionAction from common/ to browser/. Chrome builds, but not the unit tests, yet.

Patch Set 1 : proof of concept #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+329 lines, -1311 lines) Patch
M chrome/browser/automation/testing_automation_provider.cc View 5 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/extensions/api/context_menu/context_menu_apitest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/browser_action_apitest.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/extension_actions_api.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/extension_actions_api.cc View 5 chunks +15 lines, -13 lines 0 comments Download
M chrome/browser/extensions/api/extension_action/extension_browser_actions_api.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/extension_page_actions_api.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/extensions/api/extension_action/page_action_apitest.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/extension_action/script_badge_apitest.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/extensions/browser_event_router.h View 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/browser/extensions/browser_event_router.cc View 2 chunks +4 lines, -3 lines 0 comments Download
A + chrome/browser/extensions/extension_action.h View 7 chunks +17 lines, -13 lines 5 comments Download
A + chrome/browser/extensions/extension_action.cc View 3 chunks +42 lines, -5 lines 0 comments Download
A + chrome/browser/extensions/extension_action_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_context_menu_model.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/extensions/extension_keybinding_apitest.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M chrome/browser/extensions/extension_service.h View 3 chunks +17 lines, -0 lines 2 comments Download
M chrome/browser/extensions/extension_service.cc View 4 chunks +70 lines, -0 lines 3 comments Download
M chrome/browser/extensions/extension_toolbar_model.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/extensions/page_action_controller.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/extensions/script_badge_controller.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/extensions/tab_helper.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/cocoa/extensions/browser_action_button.mm View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm View 1 chunk +1 line, -1 line 1 comment Download
M chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/cocoa/location_bar/page_action_decoration.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/cocoa/location_bar/page_action_decoration.mm View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc View 8 chunks +16 lines, -12 lines 0 comments Download
M chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc View 3 chunks +8 lines, -5 lines 0 comments Download
M chrome/browser/ui/gtk/location_bar_view_gtk.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/gtk/location_bar_view_gtk.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/browser_actions_container_browsertest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/extensions/extension_installed_bubble.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/location_bar/page_action_image_view.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/location_bar/page_action_image_view.cc View 2 chunks +1 line, -1 line 0 comments Download
M chrome/chrome_browser_extensions.gypi View 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/chrome_common.gypi View 1 chunk +0 lines, -2 lines 0 comments Download
M chrome/chrome_tests.gypi View 2 chunks +1 line, -1 line 0 comments Download
M chrome/common/extensions/extension.h View 5 chunks +33 lines, -12 lines 2 comments Download
M chrome/common/extensions/extension.cc View 15 chunks +38 lines, -53 lines 0 comments Download
D chrome/common/extensions/extension_action.h View 1 chunk +0 lines, -353 lines 0 comments Download
D chrome/common/extensions/extension_action.cc View 1 chunk +0 lines, -524 lines 0 comments Download
D chrome/common/extensions/extension_action_unittest.cc View 1 chunk +0 lines, -234 lines 0 comments Download
M chrome/common/extensions/extension_file_util.cc View 2 chunks +11 lines, -17 lines 0 comments Download
M chrome/common/extensions/extension_unittest.cc View 2 chunks +2 lines, -3 lines 0 comments Download
M chrome/common/extensions/manifest_tests/extension_manifests_pageaction_unittest.cc View 2 chunks +4 lines, -7 lines 0 comments Download
M chrome/common/extensions/manifest_tests/extension_manifests_scriptbadge_unittest.cc View 2 chunks +2 lines, -5 lines 0 comments Download
M chrome/renderer/extensions/extension_custom_bindings.cc View 1 chunk +0 lines, -1 line 0 comments Download
M chrome/renderer/extensions/page_actions_custom_bindings.cc View 2 chunks +1 line, -2 lines 0 comments Download
M chrome/renderer/extensions/tabs_custom_bindings.cc View 1 chunk +0 lines, -1 line 0 comments Download
M chrome/renderer/extensions/tts_custom_bindings.cc View 1 chunk +0 lines, -1 line 0 comments Download
M chrome/test/base/ui_test_utils.cc View 2 chunks +1 line, -1 line 0 comments Download

Messages

Total messages: 6 (0 generated)
Jeffrey Yasskin
This is hacky in several places, but it appears to be possible. http://codereview.chromium.org/10911300/diff/5001/chrome/browser/extensions/extension_service.h File chrome/browser/extensions/extension_service.h ...
8 years, 3 months ago (2012-09-13 23:51:58 UTC) #1
Jeffrey Yasskin
http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/extension_action.h File chrome/browser/extensions/extension_action.h (right): http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/extension_action.h#newcode352 chrome/browser/extensions/extension_action.h:352: ExtensionAction* GetBrowserAction(Profile* profile, const Extension& extension); Functions along these ...
8 years, 3 months ago (2012-09-14 19:18:33 UTC) #2
Aaron Boodman
This will be a really nice cleanup. http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/extension_action.h File chrome/browser/extensions/extension_action.h (right): http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/extension_action.h#newcode5 chrome/browser/extensions/extension_action.h:5: #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ ...
8 years, 3 months ago (2012-09-16 01:42:50 UTC) #3
Aaron Boodman
Is someone going to finish this? I think it's a really nice and important cleanup.
8 years, 2 months ago (2012-09-26 18:06:42 UTC) #4
Aaron Boodman
+mpcomplete, kalman fyi
8 years, 2 months ago (2012-09-26 18:07:02 UTC) #5
not at google - send to devlin
8 years, 2 months ago (2012-09-27 00:46:10 UTC) #6
Some thoughts from reading the review comments. I haven't actually gone through
the code itself.

http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/e...
File chrome/browser/extensions/extension_action.h (right):

http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/e...
chrome/browser/extensions/extension_action.h:352: ExtensionAction*
GetBrowserAction(Profile* profile, const Extension& extension);
On 2012/09/16 01:42:50, Aaron Boodman wrote:
> On 2012/09/14 19:18:33, Jeffrey Yasskin wrote:
> > Functions along these lines are important to shorten code that needs to
> retrieve
> > ExtensionActions, but they could live in several places. Aaron, do you have
an
> > opinion on where?
> 
> The downside of free functions like this is that it's not immediately clear
when
> reading the code where they come from.
> 
> I'd typically prefer them as static members of ExtensionAction, but then I'm
not
> sure if it's enough of a typing savings.

I also do not like free/utility functions like this.

Even if they do live as static functions on ExtensionAction, it slightly
obfuscates where the ExtensionActions come from, with the only advantage being
saving a bit of typing. It also means that somebody cargo-culting code might
think they need a Profile when really all they need is an
ExtensionActionManager, which leads to dependency bloat and testing
difficulties.

Aside: I get upset every time I need to find the header file where
chrome::GetActiveWebContents lives. Grr! Y U NOT ON BROWSER.

Yennyway, the question is just who owns the ExtensionActions now. And the answer
is (I hear) ExtensionSystem (or some object which hangs off it like an
ExtensionActionManager -- which I think is a good idea, keep dependencies
small). If a class repeatedly gets page actions and wants to save typing, it can
cache a reference to the ExtensionActionManager (though more likely it's just
going to cache a reference to the ExtensionAction itself).

http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/e...
File chrome/browser/extensions/extension_service.cc (right):

http://codereview.chromium.org/10911300/diff/7001/chrome/browser/extensions/e...
chrome/browser/extensions/extension_service.cc:2422: case
chrome::NOTIFICATION_EXTENSION_LOADED: {
On 2012/09/16 01:42:50, Aaron Boodman wrote:
> This is the kind of code I'm trying to keep out of ExtensionService. Should be
> in ExtensionActionManager and use EXTENSION_LOADED/UNLOADED notifications to
> populate self.

Not that this solves the LOADED/UNLOADED problem, but what we need is an
ExtensionMap like ExtensionSet.

http://codereview.chromium.org/10911300/diff/7001/chrome/common/extensions/ex...
File chrome/common/extensions/extension.h (right):

http://codereview.chromium.org/10911300/diff/7001/chrome/common/extensions/ex...
chrome/common/extensions/extension.h:214: TYPE_BROWSER,
On 2012/09/16 01:42:50, Aaron Boodman wrote:
> Do we need to carry around the type? The caller knows what type it is because
of
> the member it comes from. Perhaps this information only needed in browser?

It was initially added for when page actions got implicitly converted into
browser actions, for the script badges. Even though extension->browser_action()
returned an ExtensionAction, it was actually a page action and the API calls
needed to be made as such.

Since then it's also being used to decide what sizes to make the icons, I think.

While explaining that it makes me think that this is the wrong model to use, and
what we actually want is for the browser version of ExtensionAction to have a
"location" property, like

enum Location {
  LOCATION_BAR,
  TOOLBAR,
  ACTION_BOX
};

and then for the "type" to be removed and code which relies on it to use the
Location property instead.

Powered by Google App Engine
This is Rietveld 408576698