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

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

Issue 2206001: Merge 48149 - Relanding 48042.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/408/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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 Extension::Extension(const FilePath& path) 716 Extension::Extension(const FilePath& path)
717 : converted_from_user_script_(false), 717 : converted_from_user_script_(false),
718 is_theme_(false), 718 is_theme_(false),
719 web_content_enabled_(false), 719 web_content_enabled_(false),
720 launch_container_(LAUNCH_TAB), 720 launch_container_(LAUNCH_TAB),
721 launch_fullscreen_(false), 721 launch_fullscreen_(false),
722 background_page_ready_(false), 722 background_page_ready_(false),
723 being_upgraded_(false) { 723 being_upgraded_(false) {
724 DCHECK(path.IsAbsolute()); 724 DCHECK(path.IsAbsolute());
725 725
726 apps_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( 726 apps_enabled_ = AppsAreEnabled();
727 switches::kEnableApps);
728 location_ = INVALID; 727 location_ = INVALID;
729 728
730 #if defined(OS_WIN) 729 #if defined(OS_WIN)
731 // Normalize any drive letter to upper-case. We do this for consistency with 730 // Normalize any drive letter to upper-case. We do this for consistency with
732 // net_utils::FilePathToFileURL(), which does the same thing, to make string 731 // net_utils::FilePathToFileURL(), which does the same thing, to make string
733 // comparisons simpler. 732 // comparisons simpler.
734 std::wstring path_str = path.value(); 733 std::wstring path_str = path.value();
735 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && 734 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' &&
736 path_str[1] == ':') 735 path_str[1] == ':')
737 path_str[0] += ('A' - 'a'); 736 path_str[0] += ('A' - 'a');
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 921 }
923 922
924 result->swap(decoded); 923 result->swap(decoded);
925 } 924 }
926 925
927 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { 926 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) {
928 return GURL(std::string(chrome::kExtensionScheme) + 927 return GURL(std::string(chrome::kExtensionScheme) +
929 chrome::kStandardSchemeSeparator + extension_id + "/"); 928 chrome::kStandardSchemeSeparator + extension_id + "/");
930 } 929 }
931 930
931 // static
932 bool Extension::AppsAreEnabled() {
933 #if defined(OS_CHROMEOS)
934 return true;
935 #else
936 static bool apps_enabled_mode =
937 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps);
938 return apps_enabled_mode;
939 #endif
940 }
941
932 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, 942 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
933 std::string* error) { 943 std::string* error) {
934 if (source.HasKey(keys::kPublicKey)) { 944 if (source.HasKey(keys::kPublicKey)) {
935 std::string public_key_bytes; 945 std::string public_key_bytes;
936 if (!source.GetString(keys::kPublicKey, &public_key_) || 946 if (!source.GetString(keys::kPublicKey, &public_key_) ||
937 !ParsePEMKeyBytes(public_key_, &public_key_bytes) || 947 !ParsePEMKeyBytes(public_key_, &public_key_bytes) ||
938 !GenerateId(public_key_bytes, &id_)) { 948 !GenerateId(public_key_bytes, &id_)) {
939 *error = errors::kInvalidKey; 949 *error = errors::kInvalidKey;
940 return false; 950 return false;
941 } 951 }
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 } else { 1694 } else {
1685 return false; 1695 return false;
1686 } 1696 }
1687 } else { 1697 } else {
1688 return true; 1698 return true;
1689 } 1699 }
1690 } 1700 }
1691 } 1701 }
1692 return false; 1702 return false;
1693 } 1703 }
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