chromium 启动页设置

启动页的设置方式有:

  1.  chrome.exe http://www.baidu.com  
  2. 但是由于所带的参数 不能打开webUI页面 

所以我们需要改启动页的起始设置

 

启动页写入文件在

Default\Secure Preferenceschromium 启动页设置

// An integer pref. Holds one of several values:
// 0: unused, previously indicated to open the homepage on startup
// 1: restore the last session.
// 2: this was used to indicate a specific session should be restored. It is
//    no longer used, but saved to avoid conflict with old preferences.
// 3: unused, previously indicated the user wants to restore a saved session.
// 4: restore the URLs defined in kURLsToRestoreOnStartup.
// 5: open the New Tab Page on startup.
const char kRestoreOnStartup[] = "session.restore_on_startup";

// The URLs to restore on startup or when the home button is pressed. The URLs
// are only restored on startup if kRestoreOnStartup is 4.
const char kURLsToRestoreOnStartup[] = "session.startup_urls";

 

所以 我们很清楚的知道打开特定网页或者一组网页时是4

kRestoreOnStartup = 4

kURLsToRestoreOnStartup = ["chrome://security-check"...........];

诸如此类的

对应下面这个

chromium 启动页设置

所以我们需要找到代码设置这里

可以通过这个webUI页定位到相对应的位置

src\chrome\browser\prefs\session_startup_pref.cc 

就是关于启动页设置的类  所以主要就是修改它

在src\chrome\browser\chrome_browser_main.cc    

刚开始肯定要初始化那些文件之类的所以要在那些文件设置完成之后再修改

chromium 启动页设置

 

代码:

 //这边启动页面是要设置得...如果说有店铺得名字 表示的是通过打开店铺的 所以要打开webUI
  const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  if (command_line->HasSwitch(switches::kStoreName)) {
    PrefService* prefs = profile_->GetPrefs();
    SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
    pref.type = SessionStartupPref::URLS;
    if (pref.urls.size()< 1)
      pref.urls.push_back(GURL("chrome://security-check/"));
    SessionStartupPref::SetStartupPref(prefs, pref);
  }
 

我这里是90.0.4430.212 版本

chromium 启动页设置

上一篇:Electron 实现最小化到托盘


下一篇:idea2020 设置Run Dashboard