| 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // any calls to BrowserList::GetLastActive() (for example, in bookmark_util), | 584 // any calls to BrowserList::GetLastActive() (for example, in bookmark_util), |
| 585 // will return the previous browser. | 585 // will return the previous browser. |
| 586 BrowserList::SetLastActive(browser()); | 586 BrowserList::SetLastActive(browser()); |
| 587 | 587 |
| 588 // If the window is already visible, just activate it. | 588 // If the window is already visible, just activate it. |
| 589 if (frame_->IsVisible()) { | 589 if (frame_->IsVisible()) { |
| 590 frame_->Activate(); | 590 frame_->Activate(); |
| 591 return; | 591 return; |
| 592 } | 592 } |
| 593 | 593 |
| 594 #if defined(USE_AURA) | 594 CreateLauncherIcon(); |
| 595 if (!icon_updater_.get()) | |
| 596 icon_updater_.reset(LauncherUpdater::Create(browser_.get())); | |
| 597 #endif // defined(USE_AURA) | |
| 598 | 595 |
| 599 // Showing the window doesn't make the browser window active right away. | 596 // Showing the window doesn't make the browser window active right away. |
| 600 // This can cause SetFocusToLocationBar() to skip setting focus to the | 597 // This can cause SetFocusToLocationBar() to skip setting focus to the |
| 601 // location bar. To avoid this we explicilty let SetFocusToLocationBar() | 598 // location bar. To avoid this we explicilty let SetFocusToLocationBar() |
| 602 // know that it's ok to steal focus. | 599 // know that it's ok to steal focus. |
| 603 force_location_bar_focus_ = true; | 600 force_location_bar_focus_ = true; |
| 604 | 601 |
| 605 // Setting the focus doesn't work when the window is invisible, so any focus | 602 // Setting the focus doesn't work when the window is invisible, so any focus |
| 606 // initialization that happened before this will be lost. | 603 // initialization that happened before this will be lost. |
| 607 // | 604 // |
| 608 // We really "should" restore the focus whenever the window becomes unhidden, | 605 // We really "should" restore the focus whenever the window becomes unhidden, |
| 609 // but I think initializing is the only time where this can happen where | 606 // but I think initializing is the only time where this can happen where |
| 610 // there is some focus change we need to pick up, and this is easier than | 607 // there is some focus change we need to pick up, and this is easier than |
| 611 // plumbing through an un-hide message all the way from the frame. | 608 // plumbing through an un-hide message all the way from the frame. |
| 612 // | 609 // |
| 613 // If we do find there are cases where we need to restore the focus on show, | 610 // If we do find there are cases where we need to restore the focus on show, |
| 614 // that should be added and this should be removed. | 611 // that should be added and this should be removed. |
| 615 RestoreFocus(); | 612 RestoreFocus(); |
| 616 | 613 |
| 617 frame_->Show(); | 614 frame_->Show(); |
| 618 | 615 |
| 619 force_location_bar_focus_ = false; | 616 force_location_bar_focus_ = false; |
| 620 | 617 |
| 621 browser()->OnWindowDidShow(); | 618 browser()->OnWindowDidShow(); |
| 622 } | 619 } |
| 623 | 620 |
| 624 void BrowserView::ShowInactive() { | 621 void BrowserView::ShowInactive() { |
| 625 if (!frame_->IsVisible()) | 622 if (frame_->IsVisible()) |
| 626 frame_->ShowInactive(); | 623 return; |
| 624 CreateLauncherIcon(); |
| 625 frame_->ShowInactive(); |
| 627 } | 626 } |
| 628 | 627 |
| 629 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 628 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
| 630 ExitFullscreen(); | 629 ExitFullscreen(); |
| 631 GetWidget()->SetBounds(bounds); | 630 GetWidget()->SetBounds(bounds); |
| 632 } | 631 } |
| 633 | 632 |
| 634 void BrowserView::Close() { | 633 void BrowserView::Close() { |
| 635 frame_->Close(); | 634 frame_->Close(); |
| 636 } | 635 } |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2529 RemoveChildView(toolbar_); | 2528 RemoveChildView(toolbar_); |
| 2530 delete toolbar_; | 2529 delete toolbar_; |
| 2531 } | 2530 } |
| 2532 toolbar_ = toolbar; | 2531 toolbar_ = toolbar; |
| 2533 if (toolbar) { | 2532 if (toolbar) { |
| 2534 AddChildView(toolbar_); | 2533 AddChildView(toolbar_); |
| 2535 toolbar_->Init(); | 2534 toolbar_->Init(); |
| 2536 } | 2535 } |
| 2537 } | 2536 } |
| 2538 | 2537 |
| 2538 void BrowserView::CreateLauncherIcon() { |
| 2539 #if defined(USE_AURA) |
| 2540 if (!icon_updater_.get()) |
| 2541 icon_updater_.reset(LauncherUpdater::Create(browser_.get())); |
| 2542 #endif // defined(USE_AURA) |
| 2543 } |
| 2544 |
| 2539 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | 2545 #if !defined(OS_CHROMEOS) || defined(USE_AURA) |
| 2540 // static | 2546 // static |
| 2541 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2547 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2542 // Create the view and the frame. The frame will attach itself via the view | 2548 // Create the view and the frame. The frame will attach itself via the view |
| 2543 // so we don't need to do anything with the pointer. | 2549 // so we don't need to do anything with the pointer. |
| 2544 BrowserView* view = new BrowserView(browser); | 2550 BrowserView* view = new BrowserView(browser); |
| 2545 (new BrowserFrame(view))->InitBrowserFrame(); | 2551 (new BrowserFrame(view))->InitBrowserFrame(); |
| 2546 view->GetWidget()->non_client_view()->SetAccessibleName( | 2552 view->GetWidget()->non_client_view()->SetAccessibleName( |
| 2547 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2553 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 2548 return view; | 2554 return view; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2560 browser::CreateViewsBubble(bubble); | 2566 browser::CreateViewsBubble(bubble); |
| 2561 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2567 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 2562 bubble->Show(); | 2568 bubble->Show(); |
| 2563 } | 2569 } |
| 2564 | 2570 |
| 2565 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2571 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
| 2566 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2572 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
| 2567 if (button) | 2573 if (button) |
| 2568 button->ShowAvatarBubble(); | 2574 button->ShowAvatarBubble(); |
| 2569 } | 2575 } |
| OLD | NEW |