diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 01:41:05 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-15 01:41:05 +0000 |
commit | cdab86bbc35e4d2669b2e32cef85109de5a17b8d (patch) | |
tree | 368ba68d22c537d93d09b90ff2b89b49e0f4a07d /chrome | |
parent | 781c7f2ba5c5e6e0c2a480312fc4866afc9d08e2 (diff) | |
download | chromium_src-cdab86bbc35e4d2669b2e32cef85109de5a17b8d.zip chromium_src-cdab86bbc35e4d2669b2e32cef85109de5a17b8d.tar.gz chromium_src-cdab86bbc35e4d2669b2e32cef85109de5a17b8d.tar.bz2 |
Remove SelectFontDialog
this code is no longer used now that native options are gone
BUG=72658
TEST=compile
Review URL: http://codereview.chromium.org/6696004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
6 files changed, 29 insertions, 265 deletions
diff --git a/chrome/browser/resources/options/chromeos_internet_detail.html b/chrome/browser/resources/options/chromeos_internet_detail.html index 8feef75..d31c806 100644 --- a/chrome/browser/resources/options/chromeos_internet_detail.html +++ b/chrome/browser/resources/options/chromeos_internet_detail.html @@ -1,5 +1,5 @@ <div class="page hidden" id="detailsInternetPage"> - <h1 id="detailsInternetTitle"></h1> + <h1 id="inetTitle"></h1> <!-- Navigation tabs --> <div class="subpages-nav-tabs" id="details-tab-strip"> <span id="wifiNetworkNavTab" class="tab wifi-details" diff --git a/chrome/browser/resources/options/chromeos_internet_options.js b/chrome/browser/resources/options/chromeos_internet_options.js index 88ffbb5..1152cfd 100644 --- a/chrome/browser/resources/options/chromeos_internet_options.js +++ b/chrome/browser/resources/options/chromeos_internet_options.js @@ -273,12 +273,10 @@ cr.define('options', function() { } if (data.connected) { page.setAttribute('connected', data.connected); - $('detailsInternetTitle').textContent = - localStrings.getString('inetStatus'); + $('inetTitle').textContent = localStrings.getString('inetStatus'); } else { page.removeAttribute('connected'); - $('detailsInternetTitle').textContent = - localStrings.getString('inetConnect'); + $('inetTitle').textContent = localStrings.getString('inetConnect'); $('detailsInternetLogin').classList.remove('hidden'); } $('connectionState').textContent = data.connectionState; diff --git a/chrome/browser/resources/options/chromeos_internet_options_page.css b/chrome/browser/resources/options/chromeos_internet_options_page.css index 508b10e..9acbec8 100644 --- a/chrome/browser/resources/options/chromeos_internet_options_page.css +++ b/chrome/browser/resources/options/chromeos_internet_options_page.css @@ -1,7 +1,30 @@ -#detailsInternetTitle { +/* + * TODO(xiyuan): Remove the section overrides when options_page.css uses the + * new style. + */ +#inetTitle { border: none; } +#internetPage > section > h3 { + font-size: 100%; + width: auto; +} + +#internetPage > section[hidden] { + display: none; +} + +#networkingControls { + display: -webkit-box; + -webkit-margin-start: 10px; +} + +.networks { + -webkit-margin-start: 15px; + padding: 2px; +} + .network-password { left: 0px; position: relative; @@ -66,6 +89,7 @@ html[dir='rtl'] .network-item-text { background: right center no-repeat; } + .network-item[connected] > * > .network-name-label { font-weight: bold; } diff --git a/chrome/browser/ui/shell_dialogs.cc b/chrome/browser/ui/shell_dialogs.cc index 01dce47..9b9bc6e 100644 --- a/chrome/browser/ui/shell_dialogs.cc +++ b/chrome/browser/ui/shell_dialogs.cc @@ -11,7 +11,3 @@ SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} SelectFileDialog::SelectFileDialog() {} SelectFileDialog::~SelectFileDialog() {} - -SelectFontDialog::SelectFontDialog() {} - -SelectFontDialog::~SelectFontDialog() {} diff --git a/chrome/browser/ui/shell_dialogs.h b/chrome/browser/ui/shell_dialogs.h index f691c34..5d099b0 100644 --- a/chrome/browser/ui/shell_dialogs.h +++ b/chrome/browser/ui/shell_dialogs.h @@ -14,10 +14,6 @@ #include "base/string16.h" #include "ui/gfx/native_widget_types.h" -namespace gfx { -class Font; -} - // This function is declared extern such that it is accessible for unit tests // in /chrome/browser/ui/views/shell_dialogs_win_unittest.cc extern std::wstring AppendExtensionIfNeeded(const std::wstring& filename, @@ -142,61 +138,4 @@ class SelectFileDialog virtual ~SelectFileDialog(); }; -// Shows a dialog box for selecting a font. -class SelectFontDialog - : public base::RefCountedThreadSafe<SelectFontDialog>, - public BaseShellDialog { - public: - - // An interface implemented by a Listener object wishing to know about the - // the result of the Select Font action. These callbacks must be - // re-entrant. - class Listener { - public: - // Notifies the Listener that a font selection has been made. The font - // details are supplied in |font|. |params| is contextual passed to - // SelectFont. - virtual void FontSelected(const gfx::Font& font, void* params) = 0; - - // Notifies the Listener that the font selection was aborted (via the user - // canceling or closing the selection dialog box, for example). |params| is - // contextual passed to SelectFont. - virtual void FontSelectionCanceled(void* params) {} - - protected: - virtual ~Listener() {} - }; - - // Creates a dialog box helper. This object is ref-counted, but the returned - // object will have no reference (refcount is 0). - static SelectFontDialog* Create(Listener* listener); - - // Selects a font. This will start displaying the dialog box. This will also - // block the calling window until the dialog box is complete. The listener - // associated with this object will be notified when the selection is - // complete. - // |owning_window| is the window the dialog is modal to, or NULL for a - // modeless dialog. - // |params| is data from the calling context which will be passed through to - // the listener. Can be NULL. - // NOTE: only one instance of any shell dialog can be shown per owning_window - // at a time (for obvious reasons). - // TODO(beng): support specifying the default font selected in the list when - // the dialog appears. - virtual void SelectFont(gfx::NativeWindow owning_window, - void* params) = 0; - - // Same as above - also support specifying the default font selected in the - // list when the dialog appears. - virtual void SelectFont(gfx::NativeWindow owning_window, - void* params, - const std::wstring& font_name, - int font_size) = 0; - - protected: - friend class base::RefCountedThreadSafe<SelectFontDialog>; - SelectFontDialog(); - virtual ~SelectFontDialog(); -}; - #endif // CHROME_BROWSER_UI_SHELL_DIALOGS_H_ diff --git a/chrome/browser/ui/views/shell_dialogs_win.cc b/chrome/browser/ui/views/shell_dialogs_win.cc index 0fa87c7..f4144e0 100644 --- a/chrome/browser/ui/views/shell_dialogs_win.cc +++ b/chrome/browser/ui/views/shell_dialogs_win.cc @@ -24,7 +24,6 @@ #include "grit/app_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/gfx/font.h" // This function takes the output of a SaveAs dialog: a filename, a filter and // the extension originally suggested to the user (shown in the dialog box) and @@ -454,7 +453,7 @@ class BaseShellDialogImpl { // The derived class must call EndRun once the dialog is done showing to // remove the owning HWND from this list. // This object is static since it is maintained for all instances of this - // object - i.e. you can't have a font picker and a file picker open for the + // object - i.e. you can't have two file pickers open for the // same owner, even though they might be represented by different instances // of this object. // This set only contains non-null HWNDs. NULL hwnds are not added to this @@ -939,195 +938,3 @@ bool SelectFileDialogImpl::RunOpenMultiFileDialog( SelectFileDialog* SelectFileDialog::Create(Listener* listener) { return new SelectFileDialogImpl(listener); } - -/////////////////////////////////////////////////////////////////////////////// -// SelectFontDialogImpl -// Implementation of SelectFontDialog that shows a Windows common dialog for -// choosing a font. -class SelectFontDialogImpl : public SelectFontDialog, - public BaseShellDialogImpl { - public: - explicit SelectFontDialogImpl(Listener* listener); - - // SelectFontDialog implementation: - virtual void SelectFont(HWND owning_hwnd, void* params); - virtual void SelectFont(HWND owning_hwnd, - void* params, - const std::wstring& font_name, - int font_size); - virtual bool IsRunning(HWND owning_hwnd) const; - virtual void ListenerDestroyed(); - - private: - virtual ~SelectFontDialogImpl(); - - // Shows the font selection dialog modal to |owner| and calls the result - // back on the ui thread. Run on the dialog thread. - void ExecuteSelectFont(RunState run_state, void* params); - - // Shows the font selection dialog modal to |owner| and calls the result - // back on the ui thread. Run on the dialog thread. - void ExecuteSelectFontWithNameSize(RunState run_state, - void* params, - const std::wstring& font_name, - int font_size); - - // Notifies the listener that a font was chosen. Run on the ui thread. - void FontSelected(LOGFONT logfont, void* params, RunState run_state); - - // Notifies the listener that no font was chosen (the action was canceled). - // Run on the ui thread. - void FontNotSelected(void* params, RunState run_state); - - // The listener to be notified of selection completion. - Listener* listener_; - - DISALLOW_COPY_AND_ASSIGN(SelectFontDialogImpl); -}; - -SelectFontDialogImpl::SelectFontDialogImpl(Listener* listener) - : listener_(listener), - BaseShellDialogImpl() { -} - -SelectFontDialogImpl::~SelectFontDialogImpl() { -} - -void SelectFontDialogImpl::SelectFont(HWND owner, void* params) { - RunState run_state = BeginRun(owner); - run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(this, &SelectFontDialogImpl::ExecuteSelectFont, - run_state, params)); -} - -void SelectFontDialogImpl::SelectFont(HWND owner, void* params, - const std::wstring& font_name, - int font_size) { - RunState run_state = BeginRun(owner); - run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(this, - &SelectFontDialogImpl::ExecuteSelectFontWithNameSize, run_state, - params, font_name, font_size)); -} - -bool SelectFontDialogImpl::IsRunning(HWND owning_hwnd) const { - return listener_ && IsRunningDialogForOwner(owning_hwnd); -} - -void SelectFontDialogImpl::ListenerDestroyed() { - // Our associated listener has gone away, so we shouldn't call back to it if - // our worker thread returns after the listener is dead. - listener_ = NULL; -} - -void SelectFontDialogImpl::ExecuteSelectFont(RunState run_state, void* params) { - LOGFONT logfont; - CHOOSEFONT cf; - cf.lStructSize = sizeof(cf); - cf.hwndOwner = run_state.owner; - cf.lpLogFont = &logfont; - cf.Flags = CF_SCREENFONTS; - bool success = !!ChooseFont(&cf); - DisableOwner(run_state.owner); - if (success) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - NewRunnableMethod( - this, &SelectFontDialogImpl::FontSelected, logfont, params, - run_state)); - } else { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - NewRunnableMethod( - this, &SelectFontDialogImpl::FontNotSelected, params, run_state)); - } -} - -void SelectFontDialogImpl::ExecuteSelectFontWithNameSize( - RunState run_state, void* params, const std::wstring& font_name, - int font_size) { - // Create the HFONT from font name and size. - HDC hdc = GetDC(NULL); - long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72); - ReleaseDC(NULL, hdc); - HFONT hf = ::CreateFont(lf_height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - font_name.c_str()); - LOGFONT logfont; - GetObject(hf, sizeof(LOGFONT), &logfont); - // Retrieve the localized face name of the above font and update the LOGFONT - // structure. When a font has a localized name matching to the system locale, - // GetTextFace() returns the localized name. We should pass this localized - // name to ChooseFont() so it can set the focus. - HDC memory_dc = CreateCompatibleDC(NULL); - if (memory_dc) { - wchar_t localized_font_name[LF_FACESIZE]; - HFONT original_font = reinterpret_cast<HFONT>(SelectObject(memory_dc, hf)); - int length = GetTextFace(memory_dc, arraysize(localized_font_name), - &localized_font_name[0]); - if (length > 0) { - memcpy(&logfont.lfFaceName[0], &localized_font_name[0], - sizeof(localized_font_name)); - } - SelectObject(memory_dc, original_font); - DeleteDC(memory_dc); - } - CHOOSEFONT cf; - cf.lStructSize = sizeof(cf); - cf.hwndOwner = run_state.owner; - cf.lpLogFont = &logfont; - // Limit the list to a reasonable subset of fonts. - // TODO : get rid of style selector and script selector - // 1. List only truetype font - // 2. Exclude vertical fonts (whose names begin with '@') - // 3. Exclude symbol and OEM fonts - // 4. Limit the size to [8, 40]. - // See http://msdn.microsoft.com/en-us/library/ms646832(VS.85).aspx - cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_TTONLY | - CF_NOVERTFONTS | CF_SCRIPTSONLY | CF_LIMITSIZE; - - // These limits are arbitrary and needs to be revisited. Is it bad - // to clamp the size at 40 from A11Y point of view? - cf.nSizeMin = 8; - cf.nSizeMax = 40; - - bool success = !!ChooseFont(&cf); - DisableOwner(run_state.owner); - if (success) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - NewRunnableMethod( - this, &SelectFontDialogImpl::FontSelected, logfont, params, - run_state)); - } else { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &SelectFontDialogImpl::FontNotSelected, params, - run_state)); - } -} - -void SelectFontDialogImpl::FontSelected(LOGFONT logfont, - void* params, - RunState run_state) { - if (listener_) { - HFONT font = CreateFontIndirect(&logfont); - if (font) { - listener_->FontSelected(gfx::Font(font), params); - DeleteObject(font); - } else { - listener_->FontSelectionCanceled(params); - } - } - EndRun(run_state); -} - -void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { - if (listener_) - listener_->FontSelectionCanceled(params); - EndRun(run_state); -} - -// static -SelectFontDialog* SelectFontDialog::Create(Listener* listener) { - return new SelectFontDialogImpl(listener); -} |