OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 return browser_->GetCurrentPageIcon(); | 1547 return browser_->GetCurrentPageIcon(); |
1548 return SkBitmap(); | 1548 return SkBitmap(); |
1549 } | 1549 } |
1550 | 1550 |
1551 bool BrowserView::ShouldShowWindowIcon() const { | 1551 bool BrowserView::ShouldShowWindowIcon() const { |
1552 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1552 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
1553 } | 1553 } |
1554 | 1554 |
1555 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 1555 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
1556 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. | 1556 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
1557 | 1557 #if defined(OS_WIN) |
| 1558 if (command_id == IDC_DEBUG_FRAME_TOGGLE) |
| 1559 GetWindow()->DebugToggleFrameType(); |
| 1560 #endif |
1558 // Translate WM_APPCOMMAND command ids into a command id that the browser | 1561 // Translate WM_APPCOMMAND command ids into a command id that the browser |
1559 // knows how to handle. | 1562 // knows how to handle. |
1560 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); | 1563 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); |
1561 if (command_id_from_app_command != -1) | 1564 if (command_id_from_app_command != -1) |
1562 command_id = command_id_from_app_command; | 1565 command_id = command_id_from_app_command; |
1563 | 1566 |
1564 return browser_->ExecuteCommandIfEnabled(command_id); | 1567 return browser_->ExecuteCommandIfEnabled(command_id); |
1565 } | 1568 } |
1566 | 1569 |
1567 std::wstring BrowserView::GetWindowName() const { | 1570 std::wstring BrowserView::GetWindowName() const { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 Layout(); | 1797 Layout(); |
1795 } | 1798 } |
1796 | 1799 |
1797 void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) { | 1800 void BrowserView::GetAccessibleState(ui::AccessibleViewState* state) { |
1798 state->name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 1801 state->name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
1799 state->role = ui::AccessibilityTypes::ROLE_CLIENT; | 1802 state->role = ui::AccessibilityTypes::ROLE_CLIENT; |
1800 } | 1803 } |
1801 | 1804 |
1802 SkColor BrowserView::GetInfoBarSeparatorColor() const { | 1805 SkColor BrowserView::GetInfoBarSeparatorColor() const { |
1803 // NOTE: Keep this in sync with ToolbarView::OnPaint()! | 1806 // NOTE: Keep this in sync with ToolbarView::OnPaint()! |
1804 return (IsTabStripVisible() || !frame_->non_client_view()->UseNativeFrame()) ? | 1807 return (IsTabStripVisible() || !frame_->ShouldUseNativeFrame()) ? |
1805 ResourceBundle::toolbar_separator_color : SK_ColorBLACK; | 1808 ResourceBundle::toolbar_separator_color : SK_ColorBLACK; |
1806 } | 1809 } |
1807 | 1810 |
1808 void BrowserView::InfoBarContainerStateChanged(bool is_animating) { | 1811 void BrowserView::InfoBarContainerStateChanged(bool is_animating) { |
1809 ToolbarSizeChanged(is_animating); | 1812 ToolbarSizeChanged(is_animating); |
1810 } | 1813 } |
1811 | 1814 |
1812 bool BrowserView::DrawInfoBarArrows(int* x) const { | 1815 bool BrowserView::DrawInfoBarArrows(int* x) const { |
1813 if (x) { | 1816 if (x) { |
1814 const LocationIconView* location_icon_view = | 1817 const LocationIconView* location_icon_view = |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 } | 2352 } |
2350 | 2353 |
2351 #if defined(OS_WIN) | 2354 #if defined(OS_WIN) |
2352 void BrowserView::BuildSystemMenuForBrowserWindow() { | 2355 void BrowserView::BuildSystemMenuForBrowserWindow() { |
2353 system_menu_contents_->AddSeparator(); | 2356 system_menu_contents_->AddSeparator(); |
2354 system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, | 2357 system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, |
2355 IDS_TASK_MANAGER); | 2358 IDS_TASK_MANAGER); |
2356 system_menu_contents_->AddSeparator(); | 2359 system_menu_contents_->AddSeparator(); |
2357 system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 2360 system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
2358 system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 2361 system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
| 2362 AddFrameToggleItems(); |
2359 // If it's a regular browser window with tabs, we don't add any more items, | 2363 // If it's a regular browser window with tabs, we don't add any more items, |
2360 // since it already has menus (Page, Chrome). | 2364 // since it already has menus (Page, Chrome). |
2361 } | 2365 } |
2362 | 2366 |
2363 void BrowserView::BuildSystemMenuForAppOrPopupWindow() { | 2367 void BrowserView::BuildSystemMenuForAppOrPopupWindow() { |
2364 if (browser_->is_app()) { | 2368 if (browser_->is_app()) { |
2365 system_menu_contents_->AddSeparator(); | 2369 system_menu_contents_->AddSeparator(); |
2366 system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, | 2370 system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, |
2367 IDS_TASK_MANAGER); | 2371 IDS_TASK_MANAGER); |
2368 } | 2372 } |
(...skipping 20 matching lines...) Expand all Loading... |
2389 IDS_SHOW_AS_TAB); | 2393 IDS_SHOW_AS_TAB); |
2390 } | 2394 } |
2391 system_menu_contents_->AddItemWithStringId(IDC_COPY_URL, | 2395 system_menu_contents_->AddItemWithStringId(IDC_COPY_URL, |
2392 IDS_APP_MENU_COPY_URL); | 2396 IDS_APP_MENU_COPY_URL); |
2393 system_menu_contents_->AddSeparator(); | 2397 system_menu_contents_->AddSeparator(); |
2394 system_menu_contents_->AddItemWithStringId(IDC_RELOAD, IDS_APP_MENU_RELOAD); | 2398 system_menu_contents_->AddItemWithStringId(IDC_RELOAD, IDS_APP_MENU_RELOAD); |
2395 system_menu_contents_->AddItemWithStringId(IDC_FORWARD, | 2399 system_menu_contents_->AddItemWithStringId(IDC_FORWARD, |
2396 IDS_CONTENT_CONTEXT_FORWARD); | 2400 IDS_CONTENT_CONTEXT_FORWARD); |
2397 system_menu_contents_->AddItemWithStringId(IDC_BACK, | 2401 system_menu_contents_->AddItemWithStringId(IDC_BACK, |
2398 IDS_CONTENT_CONTEXT_BACK); | 2402 IDS_CONTENT_CONTEXT_BACK); |
| 2403 AddFrameToggleItems(); |
| 2404 } |
| 2405 |
| 2406 void BrowserView::AddFrameToggleItems() { |
| 2407 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2408 switches::kDebugEnableFrameToggle)) { |
| 2409 system_menu_contents_->AddSeparator(); |
| 2410 system_menu_contents_->AddItem(IDC_DEBUG_FRAME_TOGGLE, |
| 2411 L"Toggle Frame Type"); |
| 2412 } |
2399 } | 2413 } |
2400 #endif | 2414 #endif |
2401 | 2415 |
2402 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { | 2416 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { |
2403 #if defined(OS_WIN) | 2417 #if defined(OS_WIN) |
2404 switch (app_command_id) { | 2418 switch (app_command_id) { |
2405 // NOTE: The order here matches the APPCOMMAND declaration order in the | 2419 // NOTE: The order here matches the APPCOMMAND declaration order in the |
2406 // Windows headers. | 2420 // Windows headers. |
2407 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK; | 2421 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK; |
2408 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD; | 2422 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2579 view->GetWindow()->non_client_view()->SetAccessibleName( | 2593 view->GetWindow()->non_client_view()->SetAccessibleName( |
2580 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2594 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
2581 return view; | 2595 return view; |
2582 } | 2596 } |
2583 #endif | 2597 #endif |
2584 | 2598 |
2585 // static | 2599 // static |
2586 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2600 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2587 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2601 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2588 } | 2602 } |
OLD | NEW |