diff options
-rw-r--r-- | chrome/browser/views/browser_views.vcproj | 8 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 3 | ||||
-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 |
9 files changed, 46 insertions, 53 deletions
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index 3a79320..d2594d0 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -498,6 +498,14 @@ > </File> <File + RelativePath=".\chrome_views_delegate.cc" + > + </File> + <File + RelativePath=".\chrome_views_delegate.h" + > + </File> + <File RelativePath=".\clear_browsing_data.cc" > </File> diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 4eb6c34..b3aa486 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -28,6 +28,7 @@ #include "chrome/browser/views/bookmark_bubble_view.h" #include "chrome/browser/views/bookmark_manager_view.h" #include "chrome/browser/views/bug_report_view.h" +#include "chrome/browser/views/chrome_views_delegate.h" #include "chrome/browser/views/clear_browsing_data.h" #include "chrome/browser/views/download_shelf_view.h" #include "chrome/browser/views/find_bar_win.h" @@ -1667,6 +1668,8 @@ void BrowserView::InitClass() { // static BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { + if (!views::ViewsDelegate::views_delegate) + views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; BrowserView* browser_view = new BrowserView(browser); (new BrowserFrame(browser_view, browser->profile()))->Init(); return browser_view; @@ -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); } |