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

Side by Side Diff: chrome/common/extensions/manifest_handlers/app_launch_info.cc

Issue 105473003: Add explicit base namespace to string16 users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/manifest_handlers/app_launch_info.h" 5 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/extension_constants.h" 13 #include "chrome/common/extensions/extension_constants.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "extensions/common/error_utils.h" 15 #include "extensions/common/error_utils.h"
16 #include "extensions/common/manifest_constants.h" 16 #include "extensions/common/manifest_constants.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 namespace keys = manifest_keys; 20 namespace keys = manifest_keys;
21 namespace values = manifest_values; 21 namespace values = manifest_values;
22 namespace errors = manifest_errors; 22 namespace errors = manifest_errors;
23 23
24 namespace { 24 namespace {
25 25
26 bool ReadLaunchDimension(const extensions::Manifest* manifest, 26 bool ReadLaunchDimension(const extensions::Manifest* manifest,
27 const char* key, 27 const char* key,
28 int* target, 28 int* target,
29 bool is_valid_container, 29 bool is_valid_container,
30 string16* error) { 30 base::string16* error) {
31 const Value* temp = NULL; 31 const Value* temp = NULL;
32 if (manifest->Get(key, &temp)) { 32 if (manifest->Get(key, &temp)) {
33 if (!is_valid_container) { 33 if (!is_valid_container) {
34 *error = ErrorUtils::FormatErrorMessageUTF16( 34 *error = ErrorUtils::FormatErrorMessageUTF16(
35 errors::kInvalidLaunchValueContainer, 35 errors::kInvalidLaunchValueContainer,
36 key); 36 key);
37 return false; 37 return false;
38 } 38 }
39 if (!temp->GetAsInteger(target) || *target < 0) { 39 if (!temp->GetAsInteger(target) || *target < 0) {
40 *target = 0; 40 *target = 0;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // static 98 // static
99 GURL AppLaunchInfo::GetFullLaunchURL(const Extension* extension) { 99 GURL AppLaunchInfo::GetFullLaunchURL(const Extension* extension) {
100 const AppLaunchInfo& info = GetAppLaunchInfo(extension); 100 const AppLaunchInfo& info = GetAppLaunchInfo(extension);
101 if (info.launch_local_path_.empty()) 101 if (info.launch_local_path_.empty())
102 return info.launch_web_url_; 102 return info.launch_web_url_;
103 else 103 else
104 return extension->url().Resolve(info.launch_local_path_); 104 return extension->url().Resolve(info.launch_local_path_);
105 } 105 }
106 106
107 bool AppLaunchInfo::Parse(Extension* extension, string16* error) { 107 bool AppLaunchInfo::Parse(Extension* extension, base::string16* error) {
108 if (!LoadLaunchURL(extension, error) || 108 if (!LoadLaunchURL(extension, error) ||
109 !LoadLaunchContainer(extension, error)) 109 !LoadLaunchContainer(extension, error))
110 return false; 110 return false;
111 return true; 111 return true;
112 } 112 }
113 113
114 bool AppLaunchInfo::LoadLaunchURL(Extension* extension, string16* error) { 114 bool AppLaunchInfo::LoadLaunchURL(Extension* extension, base::string16* error) {
115 const Value* temp = NULL; 115 const Value* temp = NULL;
116 116
117 // Launch URL can be either local (to chrome-extension:// root) or an absolute 117 // Launch URL can be either local (to chrome-extension:// root) or an absolute
118 // web URL. 118 // web URL.
119 if (extension->manifest()->Get(keys::kLaunchLocalPath, &temp)) { 119 if (extension->manifest()->Get(keys::kLaunchLocalPath, &temp)) {
120 if (extension->manifest()->Get(keys::kLaunchWebURL, NULL)) { 120 if (extension->manifest()->Get(keys::kLaunchWebURL, NULL)) {
121 *error = ASCIIToUTF16(errors::kLaunchPathAndURLAreExclusive); 121 *error = ASCIIToUTF16(errors::kLaunchPathAndURLAreExclusive);
122 return false; 122 return false;
123 } 123 }
124 124
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 GURL cloud_print_enable_connector_url = 218 GURL cloud_print_enable_connector_url =
219 cloud_print_service_url.ReplaceComponents(replacements); 219 cloud_print_service_url.ReplaceComponents(replacements);
220 OverrideLaunchURL(extension, cloud_print_enable_connector_url); 220 OverrideLaunchURL(extension, cloud_print_enable_connector_url);
221 } 221 }
222 } 222 }
223 223
224 return true; 224 return true;
225 } 225 }
226 226
227 bool AppLaunchInfo::LoadLaunchContainer(Extension* extension, 227 bool AppLaunchInfo::LoadLaunchContainer(Extension* extension,
228 string16* error) { 228 base::string16* error) {
229 const Value* tmp_launcher_container = NULL; 229 const Value* tmp_launcher_container = NULL;
230 if (!extension->manifest()->Get(keys::kLaunchContainer, 230 if (!extension->manifest()->Get(keys::kLaunchContainer,
231 &tmp_launcher_container)) 231 &tmp_launcher_container))
232 return true; 232 return true;
233 233
234 std::string launch_container_string; 234 std::string launch_container_string;
235 if (!tmp_launcher_container->GetAsString(&launch_container_string)) { 235 if (!tmp_launcher_container->GetAsString(&launch_container_string)) {
236 *error = ASCIIToUTF16(errors::kInvalidLaunchContainer); 236 *error = ASCIIToUTF16(errors::kInvalidLaunchContainer);
237 return false; 237 return false;
238 } 238 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 pattern.SetPath(pattern.path() + '*'); 292 pattern.SetPath(pattern.path() + '*');
293 extension->AddWebExtentPattern(pattern); 293 extension->AddWebExtentPattern(pattern);
294 } 294 }
295 295
296 AppLaunchManifestHandler::AppLaunchManifestHandler() { 296 AppLaunchManifestHandler::AppLaunchManifestHandler() {
297 } 297 }
298 298
299 AppLaunchManifestHandler::~AppLaunchManifestHandler() { 299 AppLaunchManifestHandler::~AppLaunchManifestHandler() {
300 } 300 }
301 301
302 bool AppLaunchManifestHandler::Parse(Extension* extension, string16* error) { 302 bool AppLaunchManifestHandler::Parse(Extension* extension,
303 base::string16* error) {
303 scoped_ptr<AppLaunchInfo> info(new AppLaunchInfo); 304 scoped_ptr<AppLaunchInfo> info(new AppLaunchInfo);
304 if (!info->Parse(extension, error)) 305 if (!info->Parse(extension, error))
305 return false; 306 return false;
306 extension->SetManifestData(keys::kLaunch, info.release()); 307 extension->SetManifestData(keys::kLaunch, info.release());
307 return true; 308 return true;
308 } 309 }
309 310
310 bool AppLaunchManifestHandler::AlwaysParseForType(Manifest::Type type) const { 311 bool AppLaunchManifestHandler::AlwaysParseForType(Manifest::Type type) const {
311 return type == Manifest::TYPE_LEGACY_PACKAGED_APP; 312 return type == Manifest::TYPE_LEGACY_PACKAGED_APP;
312 } 313 }
313 314
314 const std::vector<std::string> AppLaunchManifestHandler::Keys() const { 315 const std::vector<std::string> AppLaunchManifestHandler::Keys() const {
315 static const char* keys[] = { 316 static const char* keys[] = {
316 keys::kLaunchLocalPath, 317 keys::kLaunchLocalPath,
317 keys::kLaunchWebURL, 318 keys::kLaunchWebURL,
318 keys::kLaunchContainer, 319 keys::kLaunchContainer,
319 keys::kLaunchHeight, 320 keys::kLaunchHeight,
320 keys::kLaunchWidth 321 keys::kLaunchWidth
321 }; 322 };
322 return std::vector<std::string>(keys, keys + arraysize(keys)); 323 return std::vector<std::string>(keys, keys + arraysize(keys));
323 } 324 }
324 325
325 } // namespace extensions 326 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698