| OLD | NEW |
| 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 "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 return true; | 743 return true; |
| 744 } | 744 } |
| 745 | 745 |
| 746 Extension::Extension(const FilePath& path) | 746 Extension::Extension(const FilePath& path) |
| 747 : converted_from_user_script_(false), | 747 : converted_from_user_script_(false), |
| 748 is_theme_(false), | 748 is_theme_(false), |
| 749 is_app_(false), | 749 is_app_(false), |
| 750 launch_container_(LAUNCH_TAB), | 750 launch_container_(LAUNCH_TAB), |
| 751 launch_width_(0), | 751 launch_width_(0), |
| 752 launch_height_(0), | 752 launch_height_(0), |
| 753 incognito_split_mode_(true), |
| 753 background_page_ready_(false), | 754 background_page_ready_(false), |
| 754 being_upgraded_(false) { | 755 being_upgraded_(false) { |
| 755 DCHECK(path.IsAbsolute()); | 756 DCHECK(path.IsAbsolute()); |
| 756 | 757 |
| 757 apps_enabled_ = AppsAreEnabled(); | 758 apps_enabled_ = AppsAreEnabled(); |
| 758 location_ = INVALID; | 759 location_ = INVALID; |
| 759 | 760 |
| 760 #if defined(OS_WIN) | 761 #if defined(OS_WIN) |
| 761 // Normalize any drive letter to upper-case. We do this for consistency with | 762 // Normalize any drive letter to upper-case. We do this for consistency with |
| 762 // net_utils::FilePathToFileURL(), which does the same thing, to make string | 763 // net_utils::FilePathToFileURL(), which does the same thing, to make string |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 *error = errors::kInvalidDevToolsPage; | 1522 *error = errors::kInvalidDevToolsPage; |
| 1522 return false; | 1523 return false; |
| 1523 } | 1524 } |
| 1524 if (!HasApiPermission(Extension::kExperimentalPermission)) { | 1525 if (!HasApiPermission(Extension::kExperimentalPermission)) { |
| 1525 *error = errors::kDevToolsExperimental; | 1526 *error = errors::kDevToolsExperimental; |
| 1526 return false; | 1527 return false; |
| 1527 } | 1528 } |
| 1528 devtools_url_ = GetResourceURL(devtools_str); | 1529 devtools_url_ = GetResourceURL(devtools_str); |
| 1529 } | 1530 } |
| 1530 | 1531 |
| 1532 } |
| 1533 |
| 1534 // Initialize incognito behavior. Apps default to split mode, extensions |
| 1535 // default to spanning. |
| 1536 incognito_split_mode_ = is_app_; |
| 1537 if (source.HasKey(keys::kIncognito)) { |
| 1538 std::string value; |
| 1539 if (!source.GetString(keys::kIncognito, &value)) { |
| 1540 *error = errors::kInvalidIncognitoBehavior; |
| 1541 return false; |
| 1542 } |
| 1543 if (value == values::kIncognitoSpanning) { |
| 1544 incognito_split_mode_ = false; |
| 1545 } else if (value == values::kIncognitoSplit) { |
| 1546 incognito_split_mode_ = true; |
| 1547 } else { |
| 1548 *error = errors::kInvalidIncognitoBehavior; |
| 1549 return false; |
| 1550 } |
| 1531 // Although |source| is passed in as a const, it's still possible to modify | 1551 // Although |source| is passed in as a const, it's still possible to modify |
| 1532 // it. This is dangerous since the utility process re-uses |source| after | 1552 // it. This is dangerous since the utility process re-uses |source| after |
| 1533 // it calls InitFromValue, passing it up to the browser process which calls | 1553 // it calls InitFromValue, passing it up to the browser process which calls |
| 1534 // InitFromValue again. As a result, we need to make sure that nobody | 1554 // InitFromValue again. As a result, we need to make sure that nobody |
| 1535 // accidentally modifies it. | 1555 // accidentally modifies it. |
| 1536 DCHECK(source.Equals(manifest_value_.get())); | 1556 DCHECK(source.Equals(manifest_value_.get())); |
| 1537 | 1557 |
| 1538 return true; | 1558 return true; |
| 1539 } | 1559 } |
| 1540 | 1560 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 : extension_id(id), | 1841 : extension_id(id), |
| 1822 extension_path(path), | 1842 extension_path(path), |
| 1823 extension_location(location) { | 1843 extension_location(location) { |
| 1824 if (manifest) | 1844 if (manifest) |
| 1825 extension_manifest.reset( | 1845 extension_manifest.reset( |
| 1826 static_cast<DictionaryValue*>(manifest->DeepCopy())); | 1846 static_cast<DictionaryValue*>(manifest->DeepCopy())); |
| 1827 } | 1847 } |
| 1828 | 1848 |
| 1829 ExtensionInfo::~ExtensionInfo() { | 1849 ExtensionInfo::~ExtensionInfo() { |
| 1830 } | 1850 } |
| OLD | NEW |