summaryrefslogtreecommitdiffstats
path: root/chrome/browser/frame_util.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-10 22:04:15 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-10 22:04:15 +0000
commita5a7eb258c1d2092f671e38a83b8eeb3931e4ed3 (patch)
treedda2ba507920cbbc7d80be98e78eed92681cb95e /chrome/browser/frame_util.cc
parent6242f020fdcfdba371613270beeb89f5bf606d11 (diff)
downloadchromium_src-a5a7eb258c1d2092f671e38a83b8eeb3931e4ed3.zip
chromium_src-a5a7eb258c1d2092f671e38a83b8eeb3931e4ed3.tar.gz
chromium_src-a5a7eb258c1d2092f671e38a83b8eeb3931e4ed3.tar.bz2
Removes the old frames.
http://crbug.com/2324 Review URL: http://codereview.chromium.org/10265 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5130 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/frame_util.cc')
-rw-r--r--chrome/browser/frame_util.cc124
1 files changed, 5 insertions, 119 deletions
diff --git a/chrome/browser/frame_util.cc b/chrome/browser/frame_util.cc
index 9580c4e..b7cccd7 100644
--- a/chrome/browser/frame_util.cc
+++ b/chrome/browser/frame_util.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/frame_util.h"
+#include "base/base_switches.h"
+#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/win_util.h"
#include "chrome/app/result_codes.h"
@@ -15,10 +17,6 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/render_view_host.h"
-#include "chrome/browser/views/old_frames/simple_vista_frame.h"
-#include "chrome/browser/views/old_frames/simple_xp_frame.h"
-#include "chrome/browser/views/old_frames/vista_frame.h"
-#include "chrome/browser/views/old_frames/xp_frame.h"
#include "chrome/browser/web_contents.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/win_util.h"
@@ -28,127 +26,16 @@
static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__";
// static
-void FrameUtil::RegisterBrowserWindow(BrowserWindow* frame) {
- DCHECK(!g_browser_process->IsUsingNewFrames());
- HWND h = reinterpret_cast<HWND>(frame->GetPlatformID());
- win_util::SetWindowUserData(h, frame);
-}
-
-// static
BrowserWindow* FrameUtil::GetBrowserWindowForHWND(HWND hwnd) {
if (IsWindow(hwnd)) {
- if (g_browser_process->IsUsingNewFrames()) {
- HANDLE data = GetProp(hwnd, kBrowserWindowKey);
- if (data)
- return reinterpret_cast<BrowserWindow*>(data);
- } else {
- std::wstring class_name = win_util::GetClassName(hwnd);
- if (class_name == VISTA_FRAME_CLASSNAME ||
- class_name == XP_FRAME_CLASSNAME) {
- // Need to check for both, as it's possible to have vista and xp frames
- // at the same time (you can get into this state when connecting via
- // remote desktop to a vista machine with Chrome already running).
- return static_cast<BrowserWindow*>(win_util::GetWindowUserData(hwnd));
- }
- }
+ HANDLE data = GetProp(hwnd, kBrowserWindowKey);
+ if (data)
+ return reinterpret_cast<BrowserWindow*>(data);
}
return NULL;
}
// static
-BrowserWindow* FrameUtil::CreateBrowserWindow(const gfx::Rect& bounds,
- Browser* browser) {
- DCHECK(!g_browser_process->IsUsingNewFrames());
-
- BrowserWindow* frame = NULL;
-
- switch (browser->GetType()) {
- case BrowserType::TABBED_BROWSER: {
- bool is_off_the_record = browser->profile()->IsOffTheRecord();
- if (win_util::ShouldUseVistaFrame())
- frame = VistaFrame::CreateFrame(bounds, browser, is_off_the_record);
- else
- frame = XPFrame::CreateFrame(bounds, browser, is_off_the_record);
- break;
- }
- case BrowserType::APPLICATION:
- case BrowserType::BROWSER:
- if (win_util::ShouldUseVistaFrame())
- frame = SimpleVistaFrame::CreateFrame(bounds, browser);
- else
- frame = SimpleXPFrame::CreateFrame(bounds, browser);
- break;
- default:
- NOTREACHED() << "Browser type unknown or not yet implemented";
- return NULL;
- }
- frame->Init();
- return frame;
-}
-
-// static
-bool FrameUtil::LoadAccelerators(
- BrowserWindow* frame,
- HACCEL accelerator_table,
- views::AcceleratorTarget* accelerator_target) {
- DCHECK(!g_browser_process->IsUsingNewFrames());
-
- // We have to copy the table to access its contents.
- int count = CopyAcceleratorTable(accelerator_table, 0, 0);
- if (count == 0) {
- // Nothing to do in that case.
- return false;
- }
-
- ACCEL* accelerators = static_cast<ACCEL*>(malloc(sizeof(ACCEL) * count));
- CopyAcceleratorTable(accelerator_table, accelerators, count);
-
- HWND hwnd = static_cast<HWND>(frame->GetPlatformID());
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManager(hwnd);
- DCHECK(focus_manager);
-
- // Let's build our own accelerator table.
- std::map<views::Accelerator, int>* our_accelerators =
- new std::map<views::Accelerator, int>;
- for (int i = 0; i < count; ++i) {
- bool alt_down = (accelerators[i].fVirt & FALT) == FALT;
- bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL;
- bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT;
- views::Accelerator accelerator(accelerators[i].key,
- shift_down, ctrl_down, alt_down);
- (*our_accelerators)[accelerator] = accelerators[i].cmd;
-
- // Also register with the focus manager.
- focus_manager->RegisterAccelerator(accelerator, accelerator_target);
- }
-
- // We don't need the Windows accelerator table anymore.
- free(accelerators);
-
- // Now set the accelerator table on the frame who becomes the owner.
- frame->SetAcceleratorTable(our_accelerators);
-
- return true;
-}
-
-// static
-bool FrameUtil::ActivateAppModalDialog(Browser* browser) {
- DCHECK(!g_browser_process->IsUsingNewFrames());
-
- // If another browser is app modal, flash and activate the modal browser.
- if (BrowserList::IsShowingAppModalDialog()) {
- if (browser != BrowserList::GetLastActive()) {
- BrowserList::GetLastActive()->window()->FlashFrame();
- BrowserList::GetLastActive()->MoveToFront(true);
- }
- AppModalDialogQueue::ActivateModalDialog();
- return true;
- }
- return false;
-}
-
-// static
// TODO(beng): post new frames, move somewhere more logical, maybe Browser or
// BrowserList.
void FrameUtil::EndSession() {
@@ -179,4 +66,3 @@ void FrameUtil::EndSession() {
// down. If any messages are processed we'll likely crash. Exit now.
ExitProcess(ResultCodes::NORMAL_EXIT);
}
-