summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 02:27:16 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 02:27:16 +0000
commit299dabdd2178ac3126282ac854da86b6cd84be02 (patch)
tree4626d596651704ec7b467d60c011da7efe18dcda /chrome
parent2758136c0f073eacbb2943d5029b90eb4b1e5512 (diff)
downloadchromium_src-299dabdd2178ac3126282ac854da86b6cd84be02.zip
chromium_src-299dabdd2178ac3126282ac854da86b6cd84be02.tar.gz
chromium_src-299dabdd2178ac3126282ac854da86b6cd84be02.tar.bz2
Land this change again now I've fixed the crash.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc2
-rw-r--r--chrome/browser/browser.cc59
-rw-r--r--chrome/browser/browser.h13
-rw-r--r--chrome/browser/browser.vcproj12
-rw-r--r--chrome/browser/browser_init.cc2
-rw-r--r--chrome/browser/browser_list.cc36
-rw-r--r--chrome/browser/browser_list.h7
-rw-r--r--chrome/browser/browser_type.h28
-rw-r--r--chrome/browser/frame_util.cc68
-rw-r--r--chrome/browser/frame_util.h25
-rw-r--r--chrome/browser/navigation_controller.cc7
-rw-r--r--chrome/browser/navigation_controller.h2
-rw-r--r--chrome/browser/navigation_controller_unittest.cc3
-rw-r--r--chrome/browser/session_restore.cc11
-rw-r--r--chrome/browser/session_service.cc6
-rw-r--r--chrome/browser/session_service.h16
-rw-r--r--chrome/browser/session_service_unittest.cc12
-rw-r--r--chrome/browser/tab_restore_service.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc2
-rw-r--r--chrome/browser/views/browser_views.vcproj16
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.cc4
-rw-r--r--chrome/browser/views/frame/browser_view.cc26
-rw-r--r--chrome/browser/views/frame/browser_view.h9
-rw-r--r--chrome/browser/views/frame/browser_window_factory.cc1
-rw-r--r--chrome/browser/views/frame/opaque_frame.cc4
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc11
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h8
-rw-r--r--chrome/browser/views/html_dialog_view.h1
-rw-r--r--chrome/browser/views/info_bubble.cc5
-rw-r--r--chrome/browser/views/tab_icon_view.cc29
-rw-r--r--chrome/browser/views/tab_icon_view.h16
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/views/toolbar_view.cc2
-rw-r--r--chrome/browser/window_sizer.cc3
-rw-r--r--chrome/common/notification_types.h10
35 files changed, 196 insertions, 268 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 7d985ff..22f9e47 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -215,7 +215,7 @@ void OpenAll(HWND parent,
NewBrowserPageNavigator navigator_impl(profile);
if (!navigator) {
Browser* browser =
- BrowserList::FindBrowserWithType(profile, BrowserType::TABBED_BROWSER);
+ BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL);
if (!browser || !browser->GetSelectedTabContents()) {
navigator = &navigator_impl;
} else {
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 142ef6f..156503f 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -139,7 +139,7 @@ struct Browser::UIUpdate {
///////////////////////////////////////////////////////////////////////////////
// Browser, Constructors, Creation, Showing:
-Browser::Browser(BrowserType::Type type, Profile* profile)
+Browser::Browser(Type type, Profile* profile)
: type_(type),
profile_(profile),
window_(NULL),
@@ -210,14 +210,14 @@ Browser::~Browser() {
// static
Browser* Browser::Create(Profile* profile) {
- Browser* browser = new Browser(BrowserType::TABBED_BROWSER, profile);
+ Browser* browser = new Browser(TYPE_NORMAL, profile);
browser->CreateBrowserWindow();
return browser;
}
// static
Browser* Browser::CreateForPopup(Profile* profile) {
- Browser* browser = new Browser(BrowserType::BROWSER, profile);
+ Browser* browser = new Browser(TYPE_POPUP, profile);
browser->CreateBrowserWindow();
return browser;
}
@@ -225,7 +225,7 @@ Browser* Browser::CreateForPopup(Profile* profile) {
// static
Browser* Browser::CreateForApp(const std::wstring& app_name,
Profile* profile) {
- Browser* browser = new Browser(BrowserType::APPLICATION, profile);
+ Browser* browser = new Browser(TYPE_APP, profile);
browser->app_name_ = app_name;
browser->CreateBrowserWindow();
return browser;
@@ -260,7 +260,7 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
Profile* off_the_record_profile = profile->GetOffTheRecordProfile();
Browser* browser = BrowserList::FindBrowserWithType(
off_the_record_profile,
- BrowserType::TABBED_BROWSER);
+ TYPE_NORMAL);
if (!browser)
browser = Browser::Create(off_the_record_profile);
// TODO(eroman): should we have referrer here?
@@ -319,7 +319,7 @@ std::wstring Browser::GetWindowPlacementKey() const {
bool Browser::ShouldSaveWindowPlacement() const {
// We don't save window position for popups.
- return type() != BrowserType::BROWSER;
+ return type() != TYPE_POPUP;
}
void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
@@ -447,7 +447,7 @@ void Browser::OnWindowClosing() {
TabContents* Browser::AddTabWithURL(
const GURL& url, const GURL& referrer, PageTransition::Type transition,
bool foreground, SiteInstance* instance) {
- if (type_ == BrowserType::APPLICATION && tabstrip_model_.count() == 1) {
+ if (type_ == TYPE_APP && tabstrip_model_.count() == 1) {
NOTREACHED() << "Cannot add a tab in a mono tab application.";
return NULL;
}
@@ -621,7 +621,7 @@ void Browser::OpenCurrentURL() {
void Browser::NewTab() {
UserMetrics::RecordAction(L"NewTab", profile_);
- if (type() == BrowserType::TABBED_BROWSER) {
+ if (type() == TYPE_NORMAL) {
AddBlankTab(true);
} else {
Browser* b = GetOrCreateTabbedBrowser();
@@ -701,7 +701,7 @@ void Browser::RestoreTab() {
void Browser::ConvertPopupToTabbedBrowser() {
UserMetrics::RecordAction(L"ShowAsTab", profile_);
- if (type() != BrowserType::BROWSER) {
+ if (type() != TYPE_NORMAL) {
NOTREACHED();
return;
}
@@ -1197,10 +1197,10 @@ GURL Browser::GetBlankTabURL() const {
void Browser::CreateNewStripWithContents(TabContents* detached_contents,
const gfx::Rect& window_bounds) {
- DCHECK(type_ == BrowserType::TABBED_BROWSER);
+ DCHECK(type_ == TYPE_NORMAL);
// Create an empty new browser window the same size as the old one.
- Browser* browser = new Browser(BrowserType::TABBED_BROWSER, profile_);
+ Browser* browser = new Browser(TYPE_NORMAL, profile_);
browser->set_override_bounds(window_bounds);
browser->CreateBrowserWindow();
browser->tabstrip_model()->AppendTabContents(detached_contents, true);
@@ -1217,8 +1217,7 @@ void Browser::CreateNewStripWithContents(TabContents* detached_contents,
int Browser::GetDragActions() const {
int result = 0;
- if (BrowserList::GetBrowserCountForType(profile_,
- BrowserType::TABBED_BROWSER) > 1 ||
+ if (BrowserList::GetBrowserCountForType(profile_, TYPE_NORMAL) > 1 ||
tab_count() > 1)
result |= TAB_TEAROFF_ACTION;
if (tab_count() > 1)
@@ -1262,7 +1261,7 @@ void Browser::DuplicateContentsAt(int index) {
TabContents* new_contents = NULL;
DCHECK(contents);
- if (type_ == BrowserType::TABBED_BROWSER) {
+ if (type_ == TYPE_NORMAL) {
// If this is a tabbed browser, just create a duplicate tab inside the same
// window next to the tab being duplicated.
HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle());
@@ -1278,9 +1277,9 @@ void Browser::DuplicateContentsAt(int index) {
PageTransition::LINK, true);
} else {
Browser* browser = NULL;
- if (type_ == BrowserType::APPLICATION) {
+ if (type_ == TYPE_APP) {
browser = Browser::CreateForApp(app_name_, profile_);
- } else if (type_ == BrowserType::BROWSER) {
+ } else if (type_ == TYPE_POPUP) {
browser = Browser::CreateForPopup(profile_);
}
@@ -1467,7 +1466,7 @@ void Browser::OpenURLFromTab(TabContents* source,
// If this is an application we can only have one tab so a new tab always
// goes into a tabbed browser window.
- if (disposition != NEW_WINDOW && type_ == BrowserType::APPLICATION) {
+ if (disposition != NEW_WINDOW && type_ == TYPE_APP) {
// If the disposition is OFF_THE_RECORD we don't want to create a new
// browser that will itself create another OTR browser. This will result in
// a browser leak (and crash below because no tab is created or selected).
@@ -1603,7 +1602,7 @@ void Browser::AddNewContents(TabContents* source,
// this in tabbed browser window.
if (tabstrip_model_.count() > 0 &&
disposition != NEW_WINDOW && disposition != NEW_POPUP &&
- type_ != BrowserType::TABBED_BROWSER) {
+ type_ != TYPE_NORMAL) {
Browser* b = GetOrCreateTabbedBrowser();
DCHECK(b);
PageTransition::Type transition = PageTransition::LINK;
@@ -1612,7 +1611,7 @@ void Browser::AddNewContents(TabContents* source,
// This means we need to open the tab with the START PAGE transition.
// AddNewContents doesn't support this but the TabStripModel's
// AddTabContents method does.
- if (type_ == BrowserType::APPLICATION)
+ if (type_ == TYPE_APP)
transition = PageTransition::START_PAGE;
b->tabstrip_model()->AddTabContents(new_contents, -1, transition, true);
b->window()->Show();
@@ -1672,7 +1671,7 @@ void Browser::CloseContents(TabContents* source) {
}
void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {
- if (type() != BrowserType::BROWSER) {
+ if (type() != TYPE_POPUP) {
NOTREACHED() << "moving invalid browser type";
return;
}
@@ -1681,7 +1680,7 @@ void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {
bool Browser::IsPopup(TabContents* source) {
// A non-tabbed BROWSER is an unconstrained popup.
- return (type() == BrowserType::BROWSER);
+ return (type() == TYPE_POPUP);
}
void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) {
@@ -1718,7 +1717,7 @@ void Browser::ContentsZoomChange(bool zoom_in) {
}
bool Browser::IsApplication() const {
- return type_ == BrowserType::APPLICATION;
+ return type_ == TYPE_APP;
}
void Browser::ConvertContentsToApplication(TabContents* contents) {
@@ -1841,8 +1840,7 @@ void Browser::InitCommandState() {
controller_.UpdateCommandEnabled(IDC_STOP, true);
controller_.UpdateCommandEnabled(IDC_RELOAD, true);
- controller_.UpdateCommandEnabled(IDC_HOME,
- type() == BrowserType::TABBED_BROWSER);
+ controller_.UpdateCommandEnabled(IDC_HOME, type() == TYPE_NORMAL);
controller_.UpdateCommandEnabled(IDC_GO, true);
controller_.UpdateCommandEnabled(IDC_NEWTAB, true);
controller_.UpdateCommandEnabled(IDC_CLOSETAB, true);
@@ -1936,13 +1934,11 @@ void Browser::InitCommandState() {
controller_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true);
controller_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true);
controller_.UpdateCommandEnabled(IDC_OPTIONS, true);
- controller_.UpdateCommandEnabled(IDC_CLOSE_WEB_APP,
- type() != BrowserType::TABBED_BROWSER);
- controller_.UpdateCommandEnabled(IDC_SHOW_AS_TAB,
- type() == BrowserType::BROWSER);
+ controller_.UpdateCommandEnabled(IDC_CLOSE_WEB_APP, type() != TYPE_NORMAL);
+ controller_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, type() == TYPE_POPUP);
controller_.UpdateCommandEnabled(
IDC_RESTORE_TAB, (!profile_->IsOffTheRecord() &&
- type() == BrowserType::TABBED_BROWSER));
+ type() == TYPE_NORMAL));
controller_.UpdateCommandEnabled(IDC_EXIT, true);
// the debugger doesn't work in single process mode
controller_.UpdateCommandEnabled(IDC_DEBUGGER,
@@ -2284,7 +2280,7 @@ void Browser::ClearUnloadState(TabContents* tab) {
Browser* Browser::GetOrCreateTabbedBrowser() {
Browser* browser = BrowserList::FindBrowserWithType(
- profile_, BrowserType::TABBED_BROWSER);
+ profile_, TYPE_NORMAL);
if (!browser)
browser = Browser::Create(profile_);
return browser;
@@ -2293,8 +2289,7 @@ Browser* Browser::GetOrCreateTabbedBrowser() {
void Browser::BuildPopupWindow(TabContents* source,
TabContents* new_contents,
const gfx::Rect& initial_pos) {
- BrowserType::Type type =
- type_ == BrowserType::APPLICATION ? type_ : BrowserType::BROWSER;
+ Type type = type_ == TYPE_APP ? type_ : TYPE_POPUP;
Browser* browser = new Browser(type, profile_);
browser->set_override_bounds(initial_pos);
browser->CreateBrowserWindow();
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 398f5ae..4a77152 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -7,7 +7,6 @@
#include "chrome/browser/controller.h"
#include "chrome/browser/shell_dialogs.h"
-#include "chrome/browser/browser_type.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/session_id.h"
#include "chrome/browser/tab_contents.h"
@@ -35,12 +34,18 @@ class Browser : public TabStripModelDelegate,
public NotificationObserver,
public SelectFileDialog::Listener {
public:
+ enum Type {
+ TYPE_NORMAL = 0,
+ TYPE_POPUP = 1,
+ TYPE_APP = 2
+ };
+
// Constructors, Creation, Showing //////////////////////////////////////////
// Creates a new browser of the given |type| and for the given |profile|. The
// Browser has a NULL window after its construction, CreateBrowserWindow must
// be called after configuration for window() to be valid.
- Browser(BrowserType::Type type, Profile* profile);
+ Browser(Type type, Profile* profile);
~Browser();
// Creates a normal tabbed browser with the specified profile. The Browser's
@@ -69,7 +74,7 @@ class Browser : public TabStripModelDelegate,
// Accessors ////////////////////////////////////////////////////////////////
- BrowserType::Type type() const { return type_; }
+ Type type() const { return type_; }
Profile* profile() const { return profile_; }
BrowserWindow* window() const { return window_; }
ToolbarModel* toolbar_model() { return &toolbar_model_; }
@@ -494,7 +499,7 @@ class Browser : public TabStripModelDelegate,
// Data members /////////////////////////////////////////////////////////////
// This Browser's type.
- BrowserType::Type type_;
+ Type type_;
// This Browser's profile.
Profile* profile_;
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index 6f54f24..3a791a3 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -986,10 +986,6 @@
>
</File>
<File
- RelativePath=".\browser_type.h"
- >
- </File>
- <File
RelativePath=".\browser_window.h"
>
</File>
@@ -1006,14 +1002,6 @@
>
</File>
<File
- RelativePath=".\frame_util.cc"
- >
- </File>
- <File
- RelativePath=".\frame_util.h"
- >
- </File>
- <File
RelativePath=".\js_before_unload_handler.cc"
>
</File>
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 4bf49f6..209ebc3 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -487,7 +487,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
bool process_startup,
const std::vector<GURL>& urls) {
DCHECK(!urls.empty());
- if (!browser || browser->type() != BrowserType::TABBED_BROWSER)
+ if (!browser || browser->type() != Browser::TYPE_NORMAL)
browser = Browser::Create(profile_);
for (size_t i = 0; i < urls.size(); ++i) {
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 9e0b2e4..67d6a56 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -6,7 +6,9 @@
#include "base/logging.h"
#include "base/message_loop.h"
+#include "chrome/app/result_codes.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
@@ -134,6 +136,36 @@ void BrowserList::CloseAllBrowsers(bool use_post) {
}
// static
+void BrowserList::WindowsSessionEnding() {
+ // EndSession is invoked once per frame. Only do something the first time.
+ static bool already_ended = false;
+ if (already_ended)
+ return;
+ already_ended = true;
+
+ browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
+
+ // Write important data first.
+ g_browser_process->EndSession();
+
+ // Close all the browsers.
+ BrowserList::CloseAllBrowsers(false);
+
+ // Send out notification. This is used during testing so that the test harness
+ // can properly shutdown before we exit.
+ NotificationService::current()->Notify(NOTIFY_SESSION_END,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+
+ // And shutdown.
+ browser_shutdown::Shutdown();
+
+ // At this point the message loop is still running yet we've shut everything
+ // down. If any messages are processed we'll likely crash. Exit now.
+ ExitProcess(ResultCodes::NORMAL_EXIT);
+}
+
+// static
bool BrowserList::HasBrowserWithProfile(Profile* profile) {
BrowserList::const_iterator iter;
for (size_t i = 0; i < browsers_.size(); ++i) {
@@ -176,7 +208,7 @@ Browser* BrowserList::GetLastActive() {
}
// static
-Browser* BrowserList::FindBrowserWithType(Profile* p, BrowserType::Type t) {
+Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) {
Browser* last_active = GetLastActive();
if (last_active && last_active->profile() == p && last_active->type() == t)
return last_active;
@@ -193,7 +225,7 @@ Browser* BrowserList::FindBrowserWithType(Profile* p, BrowserType::Type t) {
}
// static
-size_t BrowserList::GetBrowserCountForType(Profile* p, BrowserType::Type type) {
+size_t BrowserList::GetBrowserCountForType(Profile* p, Browser::Type type) {
BrowserList::const_iterator i;
size_t result = 0;
for (i = BrowserList::begin(); i != BrowserList::end(); ++i) {
diff --git a/chrome/browser/browser_list.h b/chrome/browser/browser_list.h
index f385777..ef9a16f 100644
--- a/chrome/browser/browser_list.h
+++ b/chrome/browser/browser_list.h
@@ -62,7 +62,7 @@ class BrowserList {
// Find an existing browser window with the provided type. If the last active
// has the right type, it is returned. Otherwise, the next available browser
// is returned. Returns NULL if no such browser currently exists.
- static Browser* FindBrowserWithType(Profile* p, BrowserType::Type t);
+ static Browser* FindBrowserWithType(Profile* p, Browser::Type t);
// Closes all browsers. If use_post is true the windows are closed by way of
// posting a WM_CLOSE message, otherwise the windows are closed directly. In
@@ -70,6 +70,9 @@ class BrowserList {
// the session. use_post should only be false when invoked from end session.
static void CloseAllBrowsers(bool use_post);
+ // Begins shutdown of the application when the Windows session is ending.
+ static void WindowsSessionEnding();
+
// Returns true if there is at least one Browser with the specified profile.
static bool HasBrowserWithProfile(Profile* profile);
@@ -132,7 +135,7 @@ class BrowserList {
// Return the number of browsers with the following profile and type which are
// currently open.
- static size_t GetBrowserCountForType(Profile* p, BrowserType::Type type);
+ static size_t GetBrowserCountForType(Profile* p, Browser::Type type);
// Returns true if at least one off the record session is active.
static bool IsOffTheRecordSessionActive();
diff --git a/chrome/browser/browser_type.h b/chrome/browser/browser_type.h
deleted file mode 100644
index c82fcf3..0000000
--- a/chrome/browser/browser_type.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_BROWSER_TYPE_H__
-#define CHROME_BROWSER_BROWSER_TYPE_H__
-
-#include "base/basictypes.h"
-
-class BrowserType {
- public:
- // Enumeration of the types of Browsers we have. This is defined outside
- // of Browser to avoid cyclical dependencies.
- enum Type {
- // NOTE: If you change this list, you may need to update which browsers
- // are saved in session history. See
- // SessionService::BuildCommandsFromBrowser.
- TABBED_BROWSER = 0, // A normal chrome window.
- BROWSER, // A chrome window without the tabstrip or toolbar.
- APPLICATION, // Web application with a frame but no tab strips.
- };
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserType);
-};
-
-#endif // CHROME_BROWSER_BROWSER_TYPE_H__
-
diff --git a/chrome/browser/frame_util.cc b/chrome/browser/frame_util.cc
deleted file mode 100644
index b7cccd7..0000000
--- a/chrome/browser/frame_util.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#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"
-#include "chrome/browser/app_modal_dialog_queue.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_shutdown.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/profile_manager.h"
-#include "chrome/browser/render_view_host.h"
-#include "chrome/browser/web_contents.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/win_util.h"
-#include "chrome/views/focus_manager.h"
-
-// TODO(beng): clean this up
-static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__";
-
-// static
-BrowserWindow* FrameUtil::GetBrowserWindowForHWND(HWND hwnd) {
- if (IsWindow(hwnd)) {
- HANDLE data = GetProp(hwnd, kBrowserWindowKey);
- if (data)
- return reinterpret_cast<BrowserWindow*>(data);
- }
- return NULL;
-}
-
-// static
-// TODO(beng): post new frames, move somewhere more logical, maybe Browser or
-// BrowserList.
-void FrameUtil::EndSession() {
- // EndSession is invoked once per frame. Only do something the first time.
- static bool already_ended = false;
- if (already_ended)
- return;
- already_ended = true;
-
- browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
-
- // Write important data first.
- g_browser_process->EndSession();
-
- // Close all the browsers.
- BrowserList::CloseAllBrowsers(false);
-
- // Send out notification. This is used during testing so that the test harness
- // can properly shutdown before we exit.
- NotificationService::current()->Notify(NOTIFY_SESSION_END,
- NotificationService::AllSources(),
- NotificationService::NoDetails());
-
- // And shutdown.
- browser_shutdown::Shutdown();
-
- // At this point the message loop is still running yet we've shut everything
- // down. If any messages are processed we'll likely crash. Exit now.
- ExitProcess(ResultCodes::NORMAL_EXIT);
-}
diff --git a/chrome/browser/frame_util.h b/chrome/browser/frame_util.h
deleted file mode 100644
index 1adaa7f..0000000
--- a/chrome/browser/frame_util.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_FRAME_UTIL_H_
-#define CHROME_BROWSER_FRAME_UTIL_H_
-
-#include <windows.h>
-
-class BrowserWindow;
-
-// Static helpers for frames. Basically shared code until Magic Browzr lands.
-class FrameUtil {
- public:
- // Return a ChromeFrame instance given an hwnd.
- static BrowserWindow* GetBrowserWindowForHWND(HWND hwnd);
-
- // Invoked when windows is shutting down (or the user is logging off). When
- // this method returns windows is going to kill our process. As such, this
- // blocks until the shut-down has been marked as clean.
- static void EndSession();
-};
-
-#endif // #ifndef CHROME_BROWSER_FRAME_UTIL_H__
-
diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc
index 9f9cf68..c646b4a 100644
--- a/chrome/browser/navigation_controller.cc
+++ b/chrome/browser/navigation_controller.cc
@@ -8,18 +8,19 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_util.h"
-#include "chrome/common/navigation_types.h"
-#include "chrome/common/resource_bundle.h"
-#include "chrome/common/scoped_vector.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/dom_ui/dom_ui_host.h"
#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/repost_form_warning_dialog.h"
+#include "chrome/browser/session_service.h"
#include "chrome/browser/site_instance.h"
#include "chrome/browser/tab_contents.h"
#include "chrome/browser/tab_contents_delegate.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/navigation_types.h"
+#include "chrome/common/resource_bundle.h"
+#include "chrome/common/scoped_vector.h"
#include "net/base/net_util.h"
#include "webkit/glue/webkit_glue.h"
diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h
index 5b5408f..cd156b5 100644
--- a/chrome/browser/navigation_controller.h
+++ b/chrome/browser/navigation_controller.h
@@ -9,7 +9,7 @@
#include "base/linked_ptr.h"
#include "base/ref_counted.h"
-#include "chrome/browser/session_service.h"
+#include "chrome/browser/session_id.h"
#include "chrome/browser/site_instance.h"
#include "chrome/browser/ssl_manager.h"
#include "chrome/browser/tab_contents_type.h"
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc
index 64dae5e..5c43b1b 100644
--- a/chrome/browser/navigation_controller_unittest.cc
+++ b/chrome/browser/navigation_controller_unittest.cc
@@ -5,7 +5,6 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
-#include "chrome/browser/browser_type.h"
#include "chrome/browser/navigation_controller.h"
#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/profile_manager.h"
@@ -158,7 +157,7 @@ class NavigationControllerHistoryTest : public NavigationControllerTest {
// Force the session service to be created.
SessionService* service = profile->GetSessionService();
- service->SetWindowType(window_id, BrowserType::TABBED_BROWSER);
+ service->SetWindowType(window_id, Browser::TYPE_NORMAL);
service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false);
service->SetTabIndexInWindow(window_id,
contents->controller()->session_id(), 0);
diff --git a/chrome/browser/session_restore.cc b/chrome/browser/session_restore.cc
index b8ec569..258ed7c 100644
--- a/chrome/browser/session_restore.cc
+++ b/chrome/browser/session_restore.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/navigation_controller.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/session_service.h"
#include "chrome/browser/tab_contents.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
@@ -286,14 +287,14 @@ class SessionRestoreImpl : public NotificationObserver {
for (std::vector<SessionWindow*>::iterator i = windows->begin();
i != windows->end(); ++i) {
Browser* browser = NULL;
- if (!has_tabbed_browser && (*i)->type == BrowserType::TABBED_BROWSER)
+ if (!has_tabbed_browser && (*i)->type == Browser::TYPE_NORMAL)
has_tabbed_browser = true;
- if (i == windows->begin() && (*i)->type == BrowserType::TABBED_BROWSER &&
+ if (i == windows->begin() && (*i)->type == Browser::TYPE_NORMAL &&
!clobber_existing_window_) {
// If there is an open tabbed browser window, use it. Otherwise fall
// through and create a new one.
browser = current_browser;
- if (browser && (browser->type() != BrowserType::TABBED_BROWSER ||
+ if (browser && (browser->type() != Browser::TYPE_NORMAL ||
browser->profile()->IsOffTheRecord())) {
browser = NULL;
}
@@ -304,7 +305,7 @@ class SessionRestoreImpl : public NotificationObserver {
browser->set_override_maximized((*i)->is_maximized);
browser->CreateBrowserWindow();
}
- if ((*i)->type == BrowserType::TABBED_BROWSER)
+ if ((*i)->type == Browser::TYPE_NORMAL)
last_browser = browser;
const int initial_tab_count = browser->tab_count();
RestoreTabsToBrowser(*(*i), browser);
@@ -316,7 +317,7 @@ class SessionRestoreImpl : public NotificationObserver {
// included at least one tabbed browser, then close the browser window
// that was opened when the user clicked to restore the session.
if (clobber_existing_window_ && current_browser && has_tabbed_browser &&
- current_browser->type() == BrowserType::TABBED_BROWSER) {
+ current_browser->type() == Browser::TYPE_NORMAL) {
current_browser->CloseAllTabs();
}
if (last_browser && !urls_to_open_.empty())
diff --git a/chrome/browser/session_service.cc b/chrome/browser/session_service.cc
index d1b848b..f5e042e 100644
--- a/chrome/browser/session_service.cc
+++ b/chrome/browser/session_service.cc
@@ -293,7 +293,7 @@ void SessionService::WindowClosed(const SessionID& window_id) {
}
void SessionService::SetWindowType(const SessionID& window_id,
- BrowserType::Type type) {
+ Browser::Type type) {
if (!should_track_changes_for_browser_type(type))
return;
@@ -703,7 +703,7 @@ SessionCommand* SessionService::CreateSetSelectedNavigationIndexCommand(
SessionCommand* SessionService::CreateSetWindowTypeCommand(
const SessionID& window_id,
- BrowserType::Type type) {
+ Browser::Type type) {
WindowTypePayload payload = { 0 };
payload.id = window_id.id();
payload.index = static_cast<int32>(type);
@@ -1026,7 +1026,7 @@ bool SessionService::CreateTabsAndWindows(
return true;
GetWindow(payload.id, windows)->is_constrained = false;
GetWindow(payload.id, windows)->type =
- static_cast<BrowserType::Type>(payload.index);
+ static_cast<Browser::Type>(payload.index);
break;
}
diff --git a/chrome/browser/session_service.h b/chrome/browser/session_service.h
index 68b6c74b..2ff8608 100644
--- a/chrome/browser/session_service.h
+++ b/chrome/browser/session_service.h
@@ -11,7 +11,7 @@
#include "base/gfx/rect.h"
#include "base/task.h"
#include "base/time.h"
-#include "chrome/browser/browser_type.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/session_id.h"
#include "chrome/common/notification_service.h"
@@ -122,7 +122,7 @@ struct SessionTab {
struct SessionWindow {
SessionWindow()
: selected_tab_index(-1),
- type(BrowserType::TABBED_BROWSER),
+ type(Browser::TYPE_NORMAL),
is_constrained(true),
is_maximized(false) {}
~SessionWindow() { STLDeleteElements(&tabs); }
@@ -143,8 +143,8 @@ struct SessionWindow {
int selected_tab_index;
// Type of the browser. Currently we only store browsers of type
- // TABBED_BROWSER and BROWSER.
- BrowserType::Type type;
+ // TYPE_NORMAL and TYPE_POPUP.
+ Browser::Type type;
// If true, the window is constrained.
//
@@ -239,7 +239,7 @@ class SessionService : public CancelableRequestProvider,
// Sets the type of window. In order for the contents of a window to be
// tracked SetWindowType must be invoked with a type we track
// (should_track_changes_for_browser_type returns true).
- void SetWindowType(const SessionID& window_id, BrowserType::Type type);
+ void SetWindowType(const SessionID& window_id, Browser::Type type);
// Invoked when the NavigationController has removed entries from the back of
// the list. |count| gives the number of entries in the navigation controller.
@@ -386,7 +386,7 @@ class SessionService : public CancelableRequestProvider,
int index);
SessionCommand* CreateSetWindowTypeCommand(const SessionID& window_id,
- BrowserType::Type type);
+ Browser::Type type);
// Callback form the backend for getting the commands from the previous
// or save file. Converts the commands in SessionWindows and notifies
@@ -520,8 +520,8 @@ class SessionService : public CancelableRequestProvider,
bool SessionService::ShouldTrackEntry(const NavigationEntry& entry);
// Returns true if we track changes to the specified browser type.
- static bool should_track_changes_for_browser_type(BrowserType::Type type) {
- return type == BrowserType::TABBED_BROWSER;
+ static bool should_track_changes_for_browser_type(Browser::Type type) {
+ return type == Browser::TYPE_NORMAL;
}
// The profile used to determine where to save, as well as what tabs
diff --git a/chrome/browser/session_service_unittest.cc b/chrome/browser/session_service_unittest.cc
index 08dbf37..fc2a2d7 100644
--- a/chrome/browser/session_service_unittest.cc
+++ b/chrome/browser/session_service_unittest.cc
@@ -31,7 +31,7 @@ class SessionServiceTest : public testing::Test {
helper_.set_service(new SessionService(path_));
- service()->SetWindowType(window_id, BrowserType::TABBED_BROWSER);
+ service()->SetWindowType(window_id, Browser::TYPE_NORMAL);
service()->SetWindowBounds(window_id, window_bounds, false);
}
@@ -99,7 +99,7 @@ TEST_F(SessionServiceTest, Basic) {
ASSERT_EQ(0, windows[0]->selected_tab_index);
ASSERT_EQ(window_id.id(), windows[0]->window_id.id());
ASSERT_EQ(1, windows[0]->tabs.size());
- ASSERT_EQ(BrowserType::TABBED_BROWSER, windows[0]->type);
+ ASSERT_EQ(Browser::TYPE_NORMAL, windows[0]->type);
SessionTab* tab = windows[0]->tabs[0];
helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab);
@@ -232,7 +232,7 @@ TEST_F(SessionServiceTest, TwoWindows) {
UpdateNavigation(window_id, tab1_id, nav1, 0, true);
const gfx::Rect window2_bounds(3, 4, 5, 6);
- service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER);
+ service()->SetWindowType(window2_id, Browser::TYPE_NORMAL);
service()->SetWindowBounds(window2_id, window2_bounds, true);
helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
UpdateNavigation(window2_id, tab2_id, nav2, 0, true);
@@ -283,7 +283,7 @@ TEST_F(SessionServiceTest, WindowWithNoTabsGetsPruned) {
UpdateNavigation(window_id, tab1_id, nav1, 0, true);
const gfx::Rect window2_bounds(3, 4, 5, 6);
- service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER);
+ service()->SetWindowType(window2_id, Browser::TYPE_NORMAL);
service()->SetWindowBounds(window2_id, window2_bounds, false);
helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true);
@@ -341,7 +341,7 @@ TEST_F(SessionServiceTest, WindowCloseCommittedAfterNavigate) {
SessionID tab2_id;
ASSERT_NE(window2_id.id(), window_id.id());
- service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER);
+ service()->SetWindowType(window2_id, Browser::TYPE_NORMAL);
service()->SetWindowBounds(window2_id, window_bounds, false);
TabNavigation nav1(0, GURL("http://google.com"), GURL(), L"abc", "def",
@@ -379,7 +379,7 @@ TEST_F(SessionServiceTest, IgnorePopups) {
SessionID tab2_id;
ASSERT_NE(window2_id.id(), window_id.id());
- service()->SetWindowType(window2_id, BrowserType::BROWSER);
+ service()->SetWindowType(window2_id, Browser::TYPE_POPUP);
service()->SetWindowBounds(window2_id, window_bounds, false);
TabNavigation nav1(0, GURL("http://google.com"), GURL(), L"abc", "def",
diff --git a/chrome/browser/tab_restore_service.cc b/chrome/browser/tab_restore_service.cc
index e815a62..4fcbe8c 100644
--- a/chrome/browser/tab_restore_service.cc
+++ b/chrome/browser/tab_restore_service.cc
@@ -112,7 +112,7 @@ void TabRestoreService::AddHistoricalTabs(
// First pass, extract the selected tabs in each window.
for (size_t i = 0; i < windows->size(); ++i) {
SessionWindow* window = (*windows)[i];
- if (window->type == BrowserType::TABBED_BROWSER) {
+ if (window->type == Browser::TYPE_NORMAL) {
DCHECK(window->selected_tab_index >= 0 &&
window->selected_tab_index <
static_cast<int>(window->tabs.size()));
@@ -127,7 +127,7 @@ void TabRestoreService::AddHistoricalTabs(
for (size_t window_index = 0; window_index < windows->size();
++window_index) {
SessionWindow* window = (*windows)[window_index];
- if (window->type != BrowserType::TABBED_BROWSER)
+ if (window->type != Browser::TYPE_NORMAL)
continue; // Ignore popups.
for (size_t tab_index = 0; tab_index < window->tabs.size(); ++tab_index) {
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 9c29452..176bf94 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -597,7 +597,7 @@ bool TabStripModel::ShouldAddToTabRestoreService(TabContents* contents) {
Browser::GetBrowserForController(contents->controller(), NULL);
if (!browser)
return false; // Browser is null during unit tests.
- return browser->type() == BrowserType::TABBED_BROWSER;
+ return browser->type() == Browser::TYPE_NORMAL;
}
// static
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 6f38c89..5a543cd 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -216,14 +216,6 @@
RelativePath=".\info_bar_view.h"
>
</File>
- <File
- RelativePath=".\tab_icon_view.cc"
- >
- </File>
- <File
- RelativePath=".\tab_icon_view.h"
- >
- </File>
</Filter>
<Filter
Name="Options"
@@ -778,6 +770,14 @@
>
</File>
<File
+ RelativePath=".\tab_icon_view.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\tab_icon_view.h"
+ >
+ </File>
+ <File
RelativePath=".\theme_helpers.cc"
>
</File>
diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc
index 0c5846a..a24e274 100644
--- a/chrome/browser/views/frame/aero_glass_frame.cc
+++ b/chrome/browser/views/frame/aero_glass_frame.cc
@@ -7,7 +7,7 @@
#include <dwmapi.h>
#include "chrome/app/theme/theme_resources.h"
-#include "chrome/browser/frame_util.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/frame/aero_glass_non_client_view.h"
#include "chrome/common/resource_bundle.h"
@@ -108,7 +108,7 @@ void AeroGlassFrame::OnInitMenuPopup(HMENU menu, UINT position,
}
void AeroGlassFrame::OnEndSession(BOOL ending, UINT logoff) {
- FrameUtil::EndSession();
+ BrowserList::WindowsSessionEnding();
}
LRESULT AeroGlassFrame::OnMouseActivate(HWND window, UINT hittest_code,
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 54bf7c5..2b6af47 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -138,6 +138,16 @@ BrowserView::~BrowserView() {
ticker_.UnregisterTickHandler(&hung_window_detector_);
}
+// static
+BrowserWindow* BrowserView::GetBrowserWindowForHWND(HWND window) {
+ if (IsWindow(window)) {
+ HANDLE data = GetProp(window, kBrowserWindowKey);
+ if (data)
+ return reinterpret_cast<BrowserWindow*>(data);
+ }
+ return NULL;
+}
+
int BrowserView::GetShowState() const {
STARTUPINFO si = {0};
si.cb = sizeof(si);
@@ -189,7 +199,7 @@ bool BrowserView::IsOffTheRecord() const {
}
bool BrowserView::ShouldShowOffTheRecordAvatar() const {
- return IsOffTheRecord() && browser_->type() == BrowserType::TABBED_BROWSER;
+ return IsOffTheRecord() && browser_->type() == Browser::TYPE_NORMAL;
}
bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) {
@@ -283,13 +293,13 @@ bool BrowserView::SupportsWindowFeature(WindowFeature feature) const {
}
// static
-unsigned int BrowserView::FeaturesForBrowserType(BrowserType::Type type) {
+unsigned int BrowserView::FeaturesForBrowserType(Browser::Type type) {
unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF;
- if (type == BrowserType::TABBED_BROWSER)
+ if (type == Browser::TYPE_NORMAL)
features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR | FEATURE_BOOKMARKBAR;
- if (type != BrowserType::APPLICATION)
+ if (type != Browser::TYPE_APP)
features |= FEATURE_LOCATIONBAR;
- if (type != BrowserType::TABBED_BROWSER)
+ if (type != Browser::TYPE_NORMAL)
features |= FEATURE_TITLEBAR;
return features;
}
@@ -687,7 +697,7 @@ bool BrowserView::ShouldShowWindowTitle() const {
}
SkBitmap BrowserView::GetWindowIcon() {
- if (browser_->type() == BrowserType::APPLICATION)
+ if (browser_->type() == Browser::TYPE_APP)
return browser_->GetCurrentPageIcon();
return SkBitmap();
}
@@ -726,7 +736,7 @@ void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
*bounds = browser_->GetSavedWindowBounds();
- if (browser_->type() == BrowserType::BROWSER) {
+ if (browser_->type() == Browser::TYPE_POPUP) {
// We are a popup window. The value passed in |bounds| represents two
// pieces of information:
// - the position of the window, in screen coordinates (outer position).
@@ -967,7 +977,7 @@ void BrowserView::InitSystemMenu() {
int insertion_index = std::max(0, system_menu_->ItemCount() - 1);
// We add the menu items in reverse order so that insertion_index never needs
// to change.
- if (browser_->type() == BrowserType::TABBED_BROWSER) {
+ if (browser_->type() == Browser::TYPE_NORMAL) {
system_menu_->AddSeparator(insertion_index);
system_menu_->AddMenuItemWithLabel(insertion_index, IDC_TASKMANAGER,
l10n_util::GetString(IDS_TASKMANAGER));
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index fcc0ee4..d777f5a 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_H_
#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_H_
-#include "chrome/browser/browser_type.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/hang_monitor/hung_plugin_action.h"
#include "chrome/browser/hang_monitor/hung_window_detector.h"
@@ -43,6 +43,11 @@ class BrowserView : public BrowserWindow,
void set_frame(BrowserFrame* frame) { frame_ = frame; }
+ // Returns a pointer to the BrowserWindow* interface implementation (an
+ // instance of this object, typically) for a given HWND, or NULL if there is
+ // no such association.
+ static BrowserWindow* GetBrowserWindowForHWND(HWND window);
+
// Returns the show flag that should be used to show the frame containing
// this view.
int GetShowState() const;
@@ -134,7 +139,7 @@ class BrowserView : public BrowserWindow,
bool SupportsWindowFeature(WindowFeature feature) const;
// Returns the set of WindowFeatures supported by the specified BrowserType.
- static unsigned int FeaturesForBrowserType(BrowserType::Type type);
+ static unsigned int FeaturesForBrowserType(Browser::Type type);
// Register preferences specific to this view.
static void RegisterBrowserViewPrefs(PrefService* prefs);
diff --git a/chrome/browser/views/frame/browser_window_factory.cc b/chrome/browser/views/frame/browser_window_factory.cc
index 59a8d9d..9a6853b 100644
--- a/chrome/browser/views/frame/browser_window_factory.cc
+++ b/chrome/browser/views/frame/browser_window_factory.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h" // TODO(beng): remove once done.
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/frame_util.h"
#include "chrome/browser/views/frame/aero_glass_frame.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
diff --git a/chrome/browser/views/frame/opaque_frame.cc b/chrome/browser/views/frame/opaque_frame.cc
index 3158af7..f04d8e2 100644
--- a/chrome/browser/views/frame/opaque_frame.cc
+++ b/chrome/browser/views/frame/opaque_frame.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/views/frame/opaque_frame.h"
-#include "chrome/browser/frame_util.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/frame/opaque_non_client_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
@@ -82,7 +82,7 @@ bool OpaqueFrame::GetAccelerator(int cmd_id, views::Accelerator* accelerator) {
}
void OpaqueFrame::OnEndSession(BOOL ending, UINT logoff) {
- FrameUtil::EndSession();
+ BrowserList::WindowsSessionEnding();
}
void OpaqueFrame::OnInitMenuPopup(HMENU menu, UINT position,
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index 460a1f8..1f30ae5 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/views/frame/opaque_non_client_view.h"
#include "chrome/app/theme/theme_resources.h"
+#include "chrome/browser/tab_contents.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/common/gfx/chrome_font.h"
@@ -479,11 +480,15 @@ void OpaqueNonClientView::UpdateWindowIcon() {
///////////////////////////////////////////////////////////////////////////////
// OpaqueNonClientView, TabIconView::TabContentsProvider implementation:
-TabContents* OpaqueNonClientView::GetCurrentTabContents() {
- return browser_view_->GetSelectedTabContents();
+bool OpaqueNonClientView::ShouldTabIconViewAnimate() const {
+ // This function is queried during the creation of the window as the
+ // TabIconView we host is initialized, so we need to NULL check the selected
+ // TabContents because in this condition there is not yet a selected tab.
+ TabContents* current_tab = browser_view_->GetSelectedTabContents();
+ return current_tab ? current_tab->is_loading() : false;
}
-SkBitmap OpaqueNonClientView::GetFavIcon() {
+SkBitmap OpaqueNonClientView::GetFavIconForTabIconView() {
return frame_->window_delegate()->GetWindowIcon();
}
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index 6d22a5b..93cee85 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -20,7 +20,7 @@ class WindowResources;
class OpaqueNonClientView : public views::NonClientView,
public views::BaseButton::ButtonListener,
- public TabIconView::TabContentsProvider {
+ public TabIconView::TabIconViewModel {
public:
// Constructs a non-client view for an OpaqueFrame. |is_otr| specifies if the
// frame was created "off-the-record" and as such different bitmaps should be
@@ -39,9 +39,9 @@ class OpaqueNonClientView : public views::NonClientView,
void UpdateWindowIcon();
protected:
- // Overridden from TabIconView::TabContentsProvider:
- virtual TabContents* GetCurrentTabContents();
- virtual SkBitmap GetFavIcon();
+ // Overridden from TabIconView::TabIconViewModel:
+ virtual bool ShouldTabIconViewAnimate() const;
+ virtual SkBitmap GetFavIconForTabIconView();
// Overridden from views::BaseButton::ButtonListener:
virtual void ButtonPressed(views::BaseButton* sender);
diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h
index 68e09adf..3b8b28c 100644
--- a/chrome/browser/views/html_dialog_view.h
+++ b/chrome/browser/views/html_dialog_view.h
@@ -11,6 +11,7 @@
#include "chrome/browser/tab_contents_delegate.h"
#include "chrome/browser/views/dom_view.h"
+class Browser;
namespace views {
class Window;
}
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc
index 9106b3e..0fc2264 100644
--- a/chrome/browser/views/info_bubble.cc
+++ b/chrome/browser/views/info_bubble.cc
@@ -7,7 +7,7 @@
#include "base/win_util.h"
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/frame_util.h"
+#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/gfx/path.h"
#include "chrome/common/resource_bundle.h"
@@ -189,7 +189,8 @@ InfoBubble::ContentView* InfoBubble::CreateContentView(View* content) {
BrowserWindow* InfoBubble::GetHostingWindow() {
HWND owning_frame_hwnd = GetAncestor(GetHWND(), GA_ROOTOWNER);
- BrowserWindow* frame = FrameUtil::GetBrowserWindowForHWND(owning_frame_hwnd);
+ BrowserWindow* frame =
+ BrowserView::GetBrowserWindowForHWND(owning_frame_hwnd);
if (!frame) {
// We should always have a frame, but there was a bug else where that
// made it possible for the frame to be NULL, so we have the check. If
diff --git a/chrome/browser/views/tab_icon_view.cc b/chrome/browser/views/tab_icon_view.cc
index 245a38d..46595f6 100644
--- a/chrome/browser/views/tab_icon_view.cc
+++ b/chrome/browser/views/tab_icon_view.cc
@@ -50,8 +50,8 @@ void TabIconView::InitializeIfNeeded() {
}
}
-TabIconView::TabIconView(TabContentsProvider* provider)
- : provider_(provider),
+TabIconView::TabIconView(TabIconViewModel* model)
+ : model_(model),
is_light_(false),
throbber_running_(false),
throbber_frame_(0) {
@@ -62,10 +62,9 @@ TabIconView::~TabIconView() {
}
void TabIconView::Update() {
- TabContents* contents = provider_->GetCurrentTabContents();
if (throbber_running_) {
// We think the tab is loading.
- if (!contents || !contents->is_loading()) {
+ if (!model_->ShouldTabIconViewAnimate()) {
// Woops, tab is invalid or not loading, reset our status and schedule
// a paint.
throbber_running_ = false;
@@ -75,7 +74,7 @@ void TabIconView::Update() {
throbber_frame_ = (throbber_frame_ + 1) % g_throbber_frame_count;
SchedulePaint();
}
- } else if (contents && contents->is_loading()) {
+ } else if (model_->ShouldTabIconViewAnimate()) {
// We didn't think we were loading, but the tab is loading. Reset the
// frame and status and schedule a paint.
throbber_running_ = true;
@@ -106,25 +105,21 @@ void TabIconView::PaintFavIcon(ChromeCanvas* canvas, const SkBitmap& bitmap) {
}
void TabIconView::Paint(ChromeCanvas* canvas) {
- TabContents* contents = provider_->GetCurrentTabContents();
bool rendered = false;
- if (contents) {
- if (throbber_running_) {
+ if (throbber_running_) {
+ rendered = true;
+ PaintThrobber(canvas);
+ } else {
+ SkBitmap favicon = model_->GetFavIconForTabIconView();
+ if (!favicon.isNull()) {
rendered = true;
- PaintThrobber(canvas);
- } else {
- SkBitmap favicon = provider_->GetFavIcon();
- if (!favicon.isNull()) {
- rendered = true;
- PaintFavIcon(canvas, favicon);
- }
+ PaintFavIcon(canvas, favicon);
}
}
- if (!rendered) {
+ if (!rendered)
PaintFavIcon(canvas, *g_default_fav_icon);
- }
}
gfx::Size TabIconView::GetPreferredSize() {
diff --git a/chrome/browser/views/tab_icon_view.h b/chrome/browser/views/tab_icon_view.h
index 11b22d4..43302228 100644
--- a/chrome/browser/views/tab_icon_view.h
+++ b/chrome/browser/views/tab_icon_view.h
@@ -16,19 +16,19 @@ class TabContents;
////////////////////////////////////////////////////////////////////////////////
class TabIconView : public views::View {
public:
- class TabContentsProvider {
+ // Classes implement this interface to provide state for the TabIconView.
+ class TabIconViewModel {
public:
- // Should return the current tab contents this TabIconView object is
- // representing.
- virtual TabContents* GetCurrentTabContents() = 0;
+ // Returns true if the TabIconView should show a loading animation.
+ virtual bool ShouldTabIconViewAnimate() const = 0;
// Returns the favicon to display in the icon view
- virtual SkBitmap GetFavIcon() = 0;
+ virtual SkBitmap GetFavIconForTabIconView() = 0;
};
static void InitializeIfNeeded();
- explicit TabIconView(TabContentsProvider* provider);
+ explicit TabIconView(TabIconViewModel* provider);
virtual ~TabIconView();
// Invoke whenever the tab state changes or the throbber should update.
@@ -45,8 +45,8 @@ class TabIconView : public views::View {
void PaintThrobber(ChromeCanvas* canvas);
void PaintFavIcon(ChromeCanvas* canvas, const SkBitmap& bitmap);
- // Our provider of current tab contents.
- TabContentsProvider* provider_;
+ // Our model.
+ TabIconViewModel* model_;
// Whether the throbber is running.
bool throbber_running_;
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index db605a4..f81fc84 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -7,8 +7,8 @@
#include "chrome/browser/views/tabs/dragged_tab_controller.h"
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/frame_util.h"
#include "chrome/browser/tab_contents.h"
+#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/dragged_tab_view.h"
#include "chrome/browser/views/tabs/hwnd_photobooth.h"
#include "chrome/browser/views/tabs/tab.h"
@@ -441,7 +441,7 @@ TabStrip* DraggedTabController::GetTabStripForPoint(
if (!other_hwnd)
return NULL;
- BrowserWindow* other_frame = FrameUtil::GetBrowserWindowForHWND(other_hwnd);
+ BrowserWindow* other_frame = BrowserView::GetBrowserWindowForHWND(other_hwnd);
if (other_frame) {
TabStrip* other_tabstrip = other_frame->GetTabStrip();
if (!other_tabstrip->IsCompatibleWith(source_tabstrip_))
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 34f6c24..1b56e84 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -80,7 +80,7 @@ BrowserToolbarView::BrowserToolbarView(CommandController* controller,
forward_menu_model_.reset(new BackForwardMenuModel(
browser, BackForwardMenuModel::FORWARD_MENU_DELEGATE));
- if (browser->type() == BrowserType::TABBED_BROWSER)
+ if (browser->type() == Browser::TYPE_NORMAL)
display_mode_ = DISPLAYMODE_NORMAL;
else
display_mode_ = DISPLAYMODE_LOCATION;
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc
index 7b31a98..c6083a7 100644
--- a/chrome/browser/window_sizer.cc
+++ b/chrome/browser/window_sizer.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_type.h"
#include "chrome/browser/browser_window.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -140,7 +139,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
BrowserList::const_reverse_iterator end = BrowserList::end_last_active();
for (; it != end; ++it) {
Browser* last_active = *it;
- if (last_active && last_active->type() == BrowserType::TABBED_BROWSER) {
+ if (last_active && last_active->type() == Browser::TYPE_NORMAL) {
BrowserWindow* frame = last_active->window();
DCHECK(frame);
*bounds = frame->GetNormalBounds();
diff --git a/chrome/common/notification_types.h b/chrome/common/notification_types.h
index 05160bb..53e0954 100644
--- a/chrome/common/notification_types.h
+++ b/chrome/common/notification_types.h
@@ -200,6 +200,16 @@ enum NotificationType {
// No details are expected.
NOTIFY_WEB_CONTENTS_DISCONNECTED,
+ // This message is sent when a new message is added to a WebContents. The
+ // source is a Source<WebContents> with a pointer to the WebContents the
+ // message was added to.
+ NOTIFY_WEB_CONTENTS_MESSAGE_ADDED,
+
+ // This message is sent when a message is removed from a WebContents. The
+ // source is a Source<WebContents> with a pointer to the WebContents the
+ // message was removed from.
+ NOTIFY_WEB_CONTENTS_MESSAGE_REMOVED,
+
// This is sent when an externally hosted tab is created. The details contain
// the ExternalTabContainer that contains the tab
NOTIFY_EXTERNAL_TAB_CREATED,