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

Side by Side Diff: chrome/common/extensions/api/extension_action/browser_action_handler.cc

Issue 11644057: Move BrowserAction out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_ungoop_extension_action
Patch Set: Created 8 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h "
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/utf_string_conversions.h"
9 #include "base/values.h"
10 #include "chrome/common/extensions/api/extension_action/action_handler_helpers.h "
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_constants.h"
13 #include "chrome/common/extensions/extension_manifest_constants.h"
14 #include "chrome/common/extensions/feature_switch.h"
15
16 namespace errors = extension_manifest_errors;
17
18 namespace extensions {
19
20 BrowserActionInfo::BrowserActionInfo(ActionInfo* action_info)
21 : browser_action_info(action_info) {
22 }
23
24 BrowserActionInfo::~BrowserActionInfo() {
25 }
26
27 // static
28 const ActionInfo* BrowserActionInfo::GetBrowserAction(
29 const Extension* extension) {
30 BrowserActionInfo* info = static_cast<BrowserActionInfo*>(
31 extension->GetManifestData(extension_manifest_keys::kBrowserAction));
32 return info ? info->browser_action_info.get() : NULL;
33 }
34
35 BrowserActionHandler::BrowserActionHandler() {
36 }
37
38 BrowserActionHandler::~BrowserActionHandler() {
39 }
40
41 bool BrowserActionHandler::Parse(const base::Value* value,
42 Extension* extension,
43 string16* error) {
44 const DictionaryValue* dict = NULL;
45 if (!value->GetAsDictionary(&dict)) {
46 *error = ASCIIToUTF16(errors::kInvalidBrowserAction);
47 return false;
48 }
49
50 scoped_ptr<ActionInfo> action_info = LoadActionInfo(extension, dict, error);
51 if (!action_info.get())
52 return false; // Failed to parse browser action definition.
53
54 extension->SetManifestData(extension_manifest_keys::kBrowserAction,
55 new BrowserActionInfo(action_info.release()));
56
57 return true;
58 }
59
60 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698