summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 17:15:22 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-19 17:15:22 +0000
commit5275c3dbc87f48da96a2880c2ac12e956c18784c (patch)
tree1c1a15bba4f850e55fcc444ba5f53a488082a97d /chrome
parentc6f26b5d3fb527d4731b08553fd2ba8272df550f (diff)
downloadchromium_src-5275c3dbc87f48da96a2880c2ac12e956c18784c.zip
chromium_src-5275c3dbc87f48da96a2880c2ac12e956c18784c.tar.gz
chromium_src-5275c3dbc87f48da96a2880c2ac12e956c18784c.tar.bz2
Do work necessary to make Views About panel work on Chrome OS. This is to be used for forcing Chrome OS updates.
There were many things that needed to be fixed for this to work. Make skia's canvas return height of font for size of strings, instead of the actual height of the characters to bring it in line with Windows. Make average character widths use pango metrics and windows dialog units. Make this lazy, to avoid most calls. Fix bug in About panel that failed to adjust the embedded links to allow for the padding that Link adds so they can be focused. Support gtk about panel in regular build, views in chrome os only. Fix WindowGtk to call WindowClosing() Fix canvas_linux::SetupPangoLayout() to wrap correctly, if passed a width Fix Label::ComputeMultiLineFlags() to turn off eliding. With eliding the pango routines always return 1 line. Enable focus manager in dialogs. Version loader crashed in debug. Review URL: http://codereview.chromium.org/282002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-x[-rw-r--r--]chrome/browser/chromeos/chromeos_version_loader.h2
-rwxr-xr-xchrome/browser/gtk/browser_window_gtk.cc5
-rwxr-xr-x[-rw-r--r--]chrome/browser/views/about_chrome_view.cc48
-rwxr-xr-x[-rw-r--r--]chrome/browser/views/about_chrome_view.h18
-rwxr-xr-x[-rw-r--r--]chrome/browser/views/browser_dialogs.h2
-rwxr-xr-x[-rw-r--r--]chrome/browser/views/dialog_stubs_gtk.cc7
-rwxr-xr-x[-rw-r--r--]chrome/browser/views/frame/browser_view.cc3
-rwxr-xr-xchrome/chrome.gyp4
8 files changed, 64 insertions, 25 deletions
diff --git a/chrome/browser/chromeos/chromeos_version_loader.h b/chrome/browser/chromeos/chromeos_version_loader.h
index 85047b0..1dccd31 100644..100755
--- a/chrome/browser/chromeos/chromeos_version_loader.h
+++ b/chrome/browser/chromeos/chromeos_version_loader.h
@@ -40,7 +40,7 @@ class ChromeOSVersionLoader : public CancelableRequestProvider {
// ChromeOSVersionLoader calls into the Backend on the file thread to load
// and extract the version.
- class Backend : public base::RefCounted<Backend> {
+ class Backend : public base::RefCountedThreadSafe<Backend> {
public:
Backend() {}
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 8bb1540..60834d6 100755
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -81,6 +81,7 @@
#include "chrome/browser/chromeos/compact_navigation_bar.h"
#include "chrome/browser/chromeos/main_menu.h"
#include "chrome/browser/chromeos/status_area_view.h"
+#include "chrome/browser/views/browser_dialogs.h"
#include "chrome/browser/views/panel_controller.h"
#include "chrome/browser/views/tabs/tab_overview_types.h"
#include "views/widget/widget_gtk.h"
@@ -1059,7 +1060,11 @@ void BrowserWindowGtk::ToggleExtensionShelf() {
}
void BrowserWindowGtk::ShowAboutChromeDialog() {
+#if defined(OS_CHROMEOS)
+ browser::ShowAboutChromeView(window_, browser_->profile());
+#else
ShowAboutDialogForProfile(window_, browser_->profile());
+#endif
}
void BrowserWindowGtk::ShowTaskManager() {
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index 6c2dad1..63fabce 100644..100755
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/views/about_chrome_view.h"
-#include <commdlg.h>
-
#include "app/gfx/canvas.h"
#include "app/gfx/color_utils.h"
#include "base/i18n/word_iterator.h"
@@ -13,13 +11,10 @@
#include "app/resource_bundle.h"
#include "base/file_version_info.h"
#include "base/string_util.h"
-#include "base/win_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/views/restart_message_box.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/url_constants.h"
-#include "chrome/installer/util/install_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -31,6 +26,14 @@
#include "views/window/window.h"
#include "webkit/glue/webkit_glue.h"
+#if defined(OS_WIN)
+#include <commdlg.h>
+
+#include "base/win_util.h"
+#include "chrome/browser/views/restart_message_box.h"
+#include "chrome/installer/util/install_util.h"
+#endif
+
namespace {
// The pixel width of the version text field. Ideally, we'd like to have the
// bounds set to the edge of the icon. However, the icon is not a view but a
@@ -63,9 +66,10 @@ std::wstring StringSubRange(const std::wstring& text, size_t start,
namespace browser {
// Declared in browser_dialogs.h so that others don't need to depend on our .h.
-void ShowAboutChromeView(views::Widget* parent,
+void ShowAboutChromeView(gfx::NativeWindow parent,
Profile* profile) {
- views::Window::CreateChromeWindow(parent->GetNativeView(), gfx::Rect(),
+ views::Window::CreateChromeWindow(parent,
+ gfx::Rect(),
new AboutChromeView(profile))->Show();
}
@@ -82,17 +86,19 @@ AboutChromeView::AboutChromeView(Profile* profile)
copyright_label_(NULL),
main_text_label_(NULL),
main_text_label_height_(0),
- terms_of_service_url_(NULL),
chromium_url_(NULL),
open_source_url_(NULL),
- chromium_url_appears_first_(true),
+ terms_of_service_url_(NULL),
check_button_status_(CHECKBUTTON_HIDDEN),
+ chromium_url_appears_first_(true),
text_direction_is_rtl_(false) {
DCHECK(profile);
Init();
+#if defined(OS_WIN)
google_updater_ = new GoogleUpdate();
google_updater_->AddStatusChangeListener(this);
+#endif
if (kBackgroundBmp == NULL) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -101,10 +107,12 @@ AboutChromeView::AboutChromeView(Profile* profile)
}
AboutChromeView::~AboutChromeView() {
+#if defined(OS_WIN)
// The Google Updater will hold a pointer to us until it reports status, so we
// need to let it know that we will no longer be listening.
if (google_updater_)
google_updater_->RemoveStatusChangeListener();
+#endif
}
void AboutChromeView::Init() {
@@ -165,19 +173,19 @@ void AboutChromeView::Init() {
about_title_label_ = new views::Label(
l10n_util::GetString(IDS_PRODUCT_NAME));
about_title_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(18, BOLD_FONTTYPE));
+ ResourceBundle::BaseFont).DeriveFont(18, gfx::Font::BOLD));
about_title_label_->SetColor(SK_ColorBLACK);
AddChildView(about_title_label_);
// This is a text field so people can copy the version number from the dialog.
version_label_ = new views::Textfield();
- version_label_->SetText(current_version_);
+ version_label_->SetText(WideToUTF16Hack(current_version_));
version_label_->SetReadOnly(true);
version_label_->RemoveBorder();
version_label_->SetTextColor(SK_ColorBLACK);
version_label_->SetBackgroundColor(SK_ColorWHITE);
version_label_->SetFont(ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(0, BOLD_FONTTYPE));
+ ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD));
AddChildView(version_label_);
// The copyright URL portion of the main label.
@@ -476,9 +484,10 @@ void AboutChromeView::DrawTextAndPositionUrl(gfx::Canvas* canvas,
// figure out here where to place it.
if (link && rect) {
gfx::Size sz = link->GetPreferredSize();
+ gfx::Insets insets = link->GetInsets();
WrapIfWordDoesntFit(sz.width(), font.height(), position, bounds);
- *rect = gfx::Rect(position->width(), position->height(), sz.width(),
- sz.height());
+ *rect = gfx::Rect(position->width(), position->height() - insets.top(),
+ sz.width(), sz.height());
// Go from relative pixel coordinates (within the label we are drawing on)
// to absolute pixel coordinates (relative to the top left corner of the
@@ -499,7 +508,7 @@ void AboutChromeView::DrawTextStartingFrom(gfx::Canvas* canvas,
const SkColor text_color = color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
#else
// TODO(beng): source from theme provider.
- const SkColor text_color = SkColor_BLACK;
+ const SkColor text_color = SK_ColorBLACK;
#endif
// Iterate through line breaking opportunities (which in English would be
@@ -591,6 +600,7 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
parent->AddChildView(&timeout_indicator_);
timeout_indicator_.SetVisible(false);
+#if defined (OS_WIN)
// On-demand updates for Chrome don't work in Vista RTM when UAC is turned
// off. So, in this case we just want the About box to not mention
// on-demand updates. Silent updates (in the background) should still
@@ -607,6 +617,7 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
// CheckForUpdate(false, ...) means don't upgrade yet.
google_updater_->CheckForUpdate(false, window());
}
+#endif
} else {
parent->RemoveChildView(&update_label_);
parent->RemoveChildView(throbber_.get());
@@ -680,6 +691,7 @@ std::wstring AboutChromeView::GetWindowTitle() const {
}
bool AboutChromeView::Accept() {
+#if defined(OS_WIN)
UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR);
// The Upgrade button isn't available until we have received notification
@@ -690,6 +702,7 @@ bool AboutChromeView::Accept() {
google_updater_->AddStatusChangeListener(this);
// CheckForUpdate(true,...) means perform the upgrade if new version found.
google_updater_->CheckForUpdate(true, window());
+#endif
return false; // We never allow this button to close the window.
}
@@ -707,7 +720,7 @@ void AboutChromeView::LinkActivated(views::Link* source,
if (source == terms_of_service_url_)
url = GURL(chrome::kAboutTermsURL);
else if (source == chromium_url_)
- url = GURL(l10n_util::GetString(IDS_CHROMIUM_PROJECT_URL));
+ url = GURL(WideToUTF16Hack(l10n_util::GetString(IDS_CHROMIUM_PROJECT_URL)));
else if (source == open_source_url_)
url = GURL(chrome::kAboutCreditsURL);
else
@@ -717,6 +730,7 @@ void AboutChromeView::LinkActivated(views::Link* source,
browser->OpenURL(url, GURL(), NEW_WINDOW, PageTransition::LINK);
}
+#if defined(OS_WIN)
////////////////////////////////////////////////////////////////////////////////
// AboutChromeView, GoogleUpdateStatusListener implementation:
@@ -843,3 +857,5 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
if (window())
GetDialogClientView()->UpdateDialogButtons();
}
+
+#endif
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 8935cf9..cfb8a03 100644..100755
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -5,13 +5,16 @@
#ifndef CHROME_BROWSER_VIEWS_ABOUT_CHROME_VIEW_H_
#define CHROME_BROWSER_VIEWS_ABOUT_CHROME_VIEW_H_
-#include "chrome/browser/google_update.h"
#include "views/controls/image_view.h"
#include "views/controls/label.h"
#include "views/controls/link.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
+#if defined(OS_WIN)
+#include "chrome/browser/google_update.h"
+#endif
+
namespace views {
class Textfield;
class Throbber;
@@ -29,8 +32,11 @@ class Profile;
////////////////////////////////////////////////////////////////////////////////
class AboutChromeView : public views::View,
public views::DialogDelegate,
- public views::LinkController,
- public GoogleUpdateStatusListener {
+ public views::LinkController
+#if defined (OS_WIN)
+ , public GoogleUpdateStatusListener
+#endif
+ {
public:
explicit AboutChromeView(Profile* profile);
virtual ~AboutChromeView();
@@ -65,10 +71,12 @@ class AboutChromeView : public views::View,
// Overridden from views::LinkController:
virtual void LinkActivated(views::Link* source, int event_flags);
+#if defined(OS_WIN)
// Overridden from GoogleUpdateStatusListener:
virtual void OnReportResults(GoogleUpdateUpgradeResult result,
GoogleUpdateErrorCode error_code,
const std::wstring& version);
+#endif
private:
// The visible state of the Check For Updates button.
@@ -78,9 +86,11 @@ class AboutChromeView : public views::View,
CHECKBUTTON_ENABLED,
};
+#if defined(OS_WIN)
// Update the UI to show the status of the upgrade.
void UpdateStatus(GoogleUpdateUpgradeResult result,
GoogleUpdateErrorCode error_code);
+#endif
// Draws a string onto the canvas (wrapping if needed) while also keeping
// track of where it ends so we can position a URL after the text. The
@@ -160,9 +170,11 @@ class AboutChromeView : public views::View,
// Determines the order of the two links we draw in the main label.
bool chromium_url_appears_first_;
+#if defined(OS_WIN)
// The class that communicates with Google Update to find out if an update is
// available and asks it to start an upgrade.
scoped_refptr<GoogleUpdate> google_updater_;
+#endif
// Our current version.
std::wstring current_version_;
diff --git a/chrome/browser/views/browser_dialogs.h b/chrome/browser/views/browser_dialogs.h
index d4c2420..691eee6 100644..100755
--- a/chrome/browser/views/browser_dialogs.h
+++ b/chrome/browser/views/browser_dialogs.h
@@ -64,7 +64,7 @@ bool IsBookmarkBubbleViewShowing();
void ShowBookmarkManagerView(Profile* profile);
// Shows the about dialog. See AboutChromeView.
-void ShowAboutChromeView(views::Widget* parent,
+void ShowAboutChromeView(gfx::NativeWindow parent,
Profile* profile);
// Shows an HTML dialog. See HtmlDialogView.
diff --git a/chrome/browser/views/dialog_stubs_gtk.cc b/chrome/browser/views/dialog_stubs_gtk.cc
index c3a4e13..53bfc58 100644..100755
--- a/chrome/browser/views/dialog_stubs_gtk.cc
+++ b/chrome/browser/views/dialog_stubs_gtk.cc
@@ -51,10 +51,11 @@ void ShowBookmarkManagerView(Profile* profile) {
BookmarkManagerGtk::Show(profile);
}
-void ShowAboutChromeView(views::Widget* parent,
- Profile* profile) {
- ShowAboutDialogForProfile(GTK_WINDOW(parent->GetNativeView()), profile);
+#if not defined(OS_CHROMEOS)
+void ShowAboutChromeView(gfx::NativeWindow parent, Profile* profile) {
+ ShowAboutDialogForProfile(parent, profile);
}
+#endif
void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser,
HtmlDialogUIDelegate* delegate) {
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index f75af67..e721862 100644..100755
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1003,7 +1003,8 @@ void BrowserView::ToggleExtensionShelf() {
}
void BrowserView::ShowAboutChromeDialog() {
- browser::ShowAboutChromeView(GetWidget(), browser_->profile());
+ browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(),
+ browser_->profile());
}
void BrowserView::ShowTaskManager() {
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 9b34464..2ec85fc 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2894,6 +2894,10 @@
'<(INTERMEDIATE_DIR)/chrome',
],
'sources/': [
+ ['include', 'browser/views/about_chrome_view.cc'],
+ ['include', 'browser/views/about_chrome_view.h'],
+ ['exclude', 'browser/gtk/about_chrome_dialog.cc'],
+ ['exclude', 'browser/gtk/about_chrome_dialog.h'],
['include', 'browser/views/new_browser_window_widget.cc'],
['include', 'browser/views/new_browser_window_widget.h'],
['include', 'browser/views/options/options_page_view.cc'],