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

Side by Side Diff: chrome/browser/first_run/first_run_posix.cc

Issue 12670013: Out-of-process import on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on top of https://codereview.chromium.org/15736014/ Created 7 years, 7 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
« no previous file with comments | « chrome/browser/first_run/first_run_mac.mm ('k') | chrome/browser/first_run/first_run_win.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) 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/first_run/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop.h"
10 #include "base/path_service.h" 9 #include "base/path_service.h"
11 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/first_run/first_run_dialog.h" 12 #include "chrome/browser/first_run/first_run_dialog.h"
15 #include "chrome/browser/first_run/first_run_internal.h" 13 #include "chrome/browser/first_run/first_run_internal.h"
16 #include "chrome/browser/importer/importer_host.h"
17 #include "chrome/browser/importer/importer_list.h"
18 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
22 #include "chrome/common/startup_metric_utils.h" 18 #include "chrome/common/startup_metric_utils.h"
23 #include "chrome/installer/util/google_update_settings.h" 19 #include "chrome/installer/util/google_update_settings.h"
24 #include "chrome/installer/util/master_preferences.h" 20 #include "chrome/installer/util/master_preferences.h"
25 #include "chrome/installer/util/master_preferences_constants.h"
26 21
27 namespace first_run { 22 namespace first_run {
28 namespace internal { 23 namespace internal {
29 24
30 void DoPostImportPlatformSpecificTasks(Profile* profile) { 25 void DoPostImportPlatformSpecificTasks(Profile* profile) {
31 #if !defined(OS_CHROMEOS) 26 #if !defined(OS_CHROMEOS)
32 // Aura needs a views implementation of the first run dialog for Linux. 27 // Aura needs a views implementation of the first run dialog for Linux.
33 // http://crbug.com/234637 28 // http://crbug.com/234637
34 #if !defined(USE_AURA) 29 #if !defined(USE_AURA)
35 base::FilePath local_state_path; 30 base::FilePath local_state_path;
(...skipping 20 matching lines...) Expand all
56 bool GetFirstRunSentinelFilePath(base::FilePath* path) { 51 bool GetFirstRunSentinelFilePath(base::FilePath* path) {
57 base::FilePath first_run_sentinel; 52 base::FilePath first_run_sentinel;
58 53
59 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel)) 54 if (!PathService::Get(chrome::DIR_USER_DATA, &first_run_sentinel))
60 return false; 55 return false;
61 56
62 *path = first_run_sentinel.Append(chrome::kFirstRunSentinel); 57 *path = first_run_sentinel.Append(chrome::kFirstRunSentinel);
63 return true; 58 return true;
64 } 59 }
65 60
66 bool ImportSettings(Profile* profile,
67 ImporterHost* importer_host,
68 scoped_refptr<ImporterList> importer_list,
69 int items_to_import) {
70 const importer::SourceProfile& source_profile =
71 importer_list->GetSourceProfileAt(0);
72
73 // Ensure that importers aren't requested to import items that they do not
74 // support. If there is no overlap, skip.
75 items_to_import &= source_profile.services_supported;
76 if (items_to_import == 0)
77 return true;
78
79 ImportEndedObserver observer;
80 importer_host->SetObserver(&observer);
81 importer_host->StartImportSettings(source_profile,
82 profile,
83 items_to_import,
84 new ProfileWriter(profile));
85 // If the import process has not errored out, block on it.
86 if (!observer.ended()) {
87 observer.set_should_quit_message_loop();
88 MessageLoop::current()->Run();
89 }
90
91 // Unfortunately there's no success/fail signal in ImporterHost.
92 return true;
93 }
94
95 void SetImportPreferencesAndLaunchImport(
96 MasterPrefs* out_prefs,
97 installer::MasterPreferences* install_prefs) {
98 std::string import_bookmarks_path;
99 install_prefs->GetString(
100 installer::master_preferences::kDistroImportBookmarksFromFilePref,
101 &import_bookmarks_path);
102 if (!import_bookmarks_path.empty()) {
103 // There are bookmarks to import from a file.
104 base::FilePath path = base::FilePath::FromWStringHack(UTF8ToWide(
105 import_bookmarks_path));
106 if (!ImportBookmarks(path)) {
107 LOG(WARNING) << "silent bookmark import failed";
108 }
109 }
110 }
111
112 bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) { 61 bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) {
113 // The EULA is only handled on Windows. 62 // The EULA is only handled on Windows.
114 return true; 63 return true;
115 } 64 }
116 65
117 } // namespace internal 66 } // namespace internal
118 } // namespace first_run 67 } // namespace first_run
119
120 namespace first_run {
121
122 // TODO(port): Import switches need to be ported to both Mac and Linux. Not all
123 // import switches here are implemented for Linux. None are implemented for Mac
124 // (as this function will not be called on Mac).
125 int ImportNow(Profile* profile, const CommandLine& cmdline) {
126 return internal::ImportBookmarkFromFileIfNeeded(profile, cmdline);
127 }
128
129 } // namespace first_run
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run_mac.mm ('k') | chrome/browser/first_run/first_run_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698