chromium 去掉打开新的窗口、打开新的无痕窗口、设置、更多工具里面的内容
路径在:
chromium\src\chrome\browser\ui\toolbar\app_menu_model.cc
注释掉
AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); if (ShouldShowNewIncognitoWindowMenuItem()) AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
把这三行就能去掉新的窗口、打开新的无痕窗口
去掉设置
//AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
去掉更多工具里面的内容:
ToolsMenuModel::ToolsMenuModel(ui::SimpleMenuModel::Delegate* delegate, Browser* browser) : SimpleMenuModel(delegate) { //Build(browser); }
这不对....继续,应该是不添加这个类进去
所以,我们搜索ToolsMenuModel相关的都去掉
chromium\src\chrome\browser\ui\toolbar\app_menu_model.h
//class ToolsMenuModel : public ui::SimpleMenuModel { // public: // ToolsMenuModel(ui::SimpleMenuModel::Delegate* delegate, Browser* browser); // ~ToolsMenuModel() override; // private: // void Build(Browser* browser); // // DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel); //};
chromium\src\chrome\browser\ui\toolbar\app_menu_model.cc
//////////////////////////////////////////////////////////////////////////////// // ToolsMenuModel //ToolsMenuModel::ToolsMenuModel(ui::SimpleMenuModel::Delegate* delegate, // Browser* browser) // : SimpleMenuModel(delegate) { // //Build(browser); //} // //ToolsMenuModel::~ToolsMenuModel() {} // //// More tools submenu is constructed as follows: //// - Page specific actions overflow (save page, adding to desktop). //// - Browser / OS level tools (extensions, task manager). //// - Developer tools. //// - Option to enable profiling. //void ToolsMenuModel::Build(Browser* browser) { // AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); // AddItemWithStringId(IDC_CREATE_SHORTCUT, IDS_ADD_TO_OS_LAUNCH_SURFACE); // if (base::FeatureList::IsEnabled(features::kWindowNaming)) // AddItemWithStringId(IDC_NAME_WINDOW, IDS_NAME_WINDOW); // // AddSeparator(ui::NORMAL_SEPARATOR); // AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); // AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); // if (chrome::CanOpenTaskManager()) // AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); //#if BUILDFLAG(IS_CHROMEOS_ASH) // AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); //#endif // AddSeparator(ui::NORMAL_SEPARATOR); // AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); // // if (base::debug::IsProfilingSupported()) { // AddSeparator(ui::NORMAL_SEPARATOR); // AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); // } //}
//sub_menus_.push_back(std::make_unique<ToolsMenuModel>(this, browser_)); //AddSubMenuWithStringId(IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, // sub_menus_.back().get());
完事
去掉设置:
//AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
但是发现 非活动预处理器块....这边先忽略
#if BUILDFLAG(IS_CHROMEOS_ASH) void AppMenuModel::UpdateSettingsItemState() { const base::ListValue* system_features_disable_list_pref = nullptr; PrefService* const local_state = g_browser_process->local_state(); if (local_state) { // Sometimes it's not available in tests. system_features_disable_list_pref = local_state->GetList(policy::policy_prefs::kSystemFeaturesDisableList); } bool is_enabled = !system_features_disable_list_pref || system_features_disable_list_pref->Find( base::Value(policy::SystemFeature::kBrowserSettings)) == system_features_disable_list_pref->end(); int index = GetIndexOfCommandId(IDC_OPTIONS); if (index != -1) SetEnabledAt(index, is_enabled); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) index = GetIndexOfCommandId(IDC_HELP_MENU); if (index != -1) { ui::SimpleMenuModel* help_menu = static_cast<ui::SimpleMenuModel*>(GetSubmenuModelAt(index)); index = help_menu->GetIndexOfCommandId(IDC_ABOUT); if (index != -1) help_menu->SetEnabledAt(index, is_enabled); } #else // BUILDFLAG(GOOGLE_CHROME_BRANDING) index = GetIndexOfCommandId(IDC_ABOUT); if (index != -1) SetEnabledAt(index, is_enabled); #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) } #endif // BUILDFLAG(IS_CHROMEOS_ASH)
还有去掉帮助中心
//#if BUILDFLAG(GOOGLE_CHROME_BRANDING) // sub_menus_.push_back(std::make_unique<HelpMenuModel>(this, browser_)); // AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, sub_menus_.back().get()); //#else //#if BUILDFLAG(IS_CHROMEOS_ASH) // AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); //#else // AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); //#endif //#endif
这边还注释掉了
chromium\src\base\debug\debugger_win.cc
//__debugbreak();
但是有个问题,快捷键那边也要记得去掉,这个后续再操作