OLD | NEW |
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/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
14 #include "base/synchronization/cancellation_flag.h" | 14 #include "base/synchronization/cancellation_flag.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
17 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
18 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
19 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 19 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/google/google_url_tracker_factory.h" | 21 #include "chrome/browser/google/google_url_tracker_factory.h" |
22 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" | 22 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/search_engines/template_url_service_factory.h" | 24 #include "chrome/browser/search_engines/template_url_service_factory.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_iterator.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 29 #include "chrome/installer/util/browser_distribution.h" |
30 #include "components/content_settings/core/browser/content_settings_info.h" | 30 #include "components/content_settings/core/browser/content_settings_info.h" |
31 #include "components/content_settings/core/browser/content_settings_registry.h" | 31 #include "components/content_settings/core/browser/content_settings_registry.h" |
32 #include "components/content_settings/core/browser/host_content_settings_map.h" | 32 #include "components/content_settings/core/browser/host_content_settings_map.h" |
33 #include "components/content_settings/core/browser/website_settings_info.h" | 33 #include "components/content_settings/core/browser/website_settings_info.h" |
34 #include "components/content_settings/core/browser/website_settings_registry.h" | 34 #include "components/content_settings/core/browser/website_settings_registry.h" |
35 #include "components/google/core/browser/google_url_tracker.h" | 35 #include "components/google/core/browser/google_url_tracker.h" |
36 #include "components/search_engines/search_engines_pref_names.h" | 36 #include "components/search_engines/search_engines_pref_names.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (master_settings_->GetRestoreOnStartup(&restore_on_startup)) | 288 if (master_settings_->GetRestoreOnStartup(&restore_on_startup)) |
289 prefs->SetInteger(prefs::kRestoreOnStartup, restore_on_startup); | 289 prefs->SetInteger(prefs::kRestoreOnStartup, restore_on_startup); |
290 else | 290 else |
291 prefs->ClearPref(prefs::kRestoreOnStartup); | 291 prefs->ClearPref(prefs::kRestoreOnStartup); |
292 | 292 |
293 MarkAsDone(STARTUP_PAGES); | 293 MarkAsDone(STARTUP_PAGES); |
294 } | 294 } |
295 | 295 |
296 void ProfileResetter::ResetPinnedTabs() { | 296 void ProfileResetter::ResetPinnedTabs() { |
297 // Unpin all the tabs. | 297 // Unpin all the tabs. |
298 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 298 for (auto* browser : *BrowserList::GetInstance()) { |
299 if (it->is_type_tabbed() && it->profile() == profile_) { | 299 if (browser->is_type_tabbed() && browser->profile() == profile_) { |
300 TabStripModel* tab_model = it->tab_strip_model(); | 300 TabStripModel* tab_model = browser->tab_strip_model(); |
301 // Here we assume that indexof(any mini tab) < indexof(any normal tab). | 301 // Here we assume that indexof(any mini tab) < indexof(any normal tab). |
302 // If we unpin the tab, it can be moved to the right. Thus traversing in | 302 // If we unpin the tab, it can be moved to the right. Thus traversing in |
303 // reverse direction is correct. | 303 // reverse direction is correct. |
304 for (int i = tab_model->count() - 1; i >= 0; --i) { | 304 for (int i = tab_model->count() - 1; i >= 0; --i) { |
305 if (tab_model->IsTabPinned(i)) | 305 if (tab_model->IsTabPinned(i)) |
306 tab_model->SetTabPinned(i, false); | 306 tab_model->SetTabPinned(i, false); |
307 } | 307 } |
308 } | 308 } |
309 } | 309 } |
310 MarkAsDone(PINNED_TABS); | 310 MarkAsDone(PINNED_TABS); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 chrome_exe, | 361 chrome_exe, |
362 false, | 362 false, |
363 cancel, | 363 cancel, |
364 &shortcuts); | 364 &shortcuts); |
365 } | 365 } |
366 return shortcuts; | 366 return shortcuts; |
367 #else | 367 #else |
368 return std::vector<ShortcutCommand>(); | 368 return std::vector<ShortcutCommand>(); |
369 #endif | 369 #endif |
370 } | 370 } |
OLD | NEW |