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

Side by Side Diff: chrome/common/extensions/manifest_handlers/extension_action_handler.cc

Issue 977943002: [Extension Toolbar] Don't synthesize actions for policy extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 9 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
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/extensions/manifest_handlers/extension_action_handler.h" 5 #include "chrome/common/extensions/manifest_handlers/extension_action_handler.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/api/extension_action/action_info.h" 10 #include "chrome/common/extensions/api/extension_action/action_info.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if (!action_info) 54 if (!action_info)
55 return false; // Failed to parse extension action definition. 55 return false; // Failed to parse extension action definition.
56 56
57 if (key == manifest_keys::kPageAction) 57 if (key == manifest_keys::kPageAction)
58 ActionInfo::SetPageActionInfo(extension, action_info.release()); 58 ActionInfo::SetPageActionInfo(extension, action_info.release());
59 else 59 else
60 ActionInfo::SetBrowserActionInfo(extension, action_info.release()); 60 ActionInfo::SetBrowserActionInfo(extension, action_info.release());
61 } else { // No key, used for synthesizing an action for extensions with none. 61 } else { // No key, used for synthesizing an action for extensions with none.
62 if (!FeatureSwitch::extension_action_redesign()->IsEnabled()) 62 if (!FeatureSwitch::extension_action_redesign()->IsEnabled())
63 return true; // Do nothing if the switch is off. 63 return true; // Do nothing if the switch is off.
64 if (Manifest::IsComponentLocation(extension->location())) 64 if (Manifest::IsComponentLocation(extension->location()) ||
65 return true; // Don't synthesize actions for component extensions. 65 Manifest::IsPolicyLocation(extension->location()))
66 return true; // Don't synthesize actions for component/policy extensions.
66 if (extension->manifest()->HasKey( 67 if (extension->manifest()->HasKey(
67 manifest_keys::kSynthesizeExtensionAction)) { 68 manifest_keys::kSynthesizeExtensionAction)) {
68 *error = base::ASCIIToUTF16(base::StringPrintf( 69 *error = base::ASCIIToUTF16(base::StringPrintf(
69 "Key %s is reserved.", manifest_keys::kSynthesizeExtensionAction)); 70 "Key %s is reserved.", manifest_keys::kSynthesizeExtensionAction));
70 return false; // No one should use this key. 71 return false; // No one should use this key.
71 } 72 }
72 73
73 // Set an empty page action. We use a page action (instead of a browser 74 // Set an empty page action. We use a page action (instead of a browser
74 // action) because the action should not be seen as enabled on every page. 75 // action) because the action should not be seen as enabled on every page.
75 ActionInfo::SetPageActionInfo(extension, new ActionInfo()); 76 ActionInfo::SetPageActionInfo(extension, new ActionInfo());
(...skipping 29 matching lines...) Expand all
105 106
106 const std::vector<std::string> ExtensionActionHandler::Keys() const { 107 const std::vector<std::string> ExtensionActionHandler::Keys() const {
107 std::vector<std::string> keys; 108 std::vector<std::string> keys;
108 keys.push_back(manifest_keys::kPageAction); 109 keys.push_back(manifest_keys::kPageAction);
109 keys.push_back(manifest_keys::kBrowserAction); 110 keys.push_back(manifest_keys::kBrowserAction);
110 keys.push_back(manifest_keys::kSynthesizeExtensionAction); 111 keys.push_back(manifest_keys::kSynthesizeExtensionAction);
111 return keys; 112 return keys;
112 } 113 }
113 114
114 } // namespace extensions 115 } // namespace extensions
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