diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-10 05:58:40 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-10 05:58:40 +0000 |
commit | 3ee83f2c99cecee4f712cbb6fd9084cb676287a0 (patch) | |
tree | 54d504f603c3277de2100ca8df544d141f2976d0 /views | |
parent | b1c25a2fdeade0e807af70df8136d5efa62033d2 (diff) | |
download | chromium_src-3ee83f2c99cecee4f712cbb6fd9084cb676287a0.zip chromium_src-3ee83f2c99cecee4f712cbb6fd9084cb676287a0.tar.gz chromium_src-3ee83f2c99cecee4f712cbb6fd9084cb676287a0.tar.bz2 |
Add a new ViewsDelegate interface and implementation in the windows browser UI.
Provides a way for saving and restoring window placement, obtaining system helpers etc.
http://crbug.com/11633
TEST=make sure window placement saving works, clipboard, and that windows in the taskbar have a chrome icon.
Review URL: http://codereview.chromium.org/113173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/DEPS | 6 | ||||
-rw-r--r-- | views/controls/message_box_view.cc | 7 | ||||
-rw-r--r-- | views/controls/text_field.cc | 10 | ||||
-rw-r--r-- | views/view.cc | 4 | ||||
-rw-r--r-- | views/views.vcproj | 4 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 7 | ||||
-rw-r--r-- | views/window/window_delegate.cc | 50 |
7 files changed, 35 insertions, 53 deletions
@@ -6,15 +6,9 @@ include_rules = [ # TODO(beng): sever these dependencies into chrome by either refactoring or # moving code into app/ - # message_box_view.cc, text_field.cc, window_delegate.cc - "+chrome/browser/browser_process.h", - # widget_win.cc "+chrome/app/chrome_dll_resource.h", - # window_delegate.cc - "+chrome/common/pref_service.h", - # TODO(beng): swap these with app/views specific generated resources. "+grit/generated_resources.h", "+grit/theme_resources.h", diff --git a/views/controls/message_box_view.cc b/views/controls/message_box_view.cc index 456bb6e..e0cf055 100644 --- a/views/controls/message_box_view.cc +++ b/views/controls/message_box_view.cc @@ -10,10 +10,10 @@ #include "base/message_loop.h" #include "base/scoped_clipboard_writer.h" #include "base/string_util.h" -#include "chrome/browser/browser_process.h" #include "grit/generated_resources.h" #include "views/controls/button/checkbox.h" #include "views/standard_layout.h" +#include "views/views_delegate.h" #include "views/window/client_view.h" static const int kDefaultMessageWidth = 320; @@ -95,7 +95,10 @@ bool MessageBoxView::AcceleratorPressed( // We only accepts Ctrl-C. DCHECK(accelerator.GetKeyCode() == 'C' && accelerator.IsCtrlDown()); - Clipboard* clipboard = g_browser_process->clipboard(); + if (!views::ViewsDelegate::views_delegate) + return false; + + Clipboard* clipboard = views::ViewsDelegate::views_delegate->GetClipboard(); if (!clipboard) return false; diff --git a/views/controls/text_field.cc b/views/controls/text_field.cc index 35e6d36..3c587dc 100644 --- a/views/controls/text_field.cc +++ b/views/controls/text_field.cc @@ -20,12 +20,12 @@ #include "base/scoped_clipboard_writer.h" #include "base/string_util.h" #include "base/win_util.h" -#include "chrome/browser/browser_process.h" #include "grit/generated_resources.h" #include "skia/ext/skia_utils_win.h" #include "views/controls/hwnd_view.h" #include "views/controls/menu/menu.h" #include "views/focus/focus_util_win.h" +#include "views/views_delegate.h" #include "views/widget/widget.h" using gfx::NativeTheme; @@ -420,8 +420,8 @@ void TextField::Edit::OnCopy() { const std::wstring text(GetSelectedText()); - if (!text.empty()) { - ScopedClipboardWriter scw(g_browser_process->clipboard()); + if (!text.empty() && ViewsDelegate::views_delegate) { + ScopedClipboardWriter scw(ViewsDelegate::views_delegate->GetClipboard()); scw.WriteText(text); } } @@ -782,10 +782,10 @@ void TextField::Edit::OnNonLButtonDown(UINT keys, const CPoint& point) { } void TextField::Edit::OnPaste() { - if (parent_->IsReadOnly()) + if (parent_->IsReadOnly() || !ViewsDelegate::views_delegate) return; - Clipboard* clipboard = g_browser_process->clipboard(); + Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard(); if (!clipboard->IsFormatAvailable(Clipboard::GetPlainTextWFormatType())) return; diff --git a/views/view.cc b/views/view.cc index f4ef13d..cb13cb9 100644 --- a/views/view.cc +++ b/views/view.cc @@ -19,6 +19,7 @@ #include "skia/include/SkShader.h" #include "views/background.h" #include "views/layout_manager.h" +#include "views/views_delegate.h" #include "views/widget/root_view.h" #include "views/widget/widget.h" #include "views/window/window.h" @@ -30,6 +31,9 @@ namespace views { // static +ViewsDelegate* ViewsDelegate::views_delegate = NULL; + +// static char View::kViewClassName[] = "views/View"; //////////////////////////////////////////////////////////////////////////////// diff --git a/views/views.vcproj b/views/views.vcproj index 1d1c269..096e269 100644 --- a/views/views.vcproj +++ b/views/views.vcproj @@ -909,6 +909,10 @@ RelativePath=".\view_win.cc" > </File> + <File + RelativePath=".\views_delegate.h" + > + </File> </Files> <Globals> </Globals> diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 25f25da..b092682 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -9,11 +9,11 @@ #include "base/gfx/native_theme.h" #include "base/string_util.h" #include "base/win_util.h" -#include "chrome/app/chrome_dll_resource.h" #include "views/accessibility/view_accessibility.h" #include "views/controls/native_control_win.h" #include "views/fill_layout.h" #include "views/focus/focus_util_win.h" +#include "views/views_delegate.h" #include "views/widget/aero_tooltip_manager.h" #include "views/widget/default_theme_provider.h" #include "views/widget/root_view.h" @@ -920,8 +920,9 @@ std::wstring WidgetWin::GetWindowClassName() { class_ex.cbClsExtra = 0; class_ex.cbWndExtra = 0; class_ex.hInstance = NULL; - class_ex.hIcon = LoadIcon(GetModuleHandle(L"chrome.dll"), - MAKEINTRESOURCE(IDR_MAINFRAME)); + class_ex.hIcon = NULL; + if (ViewsDelegate::views_delegate) + class_ex.hIcon = ViewsDelegate::views_delegate->GetDefaultWindowIcon(); class_ex.hCursor = LoadCursor(NULL, IDC_ARROW); class_ex.hbrBackground = reinterpret_cast<HBRUSH>(class_info.background + 1); class_ex.lpszMenuName = NULL; diff --git a/views/window/window_delegate.cc b/views/window/window_delegate.cc index 7b5f251..5442743 100644 --- a/views/window/window_delegate.cc +++ b/views/window/window_delegate.cc @@ -3,10 +3,7 @@ // found in the LICENSE file. #include "views/window/window_delegate.h" - -// TODO(beng): hrmp. Fix this in http://crbug.com/4406 -#include "chrome/browser/browser_process.h" -#include "chrome/common/pref_service.h" +#include "views/views_delegate.h" #include "views/window/client_view.h" #include "views/window/window.h" #include "skia/include/SkBitmap.h" @@ -29,59 +26,38 @@ void WindowDelegate::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized, bool always_on_top) { std::wstring window_name = GetWindowName(); - if (window_name.empty() || !g_browser_process->local_state()) + if (!ViewsDelegate::views_delegate || window_name.empty()) return; - DictionaryValue* window_preferences = - g_browser_process->local_state()->GetMutableDictionary( - window_name.c_str()); - window_preferences->SetInteger(L"left", bounds.x()); - window_preferences->SetInteger(L"top", bounds.y()); - window_preferences->SetInteger(L"right", bounds.right()); - window_preferences->SetInteger(L"bottom", bounds.bottom()); - window_preferences->SetBoolean(L"maximized", maximized); - window_preferences->SetBoolean(L"always_on_top", always_on_top); + ViewsDelegate::views_delegate->SaveWindowPlacement( + window_name, bounds, maximized, always_on_top); } bool WindowDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const { std::wstring window_name = GetWindowName(); - if (window_name.empty()) - return false; - - const DictionaryValue* dictionary = - g_browser_process->local_state()->GetDictionary(window_name.c_str()); - int left, top, right, bottom; - if (!dictionary || !dictionary->GetInteger(L"left", &left) || - !dictionary->GetInteger(L"top", &top) || - !dictionary->GetInteger(L"right", &right) || - !dictionary->GetInteger(L"bottom", &bottom)) + if (!ViewsDelegate::views_delegate || window_name.empty()) return false; - bounds->SetRect(left, top, right - left, bottom - top); - return true; + return ViewsDelegate::views_delegate->GetSavedWindowBounds( + window_name, bounds); } bool WindowDelegate::GetSavedMaximizedState(bool* maximized) const { std::wstring window_name = GetWindowName(); - if (window_name.empty()) + if (!ViewsDelegate::views_delegate || window_name.empty()) return false; - const DictionaryValue* dictionary = - g_browser_process->local_state()->GetDictionary(window_name.c_str()); - return dictionary && dictionary->GetBoolean(L"maximized", maximized); + return ViewsDelegate::views_delegate->GetSavedMaximizedState( + window_name, maximized); } bool WindowDelegate::GetSavedAlwaysOnTopState(bool* always_on_top) const { - if (!g_browser_process->local_state()) - return false; - std::wstring window_name = GetWindowName(); - if (window_name.empty()) + if (!ViewsDelegate::views_delegate || window_name.empty()) return false; - const DictionaryValue* dictionary = - g_browser_process->local_state()->GetDictionary(window_name.c_str()); - return dictionary && dictionary->GetBoolean(L"always_on_top", always_on_top); + return ViewsDelegate::views_delegate->GetSavedAlwaysOnTopState( + window_name, always_on_top); } |