Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.browseractions; | |
| 6 | |
| 7 import android.os.StrictMode; | |
| 8 | |
| 9 import org.chromium.base.Callback; | |
| 10 import org.chromium.base.Log; | |
| 11 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | |
| 12 import org.chromium.chrome.browser.tabmodel.TabPersistencePolicy; | |
| 13 import org.chromium.chrome.browser.tabmodel.TabPersistentStore; | |
| 14 | |
| 15 import java.io.File; | |
| 16 import java.util.List; | |
| 17 import java.util.concurrent.Executor; | |
| 18 | |
| 19 import javax.annotation.Nullable; | |
| 20 | |
| 21 /** | |
| 22 * Handles the Browser Actions Tab specific behaviors of tab persistence. | |
| 23 */ | |
| 24 public class BrowserActionsTabPersistencePolicy implements TabPersistencePolicy { | |
| 25 static final String SAVED_STATE_DIRECTORY = "browser_actions"; | |
| 26 | |
| 27 private static final String TAG = "tabmodel"; | |
| 28 | |
| 29 /** Prevents two state directories from getting created simultaneously. */ | |
| 30 private static final Object DIR_CREATION_LOCK = new Object(); | |
| 31 | |
| 32 private static File sStateDirectory; | |
| 33 | |
| 34 @Override | |
| 35 public File getOrCreateStateDirectory() { | |
|
Yusuf
2017/07/18 22:59:47
so the only current behavior change from the paren
ltian
2017/08/07 23:24:11
To merge the Browser Actions tabs into normal Chro
| |
| 36 return getOrCreateBrowserActionsModeStateDirectory(); | |
| 37 } | |
| 38 | |
| 39 @Override | |
| 40 public String getStateFileName() { | |
| 41 return TabPersistentStore.getStateFileName("0"); | |
| 42 } | |
| 43 | |
| 44 @Override | |
| 45 public boolean shouldMergeOnStartup() { | |
|
Yusuf
2017/07/18 22:59:47
so we are not merging the tabs back in yet? What h
ltian
2017/08/07 23:24:11
Yes, this CL does not deal with tab merging. So if
| |
| 46 return false; | |
| 47 } | |
| 48 | |
| 49 @Override | |
| 50 @Nullable | |
| 51 public String getStateToBeMergedFileName() { | |
| 52 return null; | |
| 53 } | |
| 54 | |
| 55 @Override | |
| 56 public boolean performInitialization(Executor executor) { | |
| 57 return true; | |
| 58 } | |
| 59 | |
| 60 @Override | |
| 61 public void waitForInitializationToFinish() {} | |
| 62 | |
| 63 @Override | |
| 64 public boolean isMergeInProgress() { | |
| 65 return false; | |
| 66 } | |
| 67 | |
| 68 @Override | |
| 69 public void setMergeInProgress(boolean isStarted) { | |
| 70 assert false : "Merge not supported in Browser Actions"; | |
| 71 } | |
| 72 | |
| 73 @Override | |
| 74 public void cancelCleanupInProgress() {} | |
| 75 | |
| 76 @Override | |
| 77 public void cleanupUnusedFiles(Callback<List<String>> filesToDelete) {} | |
| 78 | |
| 79 @Override | |
| 80 public void setTabContentManager(TabContentManager cache) {} | |
| 81 | |
| 82 @Override | |
| 83 public void notifyStateLoaded(int tabCountAtStartup) {} | |
| 84 | |
| 85 @Override | |
| 86 public void destroy() {} | |
| 87 | |
| 88 /** | |
| 89 * The folder where the state should be saved to. | |
| 90 * @return A file representing the directory that contains TabModelSelector states. | |
| 91 */ | |
| 92 public static File getOrCreateBrowserActionsModeStateDirectory() { | |
| 93 synchronized (DIR_CREATION_LOCK) { | |
| 94 if (sStateDirectory == null) { | |
| 95 sStateDirectory = new File( | |
| 96 TabPersistentStore.getOrCreateBaseStateDirectory(), SAVE D_STATE_DIRECTORY); | |
| 97 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWr ites(); | |
| 98 try { | |
| 99 if (!sStateDirectory.exists() && !sStateDirectory.mkdirs()) { | |
| 100 Log.e(TAG, "Failed to create state folder: " + sStateDir ectory); | |
| 101 } | |
| 102 } finally { | |
| 103 StrictMode.setThreadPolicy(oldPolicy); | |
| 104 } | |
| 105 } | |
| 106 } | |
| 107 return sStateDirectory; | |
| 108 } | |
| 109 } | |
| OLD | NEW |