| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 tabstrip_(nullptr), | 456 tabstrip_(nullptr), |
| 457 toolbar_(nullptr), | 457 toolbar_(nullptr), |
| 458 find_bar_host_view_(nullptr), | 458 find_bar_host_view_(nullptr), |
| 459 infobar_container_(nullptr), | 459 infobar_container_(nullptr), |
| 460 contents_web_view_(nullptr), | 460 contents_web_view_(nullptr), |
| 461 devtools_web_view_(nullptr), | 461 devtools_web_view_(nullptr), |
| 462 contents_container_(nullptr), | 462 contents_container_(nullptr), |
| 463 initialized_(false), | 463 initialized_(false), |
| 464 handling_theme_changed_(false), | 464 handling_theme_changed_(false), |
| 465 in_process_fullscreen_(false), | 465 in_process_fullscreen_(false), |
| 466 #if defined(OS_WIN) | |
| 467 // TODO(piman): is this still useful now that windowed plugins are gone? | |
| 468 ticker_(0), | |
| 469 hung_window_detector_(&hung_plugin_action_), | |
| 470 #endif | |
| 471 force_location_bar_focus_(false), | 466 force_location_bar_focus_(false), |
| 472 activate_modal_dialog_factory_(this) { | 467 activate_modal_dialog_factory_(this) { |
| 473 } | 468 } |
| 474 | 469 |
| 475 BrowserView::~BrowserView() { | 470 BrowserView::~BrowserView() { |
| 476 // All the tabs should have been destroyed already. If we were closed by the | 471 // All the tabs should have been destroyed already. If we were closed by the |
| 477 // OS with some tabs than the NativeBrowserFrame should have destroyed them. | 472 // OS with some tabs than the NativeBrowserFrame should have destroyed them. |
| 478 DCHECK_EQ(0, browser_->tab_strip_model()->count()); | 473 DCHECK_EQ(0, browser_->tab_strip_model()->count()); |
| 479 | 474 |
| 480 // Immersive mode may need to reparent views before they are removed/deleted. | 475 // Immersive mode may need to reparent views before they are removed/deleted. |
| 481 immersive_mode_controller_.reset(); | 476 immersive_mode_controller_.reset(); |
| 482 | 477 |
| 483 browser_->tab_strip_model()->RemoveObserver(this); | 478 browser_->tab_strip_model()->RemoveObserver(this); |
| 484 | 479 |
| 485 #if defined(OS_WIN) | 480 #if defined(OS_WIN) |
| 486 // Stop hung plugin monitoring. | |
| 487 ticker_.Stop(); | |
| 488 ticker_.UnregisterTickHandler(&hung_window_detector_); | |
| 489 | |
| 490 // Terminate the jumplist (must be called before browser_->profile() is | 481 // Terminate the jumplist (must be called before browser_->profile() is |
| 491 // destroyed. | 482 // destroyed. |
| 492 if (jumplist_.get()) { | 483 if (jumplist_.get()) { |
| 493 jumplist_->Terminate(); | 484 jumplist_->Terminate(); |
| 494 } | 485 } |
| 495 #endif | 486 #endif |
| 496 | 487 |
| 497 // We destroy the download shelf before |browser_| to remove its child | 488 // We destroy the download shelf before |browser_| to remove its child |
| 498 // download views from the set of download observers (since the observed | 489 // download views from the set of download observers (since the observed |
| 499 // downloads can be destroyed along with |browser_| and the observer | 490 // downloads can be destroyed along with |browser_| and the observer |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 | 2055 |
| 2065 // Stow a pointer to this object onto the window handle so that we can get at | 2056 // Stow a pointer to this object onto the window handle so that we can get at |
| 2066 // it later when all we have is a native view. | 2057 // it later when all we have is a native view. |
| 2067 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); | 2058 GetWidget()->SetNativeWindowProperty(kBrowserViewKey, this); |
| 2068 | 2059 |
| 2069 // Stow a pointer to the browser's profile onto the window handle so that we | 2060 // Stow a pointer to the browser's profile onto the window handle so that we |
| 2070 // can get it later when all we have is a native view. | 2061 // can get it later when all we have is a native view. |
| 2071 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, | 2062 GetWidget()->SetNativeWindowProperty(Profile::kProfileKey, |
| 2072 browser_->profile()); | 2063 browser_->profile()); |
| 2073 | 2064 |
| 2074 // Start a hung plugin window detector for this browser object (as long as | |
| 2075 // hang detection is not disabled). | |
| 2076 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2077 switches::kDisableHangMonitor)) { | |
| 2078 InitHangMonitor(); | |
| 2079 } | |
| 2080 | |
| 2081 LoadAccelerators(); | 2065 LoadAccelerators(); |
| 2082 | 2066 |
| 2083 contents_web_view_ = new ContentsWebView(browser_->profile()); | 2067 contents_web_view_ = new ContentsWebView(browser_->profile()); |
| 2084 contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER); | 2068 contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER); |
| 2085 contents_web_view_->SetEmbedFullscreenWidgetMode(true); | 2069 contents_web_view_->SetEmbedFullscreenWidgetMode(true); |
| 2086 | 2070 |
| 2087 web_contents_close_handler_.reset( | 2071 web_contents_close_handler_.reset( |
| 2088 new WebContentsCloseHandler(contents_web_view_)); | 2072 new WebContentsCloseHandler(contents_web_view_)); |
| 2089 | 2073 |
| 2090 devtools_web_view_ = new views::WebView(browser_->profile()); | 2074 devtools_web_view_ = new views::WebView(browser_->profile()); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 case APPCOMMAND_REDO: | 2438 case APPCOMMAND_REDO: |
| 2455 case APPCOMMAND_SPELL_CHECK: | 2439 case APPCOMMAND_SPELL_CHECK: |
| 2456 default: return -1; | 2440 default: return -1; |
| 2457 } | 2441 } |
| 2458 #else | 2442 #else |
| 2459 // App commands are Windows-specific so there's nothing to do here. | 2443 // App commands are Windows-specific so there's nothing to do here. |
| 2460 return -1; | 2444 return -1; |
| 2461 #endif | 2445 #endif |
| 2462 } | 2446 } |
| 2463 | 2447 |
| 2464 void BrowserView::InitHangMonitor() { | |
| 2465 #if defined(OS_WIN) | |
| 2466 PrefService* pref_service = g_browser_process->local_state(); | |
| 2467 if (!pref_service) | |
| 2468 return; | |
| 2469 | |
| 2470 int plugin_message_response_timeout = | |
| 2471 pref_service->GetInteger(prefs::kPluginMessageResponseTimeout); | |
| 2472 int hung_plugin_detect_freq = | |
| 2473 pref_service->GetInteger(prefs::kHungPluginDetectFrequency); | |
| 2474 HWND window = GetWidget()->GetNativeView()->GetHost()-> | |
| 2475 GetAcceleratedWidget(); | |
| 2476 if ((hung_plugin_detect_freq > 0) && | |
| 2477 hung_window_detector_.Initialize(window, | |
| 2478 plugin_message_response_timeout)) { | |
| 2479 ticker_.set_tick_interval(hung_plugin_detect_freq); | |
| 2480 ticker_.RegisterTickHandler(&hung_window_detector_); | |
| 2481 ticker_.Start(); | |
| 2482 | |
| 2483 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, | |
| 2484 plugin_message_response_timeout); | |
| 2485 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, | |
| 2486 hung_plugin_detect_freq); | |
| 2487 } | |
| 2488 #endif | |
| 2489 } | |
| 2490 | |
| 2491 void BrowserView::UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, | 2448 void BrowserView::UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, |
| 2492 int command_id) { | 2449 int command_id) { |
| 2493 const ui::KeyboardCode key_code = accelerator.key_code(); | 2450 const ui::KeyboardCode key_code = accelerator.key_code(); |
| 2494 if (command_id == IDC_HELP_PAGE_VIA_KEYBOARD && key_code == ui::VKEY_F1) | 2451 if (command_id == IDC_HELP_PAGE_VIA_KEYBOARD && key_code == ui::VKEY_F1) |
| 2495 content::RecordAction(UserMetricsAction("ShowHelpTabViaF1")); | 2452 content::RecordAction(UserMetricsAction("ShowHelpTabViaF1")); |
| 2496 | 2453 |
| 2497 if (command_id == IDC_BOOKMARK_PAGE) | 2454 if (command_id == IDC_BOOKMARK_PAGE) |
| 2498 UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint", | 2455 UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint", |
| 2499 BOOKMARK_ENTRY_POINT_ACCELERATOR, | 2456 BOOKMARK_ENTRY_POINT_ACCELERATOR, |
| 2500 BOOKMARK_ENTRY_POINT_LIMIT); | 2457 BOOKMARK_ENTRY_POINT_LIMIT); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 } | 2659 } |
| 2703 | 2660 |
| 2704 extensions::ActiveTabPermissionGranter* | 2661 extensions::ActiveTabPermissionGranter* |
| 2705 BrowserView::GetActiveTabPermissionGranter() { | 2662 BrowserView::GetActiveTabPermissionGranter() { |
| 2706 content::WebContents* web_contents = GetActiveWebContents(); | 2663 content::WebContents* web_contents = GetActiveWebContents(); |
| 2707 if (!web_contents) | 2664 if (!web_contents) |
| 2708 return nullptr; | 2665 return nullptr; |
| 2709 return extensions::TabHelper::FromWebContents(web_contents) | 2666 return extensions::TabHelper::FromWebContents(web_contents) |
| 2710 ->active_tab_permission_granter(); | 2667 ->active_tab_permission_granter(); |
| 2711 } | 2668 } |
| OLD | NEW |