| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/first_run_bubble.h" | 5 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/first_run/first_run.h" | 8 #include "chrome/browser/first_run/first_run.h" |
| 9 #include "chrome/browser/search_engines/util.h" | 9 #include "chrome/browser/search_engines/util.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 break; | 484 break; |
| 485 case FirstRun::MINIMAL_BUBBLE: | 485 case FirstRun::MINIMAL_BUBBLE: |
| 486 view = new FirstRunMinimalBubbleView(bubble, profile); | 486 view = new FirstRunMinimalBubbleView(bubble, profile); |
| 487 break; | 487 break; |
| 488 default: | 488 default: |
| 489 NOTREACHED(); | 489 NOTREACHED(); |
| 490 } | 490 } |
| 491 bubble->set_view(view); | 491 bubble->set_view(view); |
| 492 bubble->InitBubble( | 492 bubble->InitBubble( |
| 493 parent, position_relative_to, arrow_location, view, bubble); | 493 parent, position_relative_to, arrow_location, view, bubble); |
| 494 bubble->GetFocusManager()->AddFocusChangeListener(view); | 494 bubble->GetWidget()->GetFocusManager()->AddFocusChangeListener(view); |
| 495 view->BubbleShown(); | 495 view->BubbleShown(); |
| 496 return bubble; | 496 return bubble; |
| 497 } | 497 } |
| 498 | 498 |
| 499 FirstRunBubble::FirstRunBubble() | 499 FirstRunBubble::FirstRunBubble() |
| 500 : has_been_activated_(false), | 500 : has_been_activated_(false), |
| 501 ALLOW_THIS_IN_INITIALIZER_LIST(enable_window_method_factory_(this)), | 501 ALLOW_THIS_IN_INITIALIZER_LIST(enable_window_method_factory_(this)), |
| 502 view_(NULL) { | 502 view_(NULL) { |
| 503 } | 503 } |
| 504 | 504 |
| 505 FirstRunBubble::~FirstRunBubble() { | 505 FirstRunBubble::~FirstRunBubble() { |
| 506 enable_window_method_factory_.RevokeAll(); | 506 enable_window_method_factory_.RevokeAll(); |
| 507 GetFocusManager()->RemoveFocusChangeListener(view_); | 507 GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void FirstRunBubble::EnableParent() { | 510 void FirstRunBubble::EnableParent() { |
| 511 ::EnableWindow(GetParent(), true); | 511 ::EnableWindow(GetParent(), true); |
| 512 // The EnableWindow() call above causes the parent to become active, which | 512 // The EnableWindow() call above causes the parent to become active, which |
| 513 // resets the flag set by Bubble's call to DisableInactiveRendering(), so we | 513 // resets the flag set by Bubble's call to DisableInactiveRendering(), so we |
| 514 // have to call it again before activating the bubble to prevent the parent | 514 // have to call it again before activating the bubble to prevent the parent |
| 515 // window from rendering inactive. | 515 // window from rendering inactive. |
| 516 // TODO(beng): this only works in custom-frame mode, not glass-frame mode. | 516 // TODO(beng): this only works in custom-frame mode, not glass-frame mode. |
| 517 views::NativeWidget* parent = | 517 views::NativeWidget* parent = |
| 518 views::NativeWidget::GetNativeWidgetForNativeView(GetParent()); | 518 views::NativeWidget::GetNativeWidgetForNativeView(GetParent()); |
| 519 if (parent) | 519 if (parent) |
| 520 parent->GetWidget()->GetWindow()->DisableInactiveRendering(); | 520 parent->GetWidget()->GetContainingWindow()->DisableInactiveRendering(); |
| 521 // Reactivate the FirstRunBubble so it responds to OnActivate messages. | 521 // Reactivate the FirstRunBubble so it responds to OnActivate messages. |
| 522 SetWindowPos(GetParent(), 0, 0, 0, 0, | 522 SetWindowPos(GetParent(), 0, 0, 0, 0, |
| 523 SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_SHOWWINDOW); | 523 SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_SHOWWINDOW); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void FirstRunBubble::OnActivate(UINT action, BOOL minimized, HWND window) { | 526 void FirstRunBubble::OnActivate(UINT action, BOOL minimized, HWND window) { |
| 527 // Keep the bubble around for kLingerTime milliseconds, to prevent accidental | 527 // Keep the bubble around for kLingerTime milliseconds, to prevent accidental |
| 528 // closure. | 528 // closure. |
| 529 const int kLingerTime = 3000; | 529 const int kLingerTime = 3000; |
| 530 | 530 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 546 // Keep window from automatically closing until kLingerTime has passed. | 546 // Keep window from automatically closing until kLingerTime has passed. |
| 547 if (::IsWindowEnabled(GetParent())) | 547 if (::IsWindowEnabled(GetParent())) |
| 548 Bubble::OnActivate(action, minimized, window); | 548 Bubble::OnActivate(action, minimized, window); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { | 551 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { |
| 552 // Make sure our parent window is re-enabled. | 552 // Make sure our parent window is re-enabled. |
| 553 if (!IsWindowEnabled(GetParent())) | 553 if (!IsWindowEnabled(GetParent())) |
| 554 ::EnableWindow(GetParent(), true); | 554 ::EnableWindow(GetParent(), true); |
| 555 } | 555 } |
| OLD | NEW |