| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 46 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
| 47 #include "chrome/browser/ui/views/avatar_menu_button.h" | 47 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 48 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 48 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 49 #include "chrome/browser/ui/views/browser_dialogs.h" | 49 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 50 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 50 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 51 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 51 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 52 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 52 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 53 #include "chrome/browser/ui/views/frame/contents_container.h" | 53 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 54 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" | 54 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| 55 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 55 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 56 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" |
| 56 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 57 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 57 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 58 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 58 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 59 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
| 59 #include "chrome/browser/ui/views/status_bubble_views.h" | 60 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 60 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 61 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 61 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 62 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 62 #include "chrome/browser/ui/views/toolbar_view.h" | 63 #include "chrome/browser/ui/views/toolbar_view.h" |
| 63 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 64 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 64 #include "chrome/browser/ui/views/website_settings_popup_view.h" | 65 #include "chrome/browser/ui/views/website_settings_popup_view.h" |
| 65 #include "chrome/browser/ui/webui/feedback_ui.h" | 66 #include "chrome/browser/ui/webui/feedback_ui.h" |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 true, false, false, false); | 1281 true, false, false, false); |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 void BrowserView::ShowInstant(TabContents* preview) { | 1284 void BrowserView::ShowInstant(TabContents* preview) { |
| 1284 if (!preview_container_) { | 1285 if (!preview_container_) { |
| 1285 preview_container_ = new views::WebView(browser_->profile()); | 1286 preview_container_ = new views::WebView(browser_->profile()); |
| 1286 preview_container_->set_id(VIEW_ID_TAB_CONTAINER); | 1287 preview_container_->set_id(VIEW_ID_TAB_CONTAINER); |
| 1287 } | 1288 } |
| 1288 contents_->SetPreview(preview_container_, preview->web_contents()); | 1289 contents_->SetPreview(preview_container_, preview->web_contents()); |
| 1289 preview_container_->SetWebContents(preview->web_contents()); | 1290 preview_container_->SetWebContents(preview->web_contents()); |
| 1291 RestackLocationBarContainer(); |
| 1290 } | 1292 } |
| 1291 | 1293 |
| 1292 void BrowserView::HideInstant() { | 1294 void BrowserView::HideInstant() { |
| 1293 if (!preview_container_) | 1295 if (!preview_container_) |
| 1294 return; | 1296 return; |
| 1295 | 1297 |
| 1296 // The contents must be changed before SetPreview is invoked. | 1298 // The contents must be changed before SetPreview is invoked. |
| 1297 preview_container_->SetWebContents(NULL); | 1299 preview_container_->SetWebContents(NULL); |
| 1298 contents_->SetPreview(NULL, NULL); | 1300 contents_->SetPreview(NULL, NULL); |
| 1299 delete preview_container_; | 1301 delete preview_container_; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 | 1882 |
| 1881 #if defined(OS_WIN) && !defined(USE_AURA) | 1883 #if defined(OS_WIN) && !defined(USE_AURA) |
| 1882 // Create a custom JumpList and add it to an observer of TabRestoreService | 1884 // Create a custom JumpList and add it to an observer of TabRestoreService |
| 1883 // so we can update the custom JumpList when a tab is added or removed. | 1885 // so we can update the custom JumpList when a tab is added or removed. |
| 1884 if (JumpList::Enabled()) { | 1886 if (JumpList::Enabled()) { |
| 1885 jumplist_ = new JumpList(); | 1887 jumplist_ = new JumpList(); |
| 1886 jumplist_->AddObserver(browser_->profile()); | 1888 jumplist_->AddObserver(browser_->profile()); |
| 1887 } | 1889 } |
| 1888 #endif | 1890 #endif |
| 1889 | 1891 |
| 1892 ReorderChildView(toolbar_->location_bar_container(), child_count() - 1); |
| 1893 |
| 1890 // We're now initialized and ready to process Layout requests. | 1894 // We're now initialized and ready to process Layout requests. |
| 1891 ignore_layout_ = false; | 1895 ignore_layout_ = false; |
| 1892 } | 1896 } |
| 1893 | 1897 |
| 1894 void BrowserView::LoadingAnimationCallback() { | 1898 void BrowserView::LoadingAnimationCallback() { |
| 1895 base::TimeTicks now = base::TimeTicks::Now(); | 1899 base::TimeTicks now = base::TimeTicks::Now(); |
| 1896 if (!last_animation_time_.is_null()) { | 1900 if (!last_animation_time_.is_null()) { |
| 1897 UMA_HISTOGRAM_TIMES( | 1901 UMA_HISTOGRAM_TIMES( |
| 1898 "Tabs.LoadingAnimationTime", | 1902 "Tabs.LoadingAnimationTime", |
| 1899 now - last_animation_time_); | 1903 now - last_animation_time_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 TabContents* devtools_tab_contents = | 1975 TabContents* devtools_tab_contents = |
| 1972 DevToolsWindow::GetDevToolsContents(tab_contents->web_contents()); | 1976 DevToolsWindow::GetDevToolsContents(tab_contents->web_contents()); |
| 1973 if (devtools_tab_contents) | 1977 if (devtools_tab_contents) |
| 1974 devtools_contents = devtools_tab_contents->web_contents(); | 1978 devtools_contents = devtools_tab_contents->web_contents(); |
| 1975 } | 1979 } |
| 1976 | 1980 |
| 1977 bool should_show = devtools_contents && !devtools_container_->visible(); | 1981 bool should_show = devtools_contents && !devtools_container_->visible(); |
| 1978 bool should_hide = !devtools_contents && devtools_container_->visible(); | 1982 bool should_hide = !devtools_contents && devtools_container_->visible(); |
| 1979 | 1983 |
| 1980 devtools_container_->SetWebContents(devtools_contents); | 1984 devtools_container_->SetWebContents(devtools_contents); |
| 1985 RestackLocationBarContainer(); |
| 1981 | 1986 |
| 1982 if (should_show) | 1987 if (should_show) |
| 1983 ShowDevToolsContainer(); | 1988 ShowDevToolsContainer(); |
| 1984 else if (should_hide) | 1989 else if (should_hide) |
| 1985 HideDevToolsContainer(); | 1990 HideDevToolsContainer(); |
| 1986 } | 1991 } |
| 1987 | 1992 |
| 1988 void BrowserView::ShowDevToolsContainer() { | 1993 void BrowserView::ShowDevToolsContainer() { |
| 1989 if (!devtools_focus_tracker_.get()) { | 1994 if (!devtools_focus_tracker_.get()) { |
| 1990 // Install devtools focus tracker when dev tools window is shown for the | 1995 // Install devtools focus tracker when dev tools window is shown for the |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 // avoid an unnecessary resize and re-layout of a WebContents. | 2369 // avoid an unnecessary resize and re-layout of a WebContents. |
| 2365 if (change_tab_contents) | 2370 if (change_tab_contents) |
| 2366 contents_container_->SetWebContents(NULL); | 2371 contents_container_->SetWebContents(NULL); |
| 2367 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); | 2372 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); |
| 2368 if (bookmark_bar_view_.get()) { | 2373 if (bookmark_bar_view_.get()) { |
| 2369 bookmark_bar_view_->SetBookmarkBarState( | 2374 bookmark_bar_view_->SetBookmarkBarState( |
| 2370 browser_->bookmark_bar_state(), | 2375 browser_->bookmark_bar_state(), |
| 2371 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2376 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 2372 } | 2377 } |
| 2373 UpdateUIForContents(new_contents); | 2378 UpdateUIForContents(new_contents); |
| 2374 if (change_tab_contents) | 2379 if (change_tab_contents) { |
| 2375 contents_container_->SetWebContents(new_contents->web_contents()); | 2380 contents_container_->SetWebContents(new_contents->web_contents()); |
| 2381 RestackLocationBarContainer(); |
| 2382 } |
| 2376 | 2383 |
| 2377 UpdateDevToolsForContents(new_contents); | 2384 UpdateDevToolsForContents(new_contents); |
| 2378 // TODO(beng): This should be called automatically by ChangeWebContents, but I | 2385 // TODO(beng): This should be called automatically by ChangeWebContents, but I |
| 2379 // am striving for parity now rather than cleanliness. This is | 2386 // am striving for parity now rather than cleanliness. This is |
| 2380 // required to make features like Duplicate Tab, Undo Close Tab, | 2387 // required to make features like Duplicate Tab, Undo Close Tab, |
| 2381 // etc not result in sad tab. | 2388 // etc not result in sad tab. |
| 2382 new_contents->web_contents()->DidBecomeSelected(); | 2389 new_contents->web_contents()->DidBecomeSelected(); |
| 2383 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && | 2390 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && |
| 2384 GetWidget()->IsVisible()) { | 2391 GetWidget()->IsVisible()) { |
| 2385 // We only restore focus if our window is visible, to avoid invoking blur | 2392 // We only restore focus if our window is visible, to avoid invoking blur |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2398 } | 2405 } |
| 2399 | 2406 |
| 2400 void BrowserView::SetToolbar(ToolbarView* toolbar) { | 2407 void BrowserView::SetToolbar(ToolbarView* toolbar) { |
| 2401 if (toolbar_) { | 2408 if (toolbar_) { |
| 2402 RemoveChildView(toolbar_); | 2409 RemoveChildView(toolbar_); |
| 2403 delete toolbar_; | 2410 delete toolbar_; |
| 2404 } | 2411 } |
| 2405 toolbar_ = toolbar; | 2412 toolbar_ = toolbar; |
| 2406 if (toolbar) { | 2413 if (toolbar) { |
| 2407 AddChildView(toolbar_); | 2414 AddChildView(toolbar_); |
| 2408 toolbar_->Init(contents_->header()); | 2415 toolbar_->Init(this, contents_->header()); |
| 2409 } | 2416 } |
| 2410 } | 2417 } |
| 2411 | 2418 |
| 2412 void BrowserView::CreateLauncherIcon() { | 2419 void BrowserView::CreateLauncherIcon() { |
| 2413 #if defined(USE_ASH) | 2420 #if defined(USE_ASH) |
| 2414 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && | 2421 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && |
| 2415 !launcher_item_controller_.get()) { | 2422 !launcher_item_controller_.get()) { |
| 2416 launcher_item_controller_.reset( | 2423 launcher_item_controller_.reset( |
| 2417 BrowserLauncherItemController::Create(browser_.get())); | 2424 BrowserLauncherItemController::Create(browser_.get())); |
| 2418 } | 2425 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2470 this, | 2477 this, |
| 2471 tab_contents->web_contents()->GetRenderViewHost(), | 2478 tab_contents->web_contents()->GetRenderViewHost(), |
| 2472 password_generator, | 2479 password_generator, |
| 2473 browser_.get(), | 2480 browser_.get(), |
| 2474 tab_contents->password_manager()); | 2481 tab_contents->password_manager()); |
| 2475 | 2482 |
| 2476 views::BubbleDelegateView::CreateBubble(bubble); | 2483 views::BubbleDelegateView::CreateBubble(bubble); |
| 2477 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); | 2484 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); |
| 2478 bubble->Show(); | 2485 bubble->Show(); |
| 2479 } | 2486 } |
| 2487 |
| 2488 void BrowserView::RestackLocationBarContainer() { |
| 2489 toolbar_->location_bar_container()->StackAtTop(); |
| 2490 } |
| OLD | NEW |