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