| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 61 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 62 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 62 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
| 63 #include "chrome/browser/ui/views/browser_dialogs.h" | 63 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 64 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 64 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 65 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 65 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 66 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" | 66 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" |
| 67 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 67 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 68 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | 68 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" |
| 69 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" | 69 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" |
| 70 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 70 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 71 #include "chrome/browser/ui/views/frame/native_browser_frame_factory.h" | |
| 72 #include "chrome/browser/ui/views/frame/top_container_view.h" | 71 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 73 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" | 72 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" |
| 74 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" | 73 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| 75 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 74 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 76 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 75 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 77 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 76 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 78 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 77 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 79 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" | 78 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" |
| 80 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 79 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 81 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 80 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 101 #include "components/app_modal_dialogs/app_modal_dialog.h" | 100 #include "components/app_modal_dialogs/app_modal_dialog.h" |
| 102 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" | 101 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
| 103 #include "components/signin/core/common/profile_management_switches.h" | 102 #include "components/signin/core/common/profile_management_switches.h" |
| 104 #include "components/translate/core/browser/language_state.h" | 103 #include "components/translate/core/browser/language_state.h" |
| 105 #include "content/app/resources/grit/content_resources.h" | 104 #include "content/app/resources/grit/content_resources.h" |
| 106 #include "content/public/browser/download_manager.h" | 105 #include "content/public/browser/download_manager.h" |
| 107 #include "content/public/browser/native_web_keyboard_event.h" | 106 #include "content/public/browser/native_web_keyboard_event.h" |
| 108 #include "content/public/browser/notification_service.h" | 107 #include "content/public/browser/notification_service.h" |
| 109 #include "content/public/browser/render_frame_host.h" | 108 #include "content/public/browser/render_frame_host.h" |
| 110 #include "content/public/browser/render_view_host.h" | 109 #include "content/public/browser/render_view_host.h" |
| 110 #include "content/public/browser/render_widget_host_view.h" |
| 111 #include "content/public/browser/user_metrics.h" | 111 #include "content/public/browser/user_metrics.h" |
| 112 #include "content/public/browser/web_contents.h" | 112 #include "content/public/browser/web_contents.h" |
| 113 #include "content/public/common/content_switches.h" | 113 #include "content/public/common/content_switches.h" |
| 114 #include "grit/theme_resources.h" | 114 #include "grit/theme_resources.h" |
| 115 #include "ui/accessibility/ax_view_state.h" | 115 #include "ui/accessibility/ax_view_state.h" |
| 116 #include "ui/aura/client/window_tree_client.h" | |
| 117 #include "ui/aura/window.h" | |
| 118 #include "ui/aura/window_tree_host.h" | |
| 119 #include "ui/base/accelerators/accelerator.h" | 116 #include "ui/base/accelerators/accelerator.h" |
| 120 #include "ui/base/hit_test.h" | 117 #include "ui/base/hit_test.h" |
| 121 #include "ui/base/l10n/l10n_util.h" | 118 #include "ui/base/l10n/l10n_util.h" |
| 122 #include "ui/base/resource/resource_bundle.h" | 119 #include "ui/base/resource/resource_bundle.h" |
| 123 #include "ui/base/theme_provider.h" | 120 #include "ui/base/theme_provider.h" |
| 124 #include "ui/events/event_utils.h" | 121 #include "ui/events/event_utils.h" |
| 125 #include "ui/gfx/canvas.h" | 122 #include "ui/gfx/canvas.h" |
| 126 #include "ui/gfx/color_utils.h" | 123 #include "ui/gfx/color_utils.h" |
| 127 #include "ui/gfx/rect_conversions.h" | 124 #include "ui/gfx/rect_conversions.h" |
| 128 #include "ui/gfx/screen.h" | 125 #include "ui/gfx/screen.h" |
| 129 #include "ui/strings/grit/ui_strings.h" | 126 #include "ui/strings/grit/ui_strings.h" |
| 130 #include "ui/views/controls/button/menu_button.h" | 127 #include "ui/views/controls/button/menu_button.h" |
| 131 #include "ui/views/controls/textfield/textfield.h" | 128 #include "ui/views/controls/textfield/textfield.h" |
| 132 #include "ui/views/controls/webview/webview.h" | 129 #include "ui/views/controls/webview/webview.h" |
| 133 #include "ui/views/focus/external_focus_tracker.h" | 130 #include "ui/views/focus/external_focus_tracker.h" |
| 134 #include "ui/views/focus/view_storage.h" | 131 #include "ui/views/focus/view_storage.h" |
| 135 #include "ui/views/layout/grid_layout.h" | 132 #include "ui/views/layout/grid_layout.h" |
| 136 #include "ui/views/widget/native_widget.h" | 133 #include "ui/views/widget/native_widget.h" |
| 137 #include "ui/views/widget/root_view.h" | 134 #include "ui/views/widget/root_view.h" |
| 138 #include "ui/views/widget/widget.h" | 135 #include "ui/views/widget/widget.h" |
| 139 #include "ui/views/window/dialog_delegate.h" | 136 #include "ui/views/window/dialog_delegate.h" |
| 140 | 137 |
| 138 #if defined(USE_AURA) |
| 139 #include "ui/aura/client/window_tree_client.h" |
| 140 #include "ui/aura/window.h" |
| 141 #include "ui/aura/window_tree_host.h" |
| 142 #endif |
| 143 |
| 141 #if defined(OS_WIN) | 144 #if defined(OS_WIN) |
| 142 #include "base/win/windows_version.h" | 145 #include "base/win/windows_version.h" |
| 143 #include "chrome/browser/jumplist_win.h" | 146 #include "chrome/browser/jumplist_win.h" |
| 144 #include "ui/views/win/scoped_fullscreen_visibility.h" | 147 #include "ui/views/win/scoped_fullscreen_visibility.h" |
| 145 #endif | 148 #endif |
| 146 | 149 |
| 147 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 150 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 148 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" | 151 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" |
| 149 #include "chrome/browser/ui/sync/one_click_signin_bubble_links_delegate.h" | 152 #include "chrome/browser/ui/sync/one_click_signin_bubble_links_delegate.h" |
| 150 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 153 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 ToolbarView* BrowserView::GetToolbarView() const { | 1412 ToolbarView* BrowserView::GetToolbarView() const { |
| 1410 return toolbar_; | 1413 return toolbar_; |
| 1411 } | 1414 } |
| 1412 | 1415 |
| 1413 /////////////////////////////////////////////////////////////////////////////// | 1416 /////////////////////////////////////////////////////////////////////////////// |
| 1414 // BrowserView, TabStripModelObserver implementation: | 1417 // BrowserView, TabStripModelObserver implementation: |
| 1415 | 1418 |
| 1416 void BrowserView::TabInsertedAt(WebContents* contents, | 1419 void BrowserView::TabInsertedAt(WebContents* contents, |
| 1417 int index, | 1420 int index, |
| 1418 bool foreground) { | 1421 bool foreground) { |
| 1422 #if defined(USE_AURA) |
| 1419 // WebContents inserted in tabs might not have been added to the root | 1423 // WebContents inserted in tabs might not have been added to the root |
| 1420 // window yet. Per http://crbug/342672 add them now since drawing the | 1424 // window yet. Per http://crbug/342672 add them now since drawing the |
| 1421 // WebContents requires root window specific data - information about | 1425 // WebContents requires root window specific data - information about |
| 1422 // the screen the WebContents is drawn on, for example. | 1426 // the screen the WebContents is drawn on, for example. |
| 1423 if (!contents->GetNativeView()->GetRootWindow()) { | 1427 if (!contents->GetNativeView()->GetRootWindow()) { |
| 1424 aura::Window* window = contents->GetNativeView(); | 1428 aura::Window* window = contents->GetNativeView(); |
| 1425 aura::Window* root_window = GetNativeWindow()->GetRootWindow(); | 1429 aura::Window* root_window = GetNativeWindow()->GetRootWindow(); |
| 1426 aura::client::ParentWindowWithContext( | 1430 aura::client::ParentWindowWithContext( |
| 1427 window, root_window, root_window->GetBoundsInScreen()); | 1431 window, root_window, root_window->GetBoundsInScreen()); |
| 1428 DCHECK(contents->GetNativeView()->GetRootWindow()); | 1432 DCHECK(contents->GetNativeView()->GetRootWindow()); |
| 1429 } | 1433 } |
| 1434 #endif |
| 1430 web_contents_close_handler_->TabInserted(); | 1435 web_contents_close_handler_->TabInserted(); |
| 1431 | 1436 |
| 1432 if (foreground) | 1437 if (foreground) |
| 1433 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); | 1438 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); |
| 1434 } | 1439 } |
| 1435 | 1440 |
| 1436 void BrowserView::TabDetachedAt(WebContents* contents, int index) { | 1441 void BrowserView::TabDetachedAt(WebContents* contents, int index) { |
| 1437 if (PermissionBubbleManager::FromWebContents(contents)) | 1442 if (PermissionBubbleManager::FromWebContents(contents)) |
| 1438 PermissionBubbleManager::FromWebContents(contents)->SetView(nullptr); | 1443 PermissionBubbleManager::FromWebContents(contents)->SetView(nullptr); |
| 1439 | 1444 |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2359 else if (key_code == ui::VKEY_K) | 2364 else if (key_code == ui::VKEY_K) |
| 2360 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K")); | 2365 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K")); |
| 2361 break; | 2366 break; |
| 2362 default: | 2367 default: |
| 2363 // Do nothing. | 2368 // Do nothing. |
| 2364 break; | 2369 break; |
| 2365 } | 2370 } |
| 2366 #endif | 2371 #endif |
| 2367 } | 2372 } |
| 2368 | 2373 |
| 2369 // static | |
| 2370 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | |
| 2371 // Create the view and the frame. The frame will attach itself via the view | |
| 2372 // so we don't need to do anything with the pointer. | |
| 2373 BrowserView* view = new BrowserView(); | |
| 2374 view->Init(browser); | |
| 2375 (new BrowserFrame(view))->InitBrowserFrame(); | |
| 2376 view->GetWidget()->non_client_view()->SetAccessibleName( | |
| 2377 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | |
| 2378 return view; | |
| 2379 } | |
| 2380 | |
| 2381 // static | |
| 2382 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType( | |
| 2383 chrome::HostDesktopType desktop_type) { | |
| 2384 return NativeBrowserFrameFactory::AdjustHostDesktopType(desktop_type); | |
| 2385 } | |
| 2386 | |
| 2387 void BrowserView::ShowAvatarBubble(WebContents* web_contents, | 2374 void BrowserView::ShowAvatarBubble(WebContents* web_contents, |
| 2388 const gfx::Rect& rect) { | 2375 const gfx::Rect& rect) { |
| 2389 gfx::Point origin(rect.origin()); | 2376 gfx::Point origin(rect.origin()); |
| 2390 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); | 2377 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); |
| 2391 gfx::Rect bounds(origin, rect.size()); | 2378 gfx::Rect bounds(origin, rect.size()); |
| 2392 | 2379 |
| 2393 AvatarMenuBubbleView::ShowBubble( | 2380 AvatarMenuBubbleView::ShowBubble( |
| 2394 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, | 2381 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, |
| 2395 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); | 2382 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); |
| 2396 } | 2383 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || | 2458 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || |
| 2472 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { | 2459 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { |
| 2473 views::Textfield* textfield = static_cast<views::Textfield*>(focused); | 2460 views::Textfield* textfield = static_cast<views::Textfield*>(focused); |
| 2474 textfield->ExecuteCommand(command_id); | 2461 textfield->ExecuteCommand(command_id); |
| 2475 } | 2462 } |
| 2476 } | 2463 } |
| 2477 | 2464 |
| 2478 bool BrowserView::DoCutCopyPasteForWebContents( | 2465 bool BrowserView::DoCutCopyPasteForWebContents( |
| 2479 WebContents* contents, | 2466 WebContents* contents, |
| 2480 void (WebContents::*method)()) { | 2467 void (WebContents::*method)()) { |
| 2481 gfx::NativeView native_view = contents->GetContentNativeView(); | 2468 if (contents->GetRenderWidgetHostView()->HasFocus()) { |
| 2482 if (!native_view) | |
| 2483 return false; | |
| 2484 if (native_view->HasFocus()) { | |
| 2485 (contents->*method)(); | 2469 (contents->*method)(); |
| 2486 return true; | 2470 return true; |
| 2487 } | 2471 } |
| 2488 | 2472 |
| 2489 return false; | 2473 return false; |
| 2490 } | 2474 } |
| 2491 | 2475 |
| 2492 void BrowserView::ActivateAppModalDialog() const { | 2476 void BrowserView::ActivateAppModalDialog() const { |
| 2493 // If another browser is app modal, flash and activate the modal browser. | 2477 // If another browser is app modal, flash and activate the modal browser. |
| 2494 AppModalDialog* active_dialog = | 2478 AppModalDialog* active_dialog = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2514 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2498 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2515 gfx::Point icon_bottom( | 2499 gfx::Point icon_bottom( |
| 2516 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2500 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 2517 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2501 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| 2518 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr)); | 2502 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr)); |
| 2519 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2503 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2520 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2504 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2521 } | 2505 } |
| 2522 return top_arrow_height; | 2506 return top_arrow_height; |
| 2523 } | 2507 } |
| OLD | NEW |