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

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

Issue 22470007: Add a "key" entry to InstallWarnings, remove InstallWarning::Format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_infrastructure
Patch Set: Created 7 years, 4 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 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h" 5 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.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/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 27 matching lines...) Expand all
38 SetActionInfoDefaults(extension, action_info.get()); 38 SetActionInfoDefaults(extension, action_info.get());
39 ActionInfo::SetScriptBadgeInfo(extension, action_info.release()); 39 ActionInfo::SetScriptBadgeInfo(extension, action_info.release());
40 return true; 40 return true;
41 } 41 }
42 42
43 // So as to not confuse developers if they specify a script badge section 43 // So as to not confuse developers if they specify a script badge section
44 // in the manifest, show a warning if the script badge declaration isn't 44 // in the manifest, show a warning if the script badge declaration isn't
45 // going to have any effect. 45 // going to have any effect.
46 if (!FeatureSwitch::script_badges()->IsEnabled()) { 46 if (!FeatureSwitch::script_badges()->IsEnabled()) {
47 extension->AddInstallWarning( 47 extension->AddInstallWarning(
48 InstallWarning(InstallWarning::FORMAT_TEXT, 48 InstallWarning(errors::kScriptBadgeRequiresFlag, keys::kScriptBadge));
49 errors::kScriptBadgeRequiresFlag));
50 } 49 }
51 50
52 const base::DictionaryValue* dict = NULL; 51 const base::DictionaryValue* dict = NULL;
53 if (!extension->manifest()->GetDictionary(keys::kScriptBadge, &dict)) { 52 if (!extension->manifest()->GetDictionary(keys::kScriptBadge, &dict)) {
54 *error = ASCIIToUTF16(errors::kInvalidScriptBadge); 53 *error = ASCIIToUTF16(errors::kInvalidScriptBadge);
55 return false; 54 return false;
56 } 55 }
57 56
58 action_info = ActionInfo::Load(extension, dict, error); 57 action_info = ActionInfo::Load(extension, dict, error);
59 58
60 if (!action_info.get()) 59 if (!action_info.get())
61 return false; // Failed to parse script badge definition. 60 return false; // Failed to parse script badge definition.
62 61
63 // Script badges always use their extension's title and icon so users can rely 62 // Script badges always use their extension's title and icon so users can rely
64 // on the visual appearance to know which extension is running. This isn't 63 // on the visual appearance to know which extension is running. This isn't
65 // bulletproof since an malicious extension could use a different 16x16 icon 64 // bulletproof since an malicious extension could use a different 16x16 icon
66 // that matches the icon of a trusted extension, and users wouldn't be warned 65 // that matches the icon of a trusted extension, and users wouldn't be warned
67 // during installation. 66 // during installation.
68 67
69 if (!action_info->default_title.empty()) { 68 if (!action_info->default_title.empty()) {
70 extension->AddInstallWarning( 69 extension->AddInstallWarning(
71 InstallWarning(InstallWarning::FORMAT_TEXT, 70 InstallWarning(errors::kScriptBadgeTitleIgnored,
72 errors::kScriptBadgeTitleIgnored)); 71 keys::kScriptBadge,
72 keys::kPageActionDefaultTitle));
73 } 73 }
74 74
75 if (!action_info->default_icon.empty()) { 75 if (!action_info->default_icon.empty()) {
76 extension->AddInstallWarning( 76 extension->AddInstallWarning(
77 InstallWarning(InstallWarning::FORMAT_TEXT, 77 InstallWarning(errors::kScriptBadgeIconIgnored,
78 errors::kScriptBadgeIconIgnored)); 78 keys::kScriptBadge,
79 keys::kPageActionDefaultIcon));
79 } 80 }
80 81
81 SetActionInfoDefaults(extension, action_info.get()); 82 SetActionInfoDefaults(extension, action_info.get());
82 ActionInfo::SetScriptBadgeInfo(extension, action_info.release()); 83 ActionInfo::SetScriptBadgeInfo(extension, action_info.release());
83 return true; 84 return true;
84 } 85 }
85 86
86 bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) const { 87 bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) const {
87 return type == Manifest::TYPE_EXTENSION; 88 return type == Manifest::TYPE_EXTENSION;
88 } 89 }
(...skipping 11 matching lines...) Expand all
100 extension_misc::kScriptBadgeIconSizes[i], path); 101 extension_misc::kScriptBadgeIconSizes[i], path);
101 } 102 }
102 } 103 }
103 } 104 }
104 105
105 const std::vector<std::string> ScriptBadgeHandler::Keys() const { 106 const std::vector<std::string> ScriptBadgeHandler::Keys() const {
106 return SingleKey(keys::kScriptBadge); 107 return SingleKey(keys::kScriptBadge);
107 } 108 }
108 109
109 } // namespace extensions 110 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698