| 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 26 matching lines...) Expand all Loading... |
| 37 // provides in alternative OEM bubble. | 37 // provides in alternative OEM bubble. |
| 38 const int kOEMBubblePadding = 4; | 38 const int kOEMBubblePadding = 4; |
| 39 | 39 |
| 40 // Padding between parts of strings on the same line (for instance, | 40 // Padding between parts of strings on the same line (for instance, |
| 41 // "New!" and "Search from the address bar!" | 41 // "New!" and "Search from the address bar!" |
| 42 const int kStringSeparationPadding = 2; | 42 const int kStringSeparationPadding = 2; |
| 43 | 43 |
| 44 // Margin around close button. | 44 // Margin around close button. |
| 45 const int kMarginRightOfCloseButton = 7; | 45 const int kMarginRightOfCloseButton = 7; |
| 46 | 46 |
| 47 // The bubble's HWND is actually owned by the border widget, and it's the border |
| 48 // widget that's owned by the frame window the bubble is anchored to. This |
| 49 // function makes the two leaps necessary to go from the bubble contents HWND |
| 50 // to the frame HWND. |
| 51 HWND GetLogicalBubbleOwner(HWND bubble_hwnd) { |
| 52 HWND border_widget_hwnd = GetWindow(bubble_hwnd, GW_OWNER); |
| 53 return GetWindow(border_widget_hwnd, GW_OWNER); |
| 54 } |
| 55 |
| 47 } // namespace | 56 } // namespace |
| 48 | 57 |
| 49 // Base class for implementations of the client view which appears inside the | 58 // Base class for implementations of the client view which appears inside the |
| 50 // first run bubble. It is a dialog-ish view, but is not a true dialog. | 59 // first run bubble. It is a dialog-ish view, but is not a true dialog. |
| 51 class FirstRunBubbleViewBase : public views::View, | 60 class FirstRunBubbleViewBase : public views::View, |
| 52 public views::ButtonListener, | 61 public views::ButtonListener, |
| 53 public views::FocusChangeListener { | 62 public views::FocusChangeListener { |
| 54 public: | 63 public: |
| 55 // Called by FirstRunBubble::Show to request focus for the proper button | 64 // Called by FirstRunBubble::Show to request focus for the proper button |
| 56 // in the FirstRunBubbleView when it is shown. | 65 // in the FirstRunBubbleView when it is shown. |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_); | 516 GetWidget()->GetFocusManager()->RemoveFocusChangeListener(view_); |
| 508 } | 517 } |
| 509 | 518 |
| 510 void FirstRunBubble::EnableParent() { | 519 void FirstRunBubble::EnableParent() { |
| 511 ::EnableWindow(GetParent(), true); | 520 ::EnableWindow(GetParent(), true); |
| 512 // The EnableWindow() call above causes the parent to become active, which | 521 // The EnableWindow() call above causes the parent to become active, which |
| 513 // resets the flag set by Bubble's call to DisableInactiveRendering(), so we | 522 // 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 | 523 // have to call it again before activating the bubble to prevent the parent |
| 515 // window from rendering inactive. | 524 // window from rendering inactive. |
| 516 // TODO(beng): this only works in custom-frame mode, not glass-frame mode. | 525 // TODO(beng): this only works in custom-frame mode, not glass-frame mode. |
| 526 HWND bubble_owner = GetLogicalBubbleOwner(GetNativeView()); |
| 517 views::NativeWidget* parent = | 527 views::NativeWidget* parent = |
| 518 views::NativeWidget::GetNativeWidgetForNativeView(GetParent()); | 528 views::NativeWidget::GetNativeWidgetForNativeView(bubble_owner); |
| 519 if (parent) | 529 if (parent) |
| 520 parent->GetWidget()->GetTopLevelWidget()->DisableInactiveRendering(); | 530 parent->GetWidget()->DisableInactiveRendering(); |
| 521 // Reactivate the FirstRunBubble so it responds to OnActivate messages. | 531 // Reactivate the FirstRunBubble so it responds to OnActivate messages. |
| 522 SetWindowPos(GetParent(), 0, 0, 0, 0, | 532 SetWindowPos(GetParent(), 0, 0, 0, 0, |
| 523 SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_SHOWWINDOW); | 533 SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | SWP_SHOWWINDOW); |
| 524 } | 534 } |
| 525 | 535 |
| 526 void FirstRunBubble::OnActivate(UINT action, BOOL minimized, HWND window) { | 536 void FirstRunBubble::OnActivate(UINT action, BOOL minimized, HWND window) { |
| 527 // Keep the bubble around for kLingerTime milliseconds, to prevent accidental | 537 // Keep the bubble around for kLingerTime milliseconds, to prevent accidental |
| 528 // closure. | 538 // closure. |
| 529 const int kLingerTime = 3000; | 539 const int kLingerTime = 3000; |
| 530 | 540 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 546 // Keep window from automatically closing until kLingerTime has passed. | 556 // Keep window from automatically closing until kLingerTime has passed. |
| 547 if (::IsWindowEnabled(GetParent())) | 557 if (::IsWindowEnabled(GetParent())) |
| 548 Bubble::OnActivate(action, minimized, window); | 558 Bubble::OnActivate(action, minimized, window); |
| 549 } | 559 } |
| 550 | 560 |
| 551 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { | 561 void FirstRunBubble::BubbleClosing(Bubble* bubble, bool closed_by_escape) { |
| 552 // Make sure our parent window is re-enabled. | 562 // Make sure our parent window is re-enabled. |
| 553 if (!IsWindowEnabled(GetParent())) | 563 if (!IsWindowEnabled(GetParent())) |
| 554 ::EnableWindow(GetParent(), true); | 564 ::EnableWindow(GetParent(), true); |
| 555 } | 565 } |
| OLD | NEW |