【技术应用】visual studio + chromium 更改代码 去掉地址栏

时间:2024-03-04 21:17:23

看着ie9 firefox opera都效仿tab风格,对比了下,chrome的窗口上面部分还不够小,

干脆把地址栏去掉,F10ALT键,显示隐藏地址栏,

这里是我编译好的程序,喜欢的拿走(26M)

chrome_notoobar_V12.part1

chrome_notoobar_V12.part2 


研究了下代码,更改如下:

 

1、src\chrome\browser\ui\browser.h中

 

//加入一个变量,记录当前 toolbar的显示状态

bool toolbar_visible_;

 

 

2、src\chrome\browser\ui\browser.cc中

 

//构造函数中,给变量赋值

Browser::Browser(Type type, Profile* profile)

    : type_(type),

 toolbar_visible_(false),

 ...

 

---------------------------------------------

//修改SupportsWindowFeatureImpl函数中代码

bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,

                                        bool check_fullscreen) const {

    ...

    if (type() == TYPE_NORMAL && toolbar_visible_==true)

      features |= FEATURE_TOOLBAR;

 

    if ((type() & Browser::TYPE_APP ) == 0 && toolbar_visible_==true)

      features |= FEATURE_LOCATIONBAR;

    ...

---------------------------------------------

//FocusAppMenu函数中修改代码

void Browser::FocusAppMenu() {

 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu"), profile_);

 //:ningth

 toolbar_visible_ = !toolbar_visible_;

 window_->FocusAppMenu();

}

 

3、src\chrome\browser\ui\views\frame\browser_view.cc中

//修改FocusAppMenu中代码

void BrowserView::FocusAppMenu() {

 // Chrome doesn\'t have a traditional menu bar, but it has a menu button in the

 // main toolbar that plays the same role. If the user presses a key that

 // would typically focus the menu bar, tell the toolbar to focus the menu

 // button. If the user presses the key again, return focus to the previous

 // location.

 //

 // Not used on the Mac, which has a normal menu bar.

 

 //:ningth

 Layout();

 

 SetFocusToLocationBar(true);

 /*if (toolbar_->IsAppMenuFocused()) {

    RestoreFocus();

 } else {

    SaveFocusedView();

    toolbar_->SetPaneFocusAndFocusAppMenu(last_focused_view_storage_id_);

 }*/

}

 

 

4、src\chrome\browser\ui\views\frame\browser_view_layout.cc中

修改LayoutToolbar函数中的height值

int BrowserViewLayout::LayoutToolbar(int top) {

 int browser_view_width = vertical_layout_rect_.width();

 bool visible = browser_view_->IsToolbarVisible();;

 toolbar_->location_bar()->SetFocusable(visible);

 int y = top;

 if (!browser_view_->UseVerticalTabs()) {

    y -= ((visible && browser_view_->IsTabStripVisible()) ?

          kToolbarTabStripVerticalOverlap : 0);

 }

 int height = visible ? toolbar_->GetPreferredSize().height() : 1;

 toolbar_->SetVisible(visible);

 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height);

 

 return y + height;

}