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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 12316077: Move the parsing of app.launch related keys out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "chrome/browser/prefs/browser_prefs.h" 57 #include "chrome/browser/prefs/browser_prefs.h"
58 #include "chrome/browser/prefs/pref_service_mock_builder.h" 58 #include "chrome/browser/prefs/pref_service_mock_builder.h"
59 #include "chrome/browser/prefs/pref_service_syncable.h" 59 #include "chrome/browser/prefs/pref_service_syncable.h"
60 #include "chrome/browser/prefs/scoped_user_pref_update.h" 60 #include "chrome/browser/prefs/scoped_user_pref_update.h"
61 #include "chrome/common/chrome_constants.h" 61 #include "chrome/common/chrome_constants.h"
62 #include "chrome/common/chrome_notification_types.h" 62 #include "chrome/common/chrome_notification_types.h"
63 #include "chrome/common/chrome_paths.h" 63 #include "chrome/common/chrome_paths.h"
64 #include "chrome/common/chrome_switches.h" 64 #include "chrome/common/chrome_switches.h"
65 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" 65 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
66 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 66 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
67 #include "chrome/common/extensions/app_launcher_info.h"
67 #include "chrome/common/extensions/background_info.h" 68 #include "chrome/common/extensions/background_info.h"
68 #include "chrome/common/extensions/extension.h" 69 #include "chrome/common/extensions/extension.h"
69 #include "chrome/common/extensions/extension_l10n_util.h" 70 #include "chrome/common/extensions/extension_l10n_util.h"
70 #include "chrome/common/extensions/extension_manifest_constants.h" 71 #include "chrome/common/extensions/extension_manifest_constants.h"
71 #include "chrome/common/extensions/extension_resource.h" 72 #include "chrome/common/extensions/extension_resource.h"
72 #include "chrome/common/extensions/manifest_handler.h" 73 #include "chrome/common/extensions/manifest_handler.h"
73 #include "chrome/common/extensions/manifest_url_handler.h" 74 #include "chrome/common/extensions/manifest_url_handler.h"
74 #include "chrome/common/extensions/permissions/permission_set.h" 75 #include "chrome/common/extensions/permissions/permission_set.h"
75 #include "chrome/common/pref_names.h" 76 #include "chrome/common/pref_names.h"
76 #include "chrome/common/url_constants.h" 77 #include "chrome/common/url_constants.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 540 }
540 541
541 // static 542 // static
542 void ExtensionServiceTestBase::SetUpTestCase() { 543 void ExtensionServiceTestBase::SetUpTestCase() {
543 ExtensionErrorReporter::Init(false); // no noisy errors 544 ExtensionErrorReporter::Init(false); // no noisy errors
544 } 545 }
545 546
546 void ExtensionServiceTestBase::SetUp() { 547 void ExtensionServiceTestBase::SetUp() {
547 testing::Test::SetUp(); 548 testing::Test::SetUp();
548 ExtensionErrorReporter::GetInstance()->ClearErrors(); 549 ExtensionErrorReporter::GetInstance()->ClearErrors();
550 (new extensions::AppLaunchManifestHandler)->Register();
549 (new extensions::BackgroundManifestHandler)->Register(); 551 (new extensions::BackgroundManifestHandler)->Register();
550 (new extensions::DefaultLocaleHandler)->Register(); 552 (new extensions::DefaultLocaleHandler)->Register();
551 (new extensions::PluginsHandler)->Register(); 553 (new extensions::PluginsHandler)->Register();
552 } 554 }
553 555
554 void ExtensionServiceTestBase::TearDown() { 556 void ExtensionServiceTestBase::TearDown() {
555 extensions::ManifestHandler::ClearRegistryForTesting(); 557 extensions::ManifestHandler::ClearRegistryForTesting();
556 } 558 }
557 559
558 class ExtensionServiceTest 560 class ExtensionServiceTest
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 2337
2336 // Install app1 with unlimited storage. 2338 // Install app1 with unlimited storage.
2337 const Extension* extension = 2339 const Extension* extension =
2338 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 2340 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
2339 ValidatePrefKeyCount(++pref_count); 2341 ValidatePrefKeyCount(++pref_count);
2340 ASSERT_EQ(1u, service_->extensions()->size()); 2342 ASSERT_EQ(1u, service_->extensions()->size());
2341 const std::string id1 = extension->id(); 2343 const std::string id1 = extension->id();
2342 EXPECT_TRUE(extension->HasAPIPermission( 2344 EXPECT_TRUE(extension->HasAPIPermission(
2343 APIPermission::kUnlimitedStorage)); 2345 APIPermission::kUnlimitedStorage));
2344 EXPECT_TRUE(extension->web_extent().MatchesURL( 2346 EXPECT_TRUE(extension->web_extent().MatchesURL(
2345 extension->GetFullLaunchURL())); 2347 extensions::AppLauncherInfo::GetFullLaunchURL(extension)));
2346 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); 2348 const GURL origin1(
2349 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
2347 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2350 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2348 IsStorageUnlimited(origin1)); 2351 IsStorageUnlimited(origin1));
2349 2352
2350 // Install app2 from the same origin with unlimited storage. 2353 // Install app2 from the same origin with unlimited storage.
2351 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 2354 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
2352 ValidatePrefKeyCount(++pref_count); 2355 ValidatePrefKeyCount(++pref_count);
2353 ASSERT_EQ(2u, service_->extensions()->size()); 2356 ASSERT_EQ(2u, service_->extensions()->size());
2354 const std::string id2 = extension->id(); 2357 const std::string id2 = extension->id();
2355 EXPECT_TRUE(extension->HasAPIPermission( 2358 EXPECT_TRUE(extension->HasAPIPermission(
2356 APIPermission::kUnlimitedStorage)); 2359 APIPermission::kUnlimitedStorage));
2357 EXPECT_TRUE(extension->web_extent().MatchesURL( 2360 EXPECT_TRUE(extension->web_extent().MatchesURL(
2358 extension->GetFullLaunchURL())); 2361 extensions::AppLauncherInfo::GetFullLaunchURL(extension)));
2359 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); 2362 const GURL origin2(
2363 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
2360 EXPECT_EQ(origin1, origin2); 2364 EXPECT_EQ(origin1, origin2);
2361 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2365 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2362 IsStorageUnlimited(origin2)); 2366 IsStorageUnlimited(origin2));
2363 2367
2364 2368
2365 // Uninstall one of them, unlimited storage should still be granted 2369 // Uninstall one of them, unlimited storage should still be granted
2366 // to the origin. 2370 // to the origin.
2367 UninstallExtension(id1, false); 2371 UninstallExtension(id1, false);
2368 EXPECT_EQ(1u, service_->extensions()->size()); 2372 EXPECT_EQ(1u, service_->extensions()->size());
2369 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2373 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
(...skipping 12 matching lines...) Expand all
2382 EXPECT_TRUE(service_->extensions()->is_empty()); 2386 EXPECT_TRUE(service_->extensions()->is_empty());
2383 2387
2384 int pref_count = 0; 2388 int pref_count = 0;
2385 2389
2386 const Extension* extension = 2390 const Extension* extension =
2387 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 2391 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
2388 ValidatePrefKeyCount(++pref_count); 2392 ValidatePrefKeyCount(++pref_count);
2389 ASSERT_EQ(1u, service_->extensions()->size()); 2393 ASSERT_EQ(1u, service_->extensions()->size());
2390 EXPECT_TRUE(extension->is_app()); 2394 EXPECT_TRUE(extension->is_app());
2391 const std::string id1 = extension->id(); 2395 const std::string id1 = extension->id();
2392 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); 2396 const GURL origin1(
2397 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
2393 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2398 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2394 IsStorageProtected(origin1)); 2399 IsStorageProtected(origin1));
2395 2400
2396 // App 4 has a different origin (maps.google.com). 2401 // App 4 has a different origin (maps.google.com).
2397 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW); 2402 extension = PackAndInstallCRX(data_dir_.AppendASCII("app4"), INSTALL_NEW);
2398 ValidatePrefKeyCount(++pref_count); 2403 ValidatePrefKeyCount(++pref_count);
2399 ASSERT_EQ(2u, service_->extensions()->size()); 2404 ASSERT_EQ(2u, service_->extensions()->size());
2400 const std::string id2 = extension->id(); 2405 const std::string id2 = extension->id();
2401 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); 2406 const GURL origin2(
2407 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
2402 ASSERT_NE(origin1, origin2); 2408 ASSERT_NE(origin1, origin2);
2403 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 2409 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
2404 IsStorageProtected(origin2)); 2410 IsStorageProtected(origin2));
2405 2411
2406 UninstallExtension(id1, false); 2412 UninstallExtension(id1, false);
2407 EXPECT_EQ(1u, service_->extensions()->size()); 2413 EXPECT_EQ(1u, service_->extensions()->size());
2408 2414
2409 UninstallExtension(id2, false); 2415 UninstallExtension(id2, false);
2410 2416
2411 EXPECT_TRUE(service_->extensions()->is_empty()); 2417 EXPECT_TRUE(service_->extensions()->is_empty());
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
3895 int pref_count = 0; 3901 int pref_count = 0;
3896 3902
3897 // Install app1 with unlimited storage. 3903 // Install app1 with unlimited storage.
3898 const Extension* extension = 3904 const Extension* extension =
3899 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW); 3905 PackAndInstallCRX(data_dir_.AppendASCII("app1"), INSTALL_NEW);
3900 ValidatePrefKeyCount(++pref_count); 3906 ValidatePrefKeyCount(++pref_count);
3901 ASSERT_EQ(1u, service_->extensions()->size()); 3907 ASSERT_EQ(1u, service_->extensions()->size());
3902 const std::string id1 = extension->id(); 3908 const std::string id1 = extension->id();
3903 EXPECT_TRUE(extension->HasAPIPermission( 3909 EXPECT_TRUE(extension->HasAPIPermission(
3904 APIPermission::kUnlimitedStorage)); 3910 APIPermission::kUnlimitedStorage));
3905 const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); 3911 const GURL origin1(
3912 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
3906 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 3913 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
3907 IsStorageUnlimited(origin1)); 3914 IsStorageUnlimited(origin1));
3908 string16 origin_id = 3915 string16 origin_id =
3909 webkit_database::DatabaseUtil::GetOriginIdentifier(origin1); 3916 webkit_database::DatabaseUtil::GetOriginIdentifier(origin1);
3910 3917
3911 // Install app2 from the same origin with unlimited storage. 3918 // Install app2 from the same origin with unlimited storage.
3912 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 3919 extension = PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
3913 ValidatePrefKeyCount(++pref_count); 3920 ValidatePrefKeyCount(++pref_count);
3914 ASSERT_EQ(2u, service_->extensions()->size()); 3921 ASSERT_EQ(2u, service_->extensions()->size());
3915 const std::string id2 = extension->id(); 3922 const std::string id2 = extension->id();
3916 EXPECT_TRUE(extension->HasAPIPermission( 3923 EXPECT_TRUE(extension->HasAPIPermission(
3917 APIPermission::kUnlimitedStorage)); 3924 APIPermission::kUnlimitedStorage));
3918 EXPECT_TRUE(extension->web_extent().MatchesURL( 3925 EXPECT_TRUE(extension->web_extent().MatchesURL(
3919 extension->GetFullLaunchURL())); 3926 extensions::AppLauncherInfo::GetFullLaunchURL(extension)));
3920 const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); 3927 const GURL origin2(
3928 extensions::AppLauncherInfo::GetFullLaunchURL(extension).GetOrigin());
3921 EXPECT_EQ(origin1, origin2); 3929 EXPECT_EQ(origin1, origin2);
3922 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 3930 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
3923 IsStorageUnlimited(origin2)); 3931 IsStorageUnlimited(origin2));
3924 3932
3925 // Set a cookie for the extension. 3933 // Set a cookie for the extension.
3926 net::CookieMonster* cookie_monster = 3934 net::CookieMonster* cookie_monster =
3927 profile_->GetRequestContext()->GetURLRequestContext()-> 3935 profile_->GetRequestContext()->GetURLRequestContext()->
3928 cookie_store()->GetCookieMonster(); 3936 cookie_store()->GetCookieMonster();
3929 ASSERT_TRUE(cookie_monster); 3937 ASSERT_TRUE(cookie_monster);
3930 net::CookieOptions options; 3938 net::CookieOptions options;
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
5893 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5901 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5894 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); 5902 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
5895 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); 5903 EXPECT_TRUE(service_->IsExtensionEnabled(page_action));
5896 5904
5897 ExtensionPrefs* prefs = service_->extension_prefs(); 5905 ExtensionPrefs* prefs = service_->extension_prefs();
5898 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & 5906 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) &
5899 Extension::DISABLE_SIDELOAD_WIPEOUT); 5907 Extension::DISABLE_SIDELOAD_WIPEOUT);
5900 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & 5908 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) &
5901 Extension::DISABLE_SIDELOAD_WIPEOUT); 5909 Extension::DISABLE_SIDELOAD_WIPEOUT);
5902 } 5910 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698