在上一篇里提到修改谷歌浏览器的四个地方,其实没有什么难度,只要找对了地方,
有一定C++基础的都能搞定。下面列出修改过的关键代码:
1. 关于窗口
关于窗口的源代码文件名是AboutChromeView.cc, 初始化函数为void AboutChromeView::Init()
修改此函数可以自己控制版本等信息的显示。
2. 用户配置文件和缓冲文件的路径改变
此路径原先在操作系统的用户应用程序目录,代码在chrome_pahts.cc,
原先函数是:
- bool GetDefaultUserDataDirectory(std::wstring* result) {
- if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
- return false;
- #if defined(GOOGLE_CHROME_BUILD)
- file_util::AppendToPath(result, L"Google");
- #endif
- file_util::AppendToPath(result, chrome::kBrowserAppName);
- file_util::AppendToPath(result, chrome::kUserDataDirname);
- return true;
- }
改为以下代码实现路径转移到执行目录:
- bool GetDefaultUserDataDirectory(std::wstring* result) {
- if (!PathService::Get(base::FILE_EXE, result))
- return false;
- #if defined(GOOGLE_CHROME_BUILD)
- file_util::AppendToPath(result, L"Google");
- #endif
- std::wstring::size_type index = result->find_last_of(L'//');
- if (index == std::wstring::npos)
- return false;
- *result = result->substr(0, index);
- file_util::AppendToPath(result, chrome::kUserDataDirname);
- return true;
- }
3. 网页文字下划线的绘制
源代码文件是GraphicsContextSkia.cpp,函数static void setrect_for_underline(...)
实现了设置下划线的位置、长度和粗细,若要让下划线下移一个像素,只要Top+1即可。
4. 无法记住最后浏览器最后关闭的状态(最大化或普通窗大小)
首先在文件window.cc中增加一个函数(头文件相应增加函数声明):
- void Window::Show(int command) {
- ShowWindow(command);
- SetInitialFocus();
- }
修改文件browser_view2.cc中的
- void BrowserView2::Show(int command, bool adjust_to_fit) {
- // frame_->GetWindow()->Show(); // 原先的代码
- frame_->GetWindow()->Show(command);// 修改后的代码
- }
以上可以根据自己的需求做相应更多的修改,具体就要看大家的想想力了!