summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/cf_resources.rc8
-rw-r--r--chrome_frame/resource.h2
-rw-r--r--chrome_frame/resources/chrome_frame_resources.grd5
-rw-r--r--chrome_frame/turndown_prompt/turndown_prompt_window.cc83
-rw-r--r--chrome_frame/turndown_prompt/turndown_prompt_window.h9
5 files changed, 99 insertions, 8 deletions
diff --git a/chrome/app/cf_resources.rc b/chrome/app/cf_resources.rc
index a989d1a..af6bc7a 100644
--- a/chrome/app/cf_resources.rc
+++ b/chrome/app/cf_resources.rc
@@ -55,8 +55,8 @@ IDD_CHROME_FRAME_TURNDOWN_PROMPT DIALOGEX 0, 0, 393, 14
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
- LTEXT "This site is using the Chrome Frame plug-in which will soon be unsupported. Please uninstall it and upgrade to a modern browser.",IDC_TD_PROMPT_MESSAGE,3,3,414,8
- LTEXT "Learn more.",IDC_TD_PROMPT_LINK,238,3,42,8
- PUSHBUTTON "Uninstall",IDUNINSTALL,285,2,50,12
- DEFPUSHBUTTON "Dismiss",IDDISMISS,340,2,50,12
+ LTEXT "This site is using the Chrome Frame plug-in which will soon be unsupported. Please uninstall it and upgrade to a modern browser.",IDC_TD_PROMPT_MESSAGE,3,3,260,8
+ LTEXT "Learn more.",IDC_TD_PROMPT_LINK,270,3,42,8
+ PUSHBUTTON "Uninstall",IDUNINSTALL,319,2,50,12
+ DEFPUSHBUTTON "Dismiss",IDDISMISS,377,2,18,18
END
diff --git a/chrome_frame/resource.h b/chrome_frame/resource.h
index 53f51a5..8b4d686 100644
--- a/chrome_frame/resource.h
+++ b/chrome_frame/resource.h
@@ -8,7 +8,7 @@
// Used by resources/tlb_resource.rc
// Default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 204
diff --git a/chrome_frame/resources/chrome_frame_resources.grd b/chrome_frame/resources/chrome_frame_resources.grd
index e9e1bc4..8bc5584 100644
--- a/chrome_frame/resources/chrome_frame_resources.grd
+++ b/chrome_frame/resources/chrome_frame_resources.grd
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
+<!--
Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
source code is governed by a BSD-style license that can be found in the LICENSE
file.
-->
<!--
-Embeded strings, branding resource, etc. See chrome_frame_strings.grd
+Embeded strings, branding resource, etc. See chrome_frame_strings.grd
for localizable strings
-->
@@ -39,6 +39,7 @@ for localizable strings
<if expr="not pp_ifdef('_google_chrome')">
<include name="IDI_CHROME_FRAME_ICON" file="../../chrome/app/theme/chromium/chromium.ico" type="ICON" />
</if>
+ <include name="IDB_TURNDOWN_PROMPT_CLOSE_BUTTON" file="../../chrome/app/theme/default_100_percent/common/cf_close_strip.bmp" type="BITMAP" />
</includes>
</release>
</grit>
diff --git a/chrome_frame/turndown_prompt/turndown_prompt_window.cc b/chrome_frame/turndown_prompt/turndown_prompt_window.cc
index 851f1c0..17321e0 100644
--- a/chrome_frame/turndown_prompt/turndown_prompt_window.cc
+++ b/chrome_frame/turndown_prompt/turndown_prompt_window.cc
@@ -13,6 +13,7 @@
#include "chrome_frame/simple_resource_loader.h"
#include "chrome_frame/utils.h"
#include "grit/chrome_frame_dialogs.h"
+#include "grit/chrome_frame_resources.h"
#include "grit/chromium_strings.h"
// atlctrlx.h requires 'min' and 'max' macros, the definition of which conflicts
@@ -22,6 +23,35 @@
#include <minmax.h> // NOLINT
#include <atlctrlx.h> // NOLINT
+namespace {
+const uint32 kBitmapImageSize = 18;
+} // namespace
+
+// WTL's CBitmapButton's drawing code is horribly broken when using transparent
+// images (specifically, it doesn't clear the background between redraws).
+// Fix it here.
+class CFBitmapButton: public CBitmapButtonImpl<CFBitmapButton>
+{
+ public:
+ DECLARE_WND_SUPERCLASS(_T("WTL_BitmapButton"), GetWndClassName())
+
+ CFBitmapButton()
+ : CBitmapButtonImpl<CFBitmapButton>(BMPBTN_AUTOSIZE | BMPBTN_HOVER,
+ NULL) {}
+
+ // "Overridden" from CBitmapButtonImpl via template hackery. See
+ // CBitmapButtonImpl::OnPaint() in atlctrlx.h for details.
+ void DoPaint(CDCHandle dc) {
+ RECT rc = {0};
+ GetClientRect(&rc);
+ dc.FillRect(&rc, reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1));
+
+ // Call original implementation.
+ CBitmapButtonImpl<CFBitmapButton>::DoPaint(dc);
+ }
+};
+
+// static
base::WeakPtr<TurndownPromptWindow> TurndownPromptWindow::CreateInstance(
InfobarContent::Frame* frame,
UrlLauncher* url_launcher,
@@ -48,6 +78,8 @@ base::WeakPtr<TurndownPromptWindow> TurndownPromptWindow::CreateInstance(
instance->link_->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON,
HLINK_NOTIFYBUTTON);
+ SetupBitmapButton(instance.get());
+
// Substitute the proper text given the current IE version.
CWindow text = instance->GetDlgItem(IDC_TD_PROMPT_MESSAGE);
string16 prompt_text(GetPromptText());
@@ -69,11 +101,62 @@ TurndownPromptWindow::TurndownPromptWindow(
TurndownPromptWindow::~TurndownPromptWindow() {}
+// static
+void TurndownPromptWindow::SetupBitmapButton(TurndownPromptWindow* instance) {
+ DCHECK(instance);
+ CWindow close_window = instance->GetDlgItem(IDDISMISS);
+ instance->close_button_.reset(new CFBitmapButton());
+
+ // Set the resource instance to the current dll which contains the bitmap.
+ HINSTANCE old_res_module = _AtlBaseModule.GetResourceInstance();
+ HINSTANCE this_module = _AtlBaseModule.GetModuleInstance();
+ _AtlBaseModule.SetResourceInstance(this_module);
+
+ HBITMAP close_bitmap = static_cast<HBITMAP>(
+ LoadImage(this_module, MAKEINTRESOURCE(IDB_TURNDOWN_PROMPT_CLOSE_BUTTON),
+ IMAGE_BITMAP, 0, 0, 0));
+
+ // Restore the module's resource instance.
+ _AtlBaseModule.SetResourceInstance(old_res_module);
+
+ // Create the image list with the appropriate size and colour mask.
+ instance->close_button_->m_ImageList.Create(kBitmapImageSize,
+ kBitmapImageSize,
+ ILC_COLOR8 | ILC_MASK, 4, 0);
+ instance->close_button_->m_ImageList.Add(close_bitmap, RGB(255, 0, 255));
+ instance->close_button_->m_ImageList.SetBkColor(CLR_NONE);
+
+ // Free up the original bitmap.
+ DeleteObject(close_bitmap);
+
+ // Configure the button states and initialize the button.
+ instance->close_button_->SetImages(0, 1, 2, 3);
+ instance->close_button_->SubclassWindow(close_window);
+
+ // The CDialogResize() implementation incorrectly captures the size
+ // of the bitmap image button. Reset it here to ensure that resizing works
+ // as desired.
+
+ // Find the resize data. The parameters here must match the resize map in
+ // turndown_prompt_window.h.
+ _AtlDlgResizeData resize_params = { IDDISMISS, DLSZ_CENTER_Y | DLSZ_MOVE_X };
+ int resize_index = instance->m_arrData.Find(resize_params);
+ DCHECK(resize_index > -1 && resize_index < instance->m_arrData.GetSize());
+
+ // Fiddle CDialogResize's internal data to fix up the size for the image
+ // control.
+ _AtlDlgResizeData& resize_data = instance->m_arrData[resize_index];
+ resize_data.m_rect.right = resize_data.m_rect.left + kBitmapImageSize;
+ resize_data.m_rect.top = 0;
+ resize_data.m_rect.bottom = kBitmapImageSize;
+}
+
void TurndownPromptWindow::OnFinalMessage(HWND) {
delete this;
}
void TurndownPromptWindow::OnDestroy() {
+ close_button_->m_ImageList.Destroy();
frame_ = NULL;
}
diff --git a/chrome_frame/turndown_prompt/turndown_prompt_window.h b/chrome_frame/turndown_prompt/turndown_prompt_window.h
index 626fca6..342e38a 100644
--- a/chrome_frame/turndown_prompt/turndown_prompt_window.h
+++ b/chrome_frame/turndown_prompt/turndown_prompt_window.h
@@ -28,8 +28,11 @@ class UrlLauncher;
namespace WTL {
class CHyperLink;
+class CBitmapButton;
} // namespace WTL
+class CFBitmapButton;
+
// Implements a dialog with text and buttons notifying the user that Chrome
// Frame is being turned down, offering them a link to learn more about moving
// to a modern browser.
@@ -68,8 +71,8 @@ class TurndownPromptWindow
BEGIN_DLGRESIZE_MAP(InfobarWindow)
DLGRESIZE_CONTROL(IDDISMISS, DLSZ_CENTER_Y | DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDUNINSTALL, DLSZ_CENTER_Y | DLSZ_MOVE_X)
- DLGRESIZE_CONTROL(IDC_TD_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_TD_PROMPT_LINK, DLSZ_CENTER_Y | DLSZ_MOVE_X)
+ DLGRESIZE_CONTROL(IDC_TD_PROMPT_MESSAGE, DLSZ_SIZE_Y | DLSZ_SIZE_X)
END_DLGRESIZE_MAP()
virtual void OnFinalMessage(HWND);
@@ -83,6 +86,9 @@ class TurndownPromptWindow
// The TurndownPromptWindow manages its own destruction.
virtual ~TurndownPromptWindow();
+ // Performs the necessary configuration to initialize a bitmap button.
+ static void SetupBitmapButton(TurndownPromptWindow* window);
+
// Event handlers.
void OnDestroy();
BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
@@ -101,6 +107,7 @@ class TurndownPromptWindow
InfobarContent::Frame* frame_; // Not owned by this instance
scoped_ptr<WTL::CHyperLink> link_;
+ scoped_ptr<CFBitmapButton> close_button_;
scoped_ptr<UrlLauncher> url_launcher_;
base::Closure uninstall_closure_;