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

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

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 ExtensionResource Extension::GetResource( 380 ExtensionResource Extension::GetResource(
381 const std::string& relative_path) const { 381 const std::string& relative_path) const {
382 std::string new_path = relative_path; 382 std::string new_path = relative_path;
383 // We have some legacy data where resources have leading slashes. 383 // We have some legacy data where resources have leading slashes.
384 // See: http://crbug.com/121164 384 // See: http://crbug.com/121164
385 if (!new_path.empty() && new_path.at(0) == '/') 385 if (!new_path.empty() && new_path.at(0) == '/')
386 new_path.erase(0, 1); 386 new_path.erase(0, 1);
387 #if defined(OS_POSIX) 387 #if defined(OS_POSIX)
388 base::FilePath relative_file_path(new_path); 388 base::FilePath relative_file_path(new_path);
389 #elif defined(OS_WIN) 389 #elif defined(OS_WIN)
390 base::FilePath relative_file_path(UTF8ToWide(new_path)); 390 base::FilePath relative_file_path(base::UTF8ToWide(new_path));
391 #endif 391 #endif
392 ExtensionResource r(id(), path(), relative_file_path); 392 ExtensionResource r(id(), path(), relative_file_path);
393 if ((creation_flags() & Extension::FOLLOW_SYMLINKS_ANYWHERE)) { 393 if ((creation_flags() & Extension::FOLLOW_SYMLINKS_ANYWHERE)) {
394 r.set_follow_symlinks_anywhere(); 394 r.set_follow_symlinks_anywhere();
395 } 395 }
396 return r; 396 return r;
397 } 397 }
398 398
399 ExtensionResource Extension::GetResource( 399 ExtensionResource Extension::GetResource(
400 const base::FilePath& relative_file_path) const { 400 const base::FilePath& relative_file_path) const {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 bool Extension::ShowConfigureContextMenus() const { 783 bool Extension::ShowConfigureContextMenus() const {
784 // Don't show context menu for component extensions. We might want to show 784 // Don't show context menu for component extensions. We might want to show
785 // options for component extension button but now there is no component 785 // options for component extension button but now there is no component
786 // extension with options. All other menu items like uninstall have 786 // extension with options. All other menu items like uninstall have
787 // no sense for component extensions. 787 // no sense for component extensions.
788 return location() != Manifest::COMPONENT; 788 return location() != Manifest::COMPONENT;
789 } 789 }
790 790
791 std::set<base::FilePath> Extension::GetBrowserImages() const { 791 std::set<base::FilePath> Extension::GetBrowserImages() const {
792 std::set<base::FilePath> image_paths; 792 std::set<base::FilePath> image_paths;
793 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| 793 // TODO(viettrungluu): These |FilePath::FromWStringHack(base::UTF8ToWide())|
794 // indicate that we're doing something wrong. 794 // indicate that we're doing something wrong.
795 795
796 // Extension icons. 796 // Extension icons.
797 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); 797 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin();
798 iter != icons().map().end(); ++iter) { 798 iter != icons().map().end(); ++iter) {
799 image_paths.insert( 799 image_paths.insert(
800 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); 800 base::FilePath::FromWStringHack(base::UTF8ToWide(iter->second)));
801 } 801 }
802 802
803 // Theme images. 803 // Theme images.
804 DictionaryValue* theme_images = ThemeInfo::GetThemeImages(this); 804 DictionaryValue* theme_images = ThemeInfo::GetThemeImages(this);
805 if (theme_images) { 805 if (theme_images) {
806 for (DictionaryValue::Iterator it(*theme_images); !it.IsAtEnd(); 806 for (DictionaryValue::Iterator it(*theme_images); !it.IsAtEnd();
807 it.Advance()) { 807 it.Advance()) {
808 std::string val; 808 std::string val;
809 if (it.value().GetAsString(&val)) 809 if (it.value().GetAsString(&val)) {
810 image_paths.insert(base::FilePath::FromWStringHack(UTF8ToWide(val))); 810 image_paths.insert(base::FilePath::FromWStringHack(
811 base::UTF8ToWide(val)));
812 }
811 } 813 }
812 } 814 }
813 815
814 const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(this); 816 const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(this);
815 if (page_action_info && !page_action_info->default_icon.empty()) { 817 if (page_action_info && !page_action_info->default_icon.empty()) {
816 for (ExtensionIconSet::IconMap::const_iterator iter = 818 for (ExtensionIconSet::IconMap::const_iterator iter =
817 page_action_info->default_icon.map().begin(); 819 page_action_info->default_icon.map().begin();
818 iter != page_action_info->default_icon.map().end(); 820 iter != page_action_info->default_icon.map().end();
819 ++iter) { 821 ++iter) {
820 image_paths.insert( 822 image_paths.insert(
821 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); 823 base::FilePath::FromWStringHack(base::UTF8ToWide(iter->second)));
822 } 824 }
823 } 825 }
824 826
825 const ActionInfo* browser_action = ActionInfo::GetBrowserActionInfo(this); 827 const ActionInfo* browser_action = ActionInfo::GetBrowserActionInfo(this);
826 if (browser_action && !browser_action->default_icon.empty()) { 828 if (browser_action && !browser_action->default_icon.empty()) {
827 for (ExtensionIconSet::IconMap::const_iterator iter = 829 for (ExtensionIconSet::IconMap::const_iterator iter =
828 browser_action->default_icon.map().begin(); 830 browser_action->default_icon.map().begin();
829 iter != browser_action->default_icon.map().end(); 831 iter != browser_action->default_icon.map().end();
830 ++iter) { 832 ++iter) {
831 image_paths.insert( 833 image_paths.insert(
832 base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); 834 base::FilePath::FromWStringHack(base::UTF8ToWide(iter->second)));
833 } 835 }
834 } 836 }
835 837
836 return image_paths; 838 return image_paths;
837 } 839 }
838 840
839 ExtensionResource Extension::GetIconResource( 841 ExtensionResource Extension::GetIconResource(
840 int size, ExtensionIconSet::MatchType match_type) const { 842 int size, ExtensionIconSet::MatchType match_type) const {
841 std::string path = icons().Get(size, match_type); 843 std::string path = icons().Get(size, match_type);
842 return path.empty() ? ExtensionResource() : GetResource(path); 844 return path.empty() ? ExtensionResource() : GetResource(path);
(...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
2732 2734
2733 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2735 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2734 const Extension* extension, 2736 const Extension* extension,
2735 const PermissionSet* permissions, 2737 const PermissionSet* permissions,
2736 Reason reason) 2738 Reason reason)
2737 : reason(reason), 2739 : reason(reason),
2738 extension(extension), 2740 extension(extension),
2739 permissions(permissions) {} 2741 permissions(permissions) {}
2740 2742
2741 } // namespace extensions 2743 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/child_process_logging_win.cc ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698