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

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

Issue 2450623002: [MD Bookmarks] Add skeleton for Material Design Bookmarks (Closed)
Patch Set: Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/component_loader.h" 5 #include "chrome/browser/extensions/component_loader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" 17 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h"
18 #include "chrome/browser/extensions/data_deleter.h" 18 #include "chrome/browser/extensions/data_deleter.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/pdf/pdf_extension_util.h" 20 #include "chrome/browser/pdf/pdf_extension_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/search/hotword_service.h" 22 #include "chrome/browser/search/hotword_service.h"
23 #include "chrome/browser/search/hotword_service_factory.h" 23 #include "chrome/browser/search/hotword_service_factory.h"
24 #include "chrome/common/channel_info.h" 24 #include "chrome/common/channel_info.h"
25 #include "chrome/common/chrome_features.h"
25 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/extensions/extension_constants.h" 28 #include "chrome/common/extensions/extension_constants.h"
28 #include "chrome/common/features.h" 29 #include "chrome/common/features.h"
29 #include "chrome/grit/browser_resources.h" 30 #include "chrome/grit/browser_resources.h"
30 #include "chrome/grit/chromium_strings.h" 31 #include "chrome/grit/chromium_strings.h"
31 #include "chrome/grit/generated_resources.h" 32 #include "chrome/grit/generated_resources.h"
32 #include "components/crx_file/id_util.h" 33 #include "components/crx_file/id_util.h"
33 #include "components/version_info/version_info.h" 34 #include "components/version_info/version_info.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 101
101 bool IsNormalSession() { 102 bool IsNormalSession() {
102 return !base::CommandLine::ForCurrentProcess()->HasSwitch( 103 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
103 chromeos::switches::kGuestSession) && 104 chromeos::switches::kGuestSession) &&
104 user_manager::UserManager::IsInitialized() && 105 user_manager::UserManager::IsInitialized() &&
105 user_manager::UserManager::Get()->IsUserLoggedIn(); 106 user_manager::UserManager::Get()->IsUserLoggedIn();
106 } 107 }
107 #endif // defined(OS_CHROMEOS) 108 #endif // defined(OS_CHROMEOS)
108 109
110 bool IsMaterialDesignBookmarksEnabled() {
111 return base::FeatureList::IsEnabled(features::kMaterialDesignBookmarks);
112 }
113
109 } // namespace 114 } // namespace
110 115
111 ComponentLoader::ComponentExtensionInfo::ComponentExtensionInfo( 116 ComponentLoader::ComponentExtensionInfo::ComponentExtensionInfo(
112 const base::DictionaryValue* manifest, const base::FilePath& directory) 117 const base::DictionaryValue* manifest, const base::FilePath& directory)
113 : manifest(manifest), 118 : manifest(manifest),
114 root_directory(directory) { 119 root_directory(directory) {
115 if (!root_directory.IsAbsolute()) { 120 if (!root_directory.IsAbsolute()) {
116 CHECK(PathService::Get(chrome::DIR_RESOURCES, &root_directory)); 121 CHECK(PathService::Get(chrome::DIR_RESOURCES, &root_directory));
117 root_directory = root_directory.Append(directory); 122 root_directory = root_directory.Append(directory);
118 } 123 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 utf8_error); 452 utf8_error);
448 } 453 }
449 454
450 // static 455 // static
451 void ComponentLoader::EnableBackgroundExtensionsForTesting() { 456 void ComponentLoader::EnableBackgroundExtensionsForTesting() {
452 enable_background_extensions_during_testing = true; 457 enable_background_extensions_during_testing = true;
453 } 458 }
454 459
455 void ComponentLoader::AddDefaultComponentExtensions( 460 void ComponentLoader::AddDefaultComponentExtensions(
456 bool skip_session_components) { 461 bool skip_session_components) {
462 base::FilePath bookmarks_path(IsMaterialDesignBookmarksEnabled()
463 ? FILE_PATH_LITERAL("md_bookmarks")
464 : FILE_PATH_LITERAL("bookmark_manager"));
465 int bookmark_manifest_id = IsMaterialDesignBookmarksEnabled()
Dan Beam 2016/10/25 18:05:51 can we cache this result? also, can we just do th
calamity 2016/10/28 05:58:22 Done.
466 ? IDR_MD_BOOKMARKS_MANIFEST
467 : IDR_BOOKMARKS_MANIFEST;
468
457 // Do not add component extensions that have background pages here -- add them 469 // Do not add component extensions that have background pages here -- add them
458 // to AddDefaultComponentExtensionsWithBackgroundPages. 470 // to AddDefaultComponentExtensionsWithBackgroundPages.
459 #if defined(OS_CHROMEOS) 471 #if defined(OS_CHROMEOS)
460 Add(IDR_MOBILE_MANIFEST, 472 Add(IDR_MOBILE_MANIFEST,
461 base::FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/mobile"))); 473 base::FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/mobile")));
462 474
463 #if defined(GOOGLE_CHROME_BUILD) 475 #if defined(GOOGLE_CHROME_BUILD)
464 if (browser_defaults::enable_help_app) { 476 if (browser_defaults::enable_help_app) {
465 Add(IDR_HELP_MANIFEST, base::FilePath(FILE_PATH_LITERAL( 477 Add(IDR_HELP_MANIFEST, base::FilePath(FILE_PATH_LITERAL(
466 "/usr/share/chromeos-assets/helpapp"))); 478 "/usr/share/chromeos-assets/helpapp")));
467 } 479 }
468 #endif // defined(GOOGLE_CHROME_BUILD) 480 #endif // defined(GOOGLE_CHROME_BUILD)
469 481
470 // Skip all other extensions that require user session presence. 482 // Skip all other extensions that require user session presence.
471 if (!skip_session_components) { 483 if (!skip_session_components) {
472 const base::CommandLine* command_line = 484 const base::CommandLine* command_line =
473 base::CommandLine::ForCurrentProcess(); 485 base::CommandLine::ForCurrentProcess();
474 if (!command_line->HasSwitch(chromeos::switches::kGuestSession)) 486 if (!command_line->HasSwitch(chromeos::switches::kGuestSession))
475 Add(IDR_BOOKMARKS_MANIFEST, 487 Add(bookmark_manifest_id, bookmarks_path);
476 base::FilePath(FILE_PATH_LITERAL("bookmark_manager")));
477 488
478 Add(IDR_CROSH_BUILTIN_MANIFEST, base::FilePath(FILE_PATH_LITERAL( 489 Add(IDR_CROSH_BUILTIN_MANIFEST, base::FilePath(FILE_PATH_LITERAL(
479 "/usr/share/chromeos-assets/crosh_builtin"))); 490 "/usr/share/chromeos-assets/crosh_builtin")));
480 } 491 }
481 #else // defined(OS_CHROMEOS) 492 #else // defined(OS_CHROMEOS)
482 DCHECK(!skip_session_components); 493 DCHECK(!skip_session_components);
483 Add(IDR_BOOKMARKS_MANIFEST, 494 Add(bookmark_manifest_id, bookmarks_path);
484 base::FilePath(FILE_PATH_LITERAL("bookmark_manager")));
485 #if defined(ENABLE_PRINTING) 495 #if defined(ENABLE_PRINTING)
486 // Cloud Print component app. Not required on Chrome OS. 496 // Cloud Print component app. Not required on Chrome OS.
487 Add(IDR_CLOUDPRINT_MANIFEST, 497 Add(IDR_CLOUDPRINT_MANIFEST,
488 base::FilePath(FILE_PATH_LITERAL("cloud_print"))); 498 base::FilePath(FILE_PATH_LITERAL("cloud_print")));
489 #endif // defined(ENABLE_PRINTING) 499 #endif // defined(ENABLE_PRINTING)
490 #endif // defined(OS_CHROMEOS) 500 #endif // defined(OS_CHROMEOS)
491 501
492 if (!skip_session_components) { 502 if (!skip_session_components) {
493 AddWebStoreApp(); 503 AddWebStoreApp();
494 AddChromeApp(); 504 AddChromeApp();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 manifest.release(), 700 manifest.release(),
691 root_directory, 701 root_directory,
692 false); 702 false);
693 CHECK_EQ(extension_id, actual_extension_id); 703 CHECK_EQ(extension_id, actual_extension_id);
694 if (!done_cb.is_null()) 704 if (!done_cb.is_null())
695 done_cb.Run(); 705 done_cb.Run();
696 } 706 }
697 #endif 707 #endif
698 708
699 } // namespace extensions 709 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698