Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 697223003: MacViews: Get chrome/browser/ui/views/frame to compile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@constrained
Patch Set: Rebase. Add mac_views_browser build flag Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 #include "components/app_modal_dialogs/app_modal_dialog.h" 101 #include "components/app_modal_dialogs/app_modal_dialog.h"
102 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" 102 #include "components/app_modal_dialogs/app_modal_dialog_queue.h"
103 #include "components/signin/core/common/profile_management_switches.h" 103 #include "components/signin/core/common/profile_management_switches.h"
104 #include "components/translate/core/browser/language_state.h" 104 #include "components/translate/core/browser/language_state.h"
105 #include "content/app/resources/grit/content_resources.h" 105 #include "content/app/resources/grit/content_resources.h"
106 #include "content/public/browser/download_manager.h" 106 #include "content/public/browser/download_manager.h"
107 #include "content/public/browser/native_web_keyboard_event.h" 107 #include "content/public/browser/native_web_keyboard_event.h"
108 #include "content/public/browser/notification_service.h" 108 #include "content/public/browser/notification_service.h"
109 #include "content/public/browser/render_frame_host.h" 109 #include "content/public/browser/render_frame_host.h"
110 #include "content/public/browser/render_view_host.h" 110 #include "content/public/browser/render_view_host.h"
111 #include "content/public/browser/render_widget_host_view.h"
111 #include "content/public/browser/user_metrics.h" 112 #include "content/public/browser/user_metrics.h"
112 #include "content/public/browser/web_contents.h" 113 #include "content/public/browser/web_contents.h"
113 #include "content/public/common/content_switches.h" 114 #include "content/public/common/content_switches.h"
114 #include "grit/theme_resources.h" 115 #include "grit/theme_resources.h"
115 #include "ui/accessibility/ax_view_state.h" 116 #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" 117 #include "ui/base/accelerators/accelerator.h"
120 #include "ui/base/hit_test.h" 118 #include "ui/base/hit_test.h"
121 #include "ui/base/l10n/l10n_util.h" 119 #include "ui/base/l10n/l10n_util.h"
122 #include "ui/base/resource/resource_bundle.h" 120 #include "ui/base/resource/resource_bundle.h"
123 #include "ui/base/theme_provider.h" 121 #include "ui/base/theme_provider.h"
124 #include "ui/events/event_utils.h" 122 #include "ui/events/event_utils.h"
125 #include "ui/gfx/canvas.h" 123 #include "ui/gfx/canvas.h"
126 #include "ui/gfx/color_utils.h" 124 #include "ui/gfx/color_utils.h"
127 #include "ui/gfx/rect_conversions.h" 125 #include "ui/gfx/rect_conversions.h"
128 #include "ui/gfx/screen.h" 126 #include "ui/gfx/screen.h"
129 #include "ui/strings/grit/ui_strings.h" 127 #include "ui/strings/grit/ui_strings.h"
130 #include "ui/views/controls/button/menu_button.h" 128 #include "ui/views/controls/button/menu_button.h"
131 #include "ui/views/controls/textfield/textfield.h" 129 #include "ui/views/controls/textfield/textfield.h"
132 #include "ui/views/controls/webview/webview.h" 130 #include "ui/views/controls/webview/webview.h"
133 #include "ui/views/focus/external_focus_tracker.h" 131 #include "ui/views/focus/external_focus_tracker.h"
134 #include "ui/views/focus/view_storage.h" 132 #include "ui/views/focus/view_storage.h"
135 #include "ui/views/layout/grid_layout.h" 133 #include "ui/views/layout/grid_layout.h"
136 #include "ui/views/widget/native_widget.h" 134 #include "ui/views/widget/native_widget.h"
137 #include "ui/views/widget/root_view.h" 135 #include "ui/views/widget/root_view.h"
138 #include "ui/views/widget/widget.h" 136 #include "ui/views/widget/widget.h"
139 #include "ui/views/window/dialog_delegate.h" 137 #include "ui/views/window/dialog_delegate.h"
140 138
139 #if defined(USE_AURA)
140 #include "ui/aura/client/window_tree_client.h"
141 #include "ui/aura/window.h"
142 #include "ui/aura/window_tree_host.h"
143 #endif
144
141 #if defined(OS_WIN) 145 #if defined(OS_WIN)
142 #include "base/win/windows_version.h" 146 #include "base/win/windows_version.h"
143 #include "chrome/browser/jumplist_win.h" 147 #include "chrome/browser/jumplist_win.h"
144 #include "ui/views/win/scoped_fullscreen_visibility.h" 148 #include "ui/views/win/scoped_fullscreen_visibility.h"
145 #endif 149 #endif
146 150
147 #if defined(ENABLE_ONE_CLICK_SIGNIN) 151 #if defined(ENABLE_ONE_CLICK_SIGNIN)
148 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" 152 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h"
149 #include "chrome/browser/ui/sync/one_click_signin_bubble_links_delegate.h" 153 #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" 154 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h"
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 } 1375 }
1372 1376
1373 void BrowserView::Copy() { 1377 void BrowserView::Copy() {
1374 DoCutCopyPaste(&content::WebContents::Copy, IDS_APP_COPY); 1378 DoCutCopyPaste(&content::WebContents::Copy, IDS_APP_COPY);
1375 } 1379 }
1376 1380
1377 void BrowserView::Paste() { 1381 void BrowserView::Paste() {
1378 DoCutCopyPaste(&content::WebContents::Paste, IDS_APP_PASTE); 1382 DoCutCopyPaste(&content::WebContents::Paste, IDS_APP_PASTE);
1379 } 1383 }
1380 1384
1385 #if defined(OS_MACOSX)
1386 void BrowserView::EnterFullscreenWithChrome() {
1387 NOTIMPLEMENTED();
1388 }
1389
1390 void BrowserView::EnterFullscreenWithoutChrome() {
1391 NOTIMPLEMENTED();
1392 }
1393
1394 bool BrowserView::IsFullscreenWithChrome() {
1395 NOTIMPLEMENTED();
1396 return false;
1397 }
1398
1399 bool BrowserView::IsFullscreenWithoutChrome() {
1400 NOTIMPLEMENTED();
1401 return false;
1402 }
1403 #endif
1404
1381 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( 1405 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
1382 const gfx::Rect& bounds) { 1406 const gfx::Rect& bounds) {
1383 return NEW_POPUP; 1407 return NEW_POPUP;
1384 } 1408 }
1385 1409
1386 FindBar* BrowserView::CreateFindBar() { 1410 FindBar* BrowserView::CreateFindBar() {
1387 return chrome::CreateFindBar(this); 1411 return chrome::CreateFindBar(this);
1388 } 1412 }
1389 1413
1390 WebContentsModalDialogHost* BrowserView::GetWebContentsModalDialogHost() { 1414 WebContentsModalDialogHost* BrowserView::GetWebContentsModalDialogHost() {
(...skipping 18 matching lines...) Expand all
1409 ToolbarView* BrowserView::GetToolbarView() const { 1433 ToolbarView* BrowserView::GetToolbarView() const {
1410 return toolbar_; 1434 return toolbar_;
1411 } 1435 }
1412 1436
1413 /////////////////////////////////////////////////////////////////////////////// 1437 ///////////////////////////////////////////////////////////////////////////////
1414 // BrowserView, TabStripModelObserver implementation: 1438 // BrowserView, TabStripModelObserver implementation:
1415 1439
1416 void BrowserView::TabInsertedAt(WebContents* contents, 1440 void BrowserView::TabInsertedAt(WebContents* contents,
1417 int index, 1441 int index,
1418 bool foreground) { 1442 bool foreground) {
1443 #if defined(USE_AURA)
tapted 2014/11/04 02:33:42 We'll likely need something here for Mac.. (and it
Andre 2014/11/05 02:04:23 The problem is that we will need this code in both
tapted 2014/11/05 05:00:47 yeah - it looks tricky to get BrowserFrameAsh/Aura
1419 // WebContents inserted in tabs might not have been added to the root 1444 // 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 1445 // window yet. Per http://crbug/342672 add them now since drawing the
1421 // WebContents requires root window specific data - information about 1446 // WebContents requires root window specific data - information about
1422 // the screen the WebContents is drawn on, for example. 1447 // the screen the WebContents is drawn on, for example.
1423 if (!contents->GetNativeView()->GetRootWindow()) { 1448 if (!contents->GetNativeView()->GetRootWindow()) {
1424 aura::Window* window = contents->GetNativeView(); 1449 aura::Window* window = contents->GetNativeView();
1425 aura::Window* root_window = GetNativeWindow()->GetRootWindow(); 1450 aura::Window* root_window = GetNativeWindow()->GetRootWindow();
1426 aura::client::ParentWindowWithContext( 1451 aura::client::ParentWindowWithContext(
1427 window, root_window, root_window->GetBoundsInScreen()); 1452 window, root_window, root_window->GetBoundsInScreen());
1428 DCHECK(contents->GetNativeView()->GetRootWindow()); 1453 DCHECK(contents->GetNativeView()->GetRootWindow());
1429 } 1454 }
1455 #endif
1430 web_contents_close_handler_->TabInserted(); 1456 web_contents_close_handler_->TabInserted();
1431 1457
1432 if (foreground) 1458 if (foreground)
1433 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents); 1459 extensions::MaybeShowExtensionControlledNewTabPage(browser(), contents);
1434 } 1460 }
1435 1461
1436 void BrowserView::TabDetachedAt(WebContents* contents, int index) { 1462 void BrowserView::TabDetachedAt(WebContents* contents, int index) {
1437 if (PermissionBubbleManager::FromWebContents(contents)) 1463 if (PermissionBubbleManager::FromWebContents(contents))
1438 PermissionBubbleManager::FromWebContents(contents)->SetView(NULL); 1464 PermissionBubbleManager::FromWebContents(contents)->SetView(NULL);
1439 1465
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 else if (key_code == ui::VKEY_K) 2385 else if (key_code == ui::VKEY_K)
2360 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K")); 2386 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K"));
2361 break; 2387 break;
2362 default: 2388 default:
2363 // Do nothing. 2389 // Do nothing.
2364 break; 2390 break;
2365 } 2391 }
2366 #endif 2392 #endif
2367 } 2393 }
2368 2394
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, 2395 void BrowserView::ShowAvatarBubble(WebContents* web_contents,
2388 const gfx::Rect& rect) { 2396 const gfx::Rect& rect) {
2389 gfx::Point origin(rect.origin()); 2397 gfx::Point origin(rect.origin());
2390 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); 2398 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
2391 gfx::Rect bounds(origin, rect.size()); 2399 gfx::Rect bounds(origin, rect.size());
2392 2400
2393 AvatarMenuBubbleView::ShowBubble( 2401 AvatarMenuBubbleView::ShowBubble(
2394 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, 2402 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL,
2395 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); 2403 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get());
2396 } 2404 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || 2478 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) ||
2471 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { 2479 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) {
2472 views::Textfield* textfield = static_cast<views::Textfield*>(focused); 2480 views::Textfield* textfield = static_cast<views::Textfield*>(focused);
2473 textfield->ExecuteCommand(command_id); 2481 textfield->ExecuteCommand(command_id);
2474 } 2482 }
2475 } 2483 }
2476 2484
2477 bool BrowserView::DoCutCopyPasteForWebContents( 2485 bool BrowserView::DoCutCopyPasteForWebContents(
2478 WebContents* contents, 2486 WebContents* contents,
2479 void (WebContents::*method)()) { 2487 void (WebContents::*method)()) {
2480 gfx::NativeView native_view = contents->GetContentNativeView(); 2488 if (contents->GetRenderWidgetHostView()->HasFocus()) {
2481 if (!native_view)
2482 return false;
2483 if (native_view->HasFocus()) {
2484 (contents->*method)(); 2489 (contents->*method)();
2485 return true; 2490 return true;
2486 } 2491 }
2487 2492
2488 return false; 2493 return false;
2489 } 2494 }
2490 2495
2491 void BrowserView::ActivateAppModalDialog() const { 2496 void BrowserView::ActivateAppModalDialog() const {
2492 // If another browser is app modal, flash and activate the modal browser. 2497 // If another browser is app modal, flash and activate the modal browser.
2493 AppModalDialog* active_dialog = 2498 AppModalDialog* active_dialog =
(...skipping 19 matching lines...) Expand all
2513 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2518 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2514 gfx::Point icon_bottom( 2519 gfx::Point icon_bottom(
2515 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2520 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2516 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2521 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2517 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2522 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2518 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2523 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2519 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2524 top_arrow_height = infobar_top.y() - icon_bottom.y();
2520 } 2525 }
2521 return top_arrow_height; 2526 return top_arrow_height;
2522 } 2527 }
2528
2529 #if !defined(OS_MACOSX) || defined(MAC_VIEWS_BROWSER)
2530 // static
2531 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
tapted 2014/11/04 02:33:43 move these to browser_window_factory.cc?
Andre 2014/11/05 02:04:23 Done.
2532 // Create the view and the frame. The frame will attach itself via the view
2533 // so we don't need to do anything with the pointer.
2534 BrowserView* view = new BrowserView();
2535 view->Init(browser);
2536 (new BrowserFrame(view))->InitBrowserFrame();
2537 view->GetWidget()->non_client_view()->SetAccessibleName(
2538 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
2539 return view;
2540 }
2541
2542 // static
2543 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType(
2544 chrome::HostDesktopType desktop_type) {
2545 return NativeBrowserFrameFactory::AdjustHostDesktopType(desktop_type);
2546 }
2547 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698