| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 | 6 |
| 7 #include "chrome/browser/views/frame/browser_view.h" | 7 #include "chrome/browser/views/frame/browser_view.h" |
| 8 | 8 |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // |command| can be zero on submenu items (IDS_ENCODING, | 399 // |command| can be zero on submenu items (IDS_ENCODING, |
| 400 // IDS_ZOOM) and on separators. | 400 // IDS_ZOOM) and on separators. |
| 401 if (command != 0) { | 401 if (command != 0) { |
| 402 system_menu_->EnableMenuItemByID( | 402 system_menu_->EnableMenuItemByID( |
| 403 command, | 403 command, |
| 404 browser_->command_updater()->IsCommandEnabled(command)); | 404 browser_->command_updater()->IsCommandEnabled(command)); |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool BrowserView::SupportsWindowFeature(WindowFeature feature) const { | |
| 410 const Browser::Type type = browser_->type(); | |
| 411 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; | |
| 412 if (type == Browser::TYPE_NORMAL) | |
| 413 features |= FEATURE_BOOKMARKBAR; | |
| 414 if (!fullscreen_) { | |
| 415 if (type == Browser::TYPE_NORMAL) | |
| 416 features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR; | |
| 417 else | |
| 418 features |= FEATURE_TITLEBAR; | |
| 419 if (type != Browser::TYPE_APP) | |
| 420 features |= FEATURE_LOCATIONBAR; | |
| 421 } | |
| 422 return !!(features & feature); | |
| 423 } | |
| 424 | |
| 425 // static | 409 // static |
| 426 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { | 410 void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { |
| 427 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, | 411 prefs->RegisterIntegerPref(prefs::kPluginMessageResponseTimeout, |
| 428 kDefaultPluginMessageResponseTimeout); | 412 kDefaultPluginMessageResponseTimeout); |
| 429 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, | 413 prefs->RegisterIntegerPref(prefs::kHungPluginDetectFrequency, |
| 430 kDefaultHungPluginDetectFrequency); | 414 kDefaultHungPluginDetectFrequency); |
| 431 } | 415 } |
| 432 | 416 |
| 433 /////////////////////////////////////////////////////////////////////////////// | 417 /////////////////////////////////////////////////////////////////////////////// |
| 434 // BrowserView, BrowserWindow implementation: | 418 // BrowserView, BrowserWindow implementation: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 600 |
| 617 // Notify bookmark bar, so it can set itself to the appropriate drawing state. | 601 // Notify bookmark bar, so it can set itself to the appropriate drawing state. |
| 618 if (bookmark_bar_view_.get()) | 602 if (bookmark_bar_view_.get()) |
| 619 bookmark_bar_view_->OnFullscreenToggled(fullscreen_); | 603 bookmark_bar_view_->OnFullscreenToggled(fullscreen_); |
| 620 | 604 |
| 621 // Size/position/style window appropriately. | 605 // Size/position/style window appropriately. |
| 622 views::Widget* widget = GetWidget(); | 606 views::Widget* widget = GetWidget(); |
| 623 HWND hwnd = widget->GetHWND(); | 607 HWND hwnd = widget->GetHWND(); |
| 624 if (fullscreen_) { | 608 if (fullscreen_) { |
| 625 // Save current window information. We force the window into restored mode | 609 // Save current window information. We force the window into restored mode |
| 626 // before going fuillscreen because Windows doesn't seem to hide the | 610 // before going fullscreen because Windows doesn't seem to hide the |
| 627 // taskbar if the window is in the maximized state. | 611 // taskbar if the window is in the maximized state. |
| 628 saved_window_info_.maximized = IsMaximized(); | 612 saved_window_info_.maximized = IsMaximized(); |
| 629 if (saved_window_info_.maximized) | 613 if (saved_window_info_.maximized) |
| 630 frame_->GetWindow()->ExecuteSystemMenuCommand(SC_RESTORE); | 614 frame_->GetWindow()->ExecuteSystemMenuCommand(SC_RESTORE); |
| 631 saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE); | 615 saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE); |
| 632 saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); | 616 saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); |
| 633 GetWindowRect(hwnd, &saved_window_info_.window_rect); | 617 GetWindowRect(hwnd, &saved_window_info_.window_rect); |
| 634 | 618 |
| 635 // Set new window style and size. | 619 // Set new window style and size. |
| 636 SetWindowLong(hwnd, GWL_STYLE, | 620 SetWindowLong(hwnd, GWL_STYLE, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 | 1003 |
| 1020 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { | 1004 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { |
| 1021 *bounds = browser_->GetSavedWindowBounds(); | 1005 *bounds = browser_->GetSavedWindowBounds(); |
| 1022 if (browser_->type() == Browser::TYPE_POPUP) { | 1006 if (browser_->type() == Browser::TYPE_POPUP) { |
| 1023 // We are a popup window. The value passed in |bounds| represents two | 1007 // We are a popup window. The value passed in |bounds| represents two |
| 1024 // pieces of information: | 1008 // pieces of information: |
| 1025 // - the position of the window, in screen coordinates (outer position). | 1009 // - the position of the window, in screen coordinates (outer position). |
| 1026 // - the size of the content area (inner size). | 1010 // - the size of the content area (inner size). |
| 1027 // We need to use these values to determine the appropriate size and | 1011 // We need to use these values to determine the appropriate size and |
| 1028 // position of the resulting window. | 1012 // position of the resulting window. |
| 1029 if (SupportsWindowFeature(FEATURE_TOOLBAR) || | 1013 if (IsToolbarVisible()) { |
| 1030 SupportsWindowFeature(FEATURE_LOCATIONBAR)) { | |
| 1031 // If we're showing the toolbar, we need to adjust |*bounds| to include | 1014 // If we're showing the toolbar, we need to adjust |*bounds| to include |
| 1032 // its desired height, since the toolbar is considered part of the | 1015 // its desired height, since the toolbar is considered part of the |
| 1033 // window's client area as far as GetWindowBoundsForClientBounds is | 1016 // window's client area as far as GetWindowBoundsForClientBounds is |
| 1034 // concerned... | 1017 // concerned... |
| 1035 bounds->set_height( | 1018 bounds->set_height( |
| 1036 bounds->height() + toolbar_->GetPreferredSize().height()); | 1019 bounds->height() + toolbar_->GetPreferredSize().height()); |
| 1037 } | 1020 } |
| 1038 | 1021 |
| 1039 gfx::Rect window_rect = frame_->GetWindowBoundsForClientBounds(*bounds); | 1022 gfx::Rect window_rect = frame_->GetWindowBoundsForClientBounds(*bounds); |
| 1040 window_rect.set_origin(bounds->origin()); | 1023 window_rect.set_origin(bounds->origin()); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 system_menu_->AddSeparator(insertion_index); | 1265 system_menu_->AddSeparator(insertion_index); |
| 1283 system_menu_->AddMenuItemWithLabel(insertion_index, IDC_TASK_MANAGER, | 1266 system_menu_->AddMenuItemWithLabel(insertion_index, IDC_TASK_MANAGER, |
| 1284 l10n_util::GetString(IDS_TASK_MANAGER)); | 1267 l10n_util::GetString(IDS_TASK_MANAGER)); |
| 1285 // If it's a regular browser window with tabs, we don't add any more items, | 1268 // If it's a regular browser window with tabs, we don't add any more items, |
| 1286 // since it already has menus (Page, Chrome). | 1269 // since it already has menus (Page, Chrome). |
| 1287 } else { | 1270 } else { |
| 1288 BuildMenuForTabStriplessWindow(system_menu_.get(), insertion_index); | 1271 BuildMenuForTabStriplessWindow(system_menu_.get(), insertion_index); |
| 1289 } | 1272 } |
| 1290 } | 1273 } |
| 1291 | 1274 |
| 1275 bool BrowserView::SupportsWindowFeature(WindowFeature feature) const { |
| 1276 const Browser::Type type = browser_->type(); |
| 1277 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; |
| 1278 if (type == Browser::TYPE_NORMAL) |
| 1279 features |= FEATURE_BOOKMARKBAR; |
| 1280 if (!fullscreen_) { |
| 1281 if (type == Browser::TYPE_NORMAL) |
| 1282 features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR; |
| 1283 else |
| 1284 features |= FEATURE_TITLEBAR; |
| 1285 if (type != Browser::TYPE_APP) |
| 1286 features |= FEATURE_LOCATIONBAR; |
| 1287 } |
| 1288 return !!(features & feature); |
| 1289 } |
| 1290 |
| 1292 bool BrowserView::ShouldForwardToTabStrip( | 1291 bool BrowserView::ShouldForwardToTabStrip( |
| 1293 const views::DropTargetEvent& event) { | 1292 const views::DropTargetEvent& event) { |
| 1294 if (!tabstrip_->IsVisible()) | 1293 if (!tabstrip_->IsVisible()) |
| 1295 return false; | 1294 return false; |
| 1296 | 1295 |
| 1297 const int tab_y = tabstrip_->y(); | 1296 const int tab_y = tabstrip_->y(); |
| 1298 const int tab_height = tabstrip_->height(); | 1297 const int tab_height = tabstrip_->height(); |
| 1299 if (event.y() >= tab_y + tab_height) | 1298 if (event.y() >= tab_y + tab_height) |
| 1300 return false; | 1299 return false; |
| 1301 | 1300 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 | 1601 |
| 1603 // TODO(pkasting): http://b/1113069 Handle these. | 1602 // TODO(pkasting): http://b/1113069 Handle these. |
| 1604 case APPCOMMAND_UNDO: | 1603 case APPCOMMAND_UNDO: |
| 1605 case APPCOMMAND_REDO: | 1604 case APPCOMMAND_REDO: |
| 1606 case APPCOMMAND_SPELL_CHECK: | 1605 case APPCOMMAND_SPELL_CHECK: |
| 1607 default: return -1; | 1606 default: return -1; |
| 1608 } | 1607 } |
| 1609 } | 1608 } |
| 1610 | 1609 |
| 1611 void BrowserView::LoadingAnimationCallback() { | 1610 void BrowserView::LoadingAnimationCallback() { |
| 1612 if (SupportsWindowFeature(FEATURE_TABSTRIP)) { | 1611 if (browser_->type() == Browser::TYPE_NORMAL) { |
| 1613 // Loading animations are shown in the tab for tabbed windows. | 1612 // Loading animations are shown in the tab for tabbed windows. We check the |
| 1613 // browser type instead of calling IsTabStripVisible() because the latter |
| 1614 // will return false for fullscreen windows, but we still need to update |
| 1615 // their animations (so that when they come out of fullscreen mode they'll |
| 1616 // be correct). |
| 1614 tabstrip_->UpdateLoadingAnimations(); | 1617 tabstrip_->UpdateLoadingAnimations(); |
| 1615 } else if (ShouldShowWindowIcon()) { | 1618 } else if (ShouldShowWindowIcon()) { |
| 1616 // ... or in the window icon area for popups and app windows. | 1619 // ... or in the window icon area for popups and app windows. |
| 1617 TabContents* tab_contents = browser_->GetSelectedTabContents(); | 1620 TabContents* tab_contents = browser_->GetSelectedTabContents(); |
| 1618 // GetSelectedTabContents can return NULL for example under Purify when | 1621 // GetSelectedTabContents can return NULL for example under Purify when |
| 1619 // the animations are running slowly and this function is called on a timer | 1622 // the animations are running slowly and this function is called on a timer |
| 1620 // through LoadingAnimationCallback. | 1623 // through LoadingAnimationCallback. |
| 1621 frame_->UpdateThrobber(tab_contents && tab_contents->is_loading()); | 1624 frame_->UpdateThrobber(tab_contents && tab_contents->is_loading()); |
| 1622 } | 1625 } |
| 1623 } | 1626 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1647 | 1650 |
| 1648 // static | 1651 // static |
| 1649 void BrowserView::InitClass() { | 1652 void BrowserView::InitClass() { |
| 1650 static bool initialized = false; | 1653 static bool initialized = false; |
| 1651 if (!initialized) { | 1654 if (!initialized) { |
| 1652 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1655 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1653 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 1656 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 1654 initialized = true; | 1657 initialized = true; |
| 1655 } | 1658 } |
| 1656 } | 1659 } |
| OLD | NEW |