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

Side by Side Diff: chrome/browser/chromeos/extensions/device_local_account_management_policy_provider.cc

Issue 2127373006: Use base::StartWith() in more places when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 4 years, 5 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
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/browser/chromeos/extensions/device_local_account_management_pol icy_provider.h" 5 #include "chrome/browser/chromeos/extensions/device_local_account_management_pol icy_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <string> 10 #include <string>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 #include "extensions/common/manifest.h" 18 #include "extensions/common/manifest.h"
18 #include "extensions/common/manifest_constants.h" 19 #include "extensions/common/manifest_constants.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 namespace chromeos { 22 namespace chromeos {
22 23
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 << " contains a token that's neither a string nor a dict."; 482 << " contains a token that's neither a string nor a dict.";
482 safe = false; 483 safe = false;
483 continue; 484 continue;
484 } 485 }
485 // Accept whitelisted permissions. 486 // Accept whitelisted permissions.
486 if (ArrayContains(kSafePermissionStrings, permission_string)) { 487 if (ArrayContains(kSafePermissionStrings, permission_string)) {
487 continue; 488 continue;
488 } 489 }
489 // Allow arbitrary web requests. Don't include <all_urls> because that 490 // Allow arbitrary web requests. Don't include <all_urls> because that
490 // also matches file:// schemes. 491 // also matches file:// schemes.
491 if (permission_string.find("https://") == 0 || 492 if (base::StartsWith(permission_string, "https://",
492 permission_string.find("http://") == 0 || 493 base::CompareCase::SENSITIVE) ||
493 permission_string.find("ftp://") == 0) { 494 base::StartsWith(permission_string, "http://",
495 base::CompareCase::SENSITIVE) ||
496 base::StartsWith(permission_string, "ftp://",
497 base::CompareCase::SENSITIVE)) {
494 continue; 498 continue;
495 } 499 }
496 LOG(ERROR) << extension->id() 500 LOG(ERROR) << extension->id()
497 << " requested non-whitelisted permission: " 501 << " requested non-whitelisted permission: "
498 << permission_string; 502 << permission_string;
499 safe = false; 503 safe = false;
500 } 504 }
501 // "app" may only contain "background". 505 // "app" may only contain "background".
502 } else if (it.key() == emk::kApp) { 506 } else if (it.key() == emk::kApp) {
503 const base::DictionaryValue *dict_value; 507 const base::DictionaryValue *dict_value;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if (error) { 617 if (error) {
614 *error = l10n_util::GetStringFUTF16( 618 *error = l10n_util::GetStringFUTF16(
615 IDS_EXTENSION_CANT_INSTALL_IN_DEVICE_LOCAL_ACCOUNT, 619 IDS_EXTENSION_CANT_INSTALL_IN_DEVICE_LOCAL_ACCOUNT,
616 base::UTF8ToUTF16(extension->name()), 620 base::UTF8ToUTF16(extension->name()),
617 base::UTF8ToUTF16(extension->id())); 621 base::UTF8ToUTF16(extension->id()));
618 } 622 }
619 return false; 623 return false;
620 } 624 }
621 625
622 } // namespace chromeos 626 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698