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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 2149003: Relanding 48042... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 Extension::Extension(const FilePath& path) 717 Extension::Extension(const FilePath& path)
718 : converted_from_user_script_(false), 718 : converted_from_user_script_(false),
719 is_theme_(false), 719 is_theme_(false),
720 web_content_enabled_(false), 720 web_content_enabled_(false),
721 launch_container_(LAUNCH_TAB), 721 launch_container_(LAUNCH_TAB),
722 launch_fullscreen_(false), 722 launch_fullscreen_(false),
723 background_page_ready_(false), 723 background_page_ready_(false),
724 being_upgraded_(false) { 724 being_upgraded_(false) {
725 DCHECK(path.IsAbsolute()); 725 DCHECK(path.IsAbsolute());
726 726
727 apps_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( 727 apps_enabled_ = AppsAreEnabled();
728 switches::kEnableApps);
729 location_ = INVALID; 728 location_ = INVALID;
730 729
731 #if defined(OS_WIN) 730 #if defined(OS_WIN)
732 // Normalize any drive letter to upper-case. We do this for consistency with 731 // Normalize any drive letter to upper-case. We do this for consistency with
733 // net_utils::FilePathToFileURL(), which does the same thing, to make string 732 // net_utils::FilePathToFileURL(), which does the same thing, to make string
734 // comparisons simpler. 733 // comparisons simpler.
735 std::wstring path_str = path.value(); 734 std::wstring path_str = path.value();
736 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && 735 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' &&
737 path_str[1] == ':') 736 path_str[1] == ':')
738 path_str[0] += ('A' - 'a'); 737 path_str[0] += ('A' - 'a');
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 922 }
924 923
925 result->swap(decoded); 924 result->swap(decoded);
926 } 925 }
927 926
928 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { 927 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) {
929 return GURL(std::string(chrome::kExtensionScheme) + 928 return GURL(std::string(chrome::kExtensionScheme) +
930 chrome::kStandardSchemeSeparator + extension_id + "/"); 929 chrome::kStandardSchemeSeparator + extension_id + "/");
931 } 930 }
932 931
932 // static
933 bool Extension::AppsAreEnabled() {
934 #if defined(OS_CHROMEOS)
935 return true;
936 #else
937 static bool apps_enabled_mode =
938 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps);
939 return apps_enabled_mode;
940 #endif
941 }
942
933 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, 943 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
934 std::string* error) { 944 std::string* error) {
935 if (source.HasKey(keys::kPublicKey)) { 945 if (source.HasKey(keys::kPublicKey)) {
936 std::string public_key_bytes; 946 std::string public_key_bytes;
937 if (!source.GetString(keys::kPublicKey, &public_key_) || 947 if (!source.GetString(keys::kPublicKey, &public_key_) ||
938 !ParsePEMKeyBytes(public_key_, &public_key_bytes) || 948 !ParsePEMKeyBytes(public_key_, &public_key_bytes) ||
939 !GenerateId(public_key_bytes, &id_)) { 949 !GenerateId(public_key_bytes, &id_)) {
940 *error = errors::kInvalidKey; 950 *error = errors::kInvalidKey;
941 return false; 951 return false;
942 } 952 }
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 } else { 1698 } else {
1689 return false; 1699 return false;
1690 } 1700 }
1691 } else { 1701 } else {
1692 return true; 1702 return true;
1693 } 1703 }
1694 } 1704 }
1695 } 1705 }
1696 return false; 1706 return false;
1697 } 1707 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_manifests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698