diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-18 03:48:01 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-18 03:48:01 +0000 |
commit | 276ae6d3b89a1b521f54277669e73ed8e548fdb1 (patch) | |
tree | 2e81baca1aed143c3781409e2cd00aaab6608625 /chrome | |
parent | 4c561633e8eab426db0f94f3f03543e94c57ff77 (diff) | |
download | chromium_src-276ae6d3b89a1b521f54277669e73ed8e548fdb1.zip chromium_src-276ae6d3b89a1b521f54277669e73ed8e548fdb1.tar.gz chromium_src-276ae6d3b89a1b521f54277669e73ed8e548fdb1.tar.bz2 |
Revert change 5596 because it broke the build
Review URL: http://codereview.chromium.org/11439
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
35 files changed, 268 insertions, 192 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index 22f9e47..7d985ff 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, Browser::TYPE_NORMAL); + BrowserList::FindBrowserWithType(profile, BrowserType::TABBED_BROWSER); if (!browser || !browser->GetSelectedTabContents()) { navigator = &navigator_impl; } else { diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 156503f..142ef6f 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -139,7 +139,7 @@ struct Browser::UIUpdate { /////////////////////////////////////////////////////////////////////////////// // Browser, Constructors, Creation, Showing: -Browser::Browser(Type type, Profile* profile) +Browser::Browser(BrowserType::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(TYPE_NORMAL, profile); + Browser* browser = new Browser(BrowserType::TABBED_BROWSER, profile); browser->CreateBrowserWindow(); return browser; } // static Browser* Browser::CreateForPopup(Profile* profile) { - Browser* browser = new Browser(TYPE_POPUP, profile); + Browser* browser = new Browser(BrowserType::BROWSER, 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(TYPE_APP, profile); + Browser* browser = new Browser(BrowserType::APPLICATION, 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, - TYPE_NORMAL); + BrowserType::TABBED_BROWSER); 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() != TYPE_POPUP; + return type() != BrowserType::BROWSER; } 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_ == TYPE_APP && tabstrip_model_.count() == 1) { + if (type_ == BrowserType::APPLICATION && 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() == TYPE_NORMAL) { + if (type() == BrowserType::TABBED_BROWSER) { AddBlankTab(true); } else { Browser* b = GetOrCreateTabbedBrowser(); @@ -701,7 +701,7 @@ void Browser::RestoreTab() { void Browser::ConvertPopupToTabbedBrowser() { UserMetrics::RecordAction(L"ShowAsTab", profile_); - if (type() != TYPE_NORMAL) { + if (type() != BrowserType::BROWSER) { NOTREACHED(); return; } @@ -1197,10 +1197,10 @@ GURL Browser::GetBlankTabURL() const { void Browser::CreateNewStripWithContents(TabContents* detached_contents, const gfx::Rect& window_bounds) { - DCHECK(type_ == TYPE_NORMAL); + DCHECK(type_ == BrowserType::TABBED_BROWSER); // Create an empty new browser window the same size as the old one. - Browser* browser = new Browser(TYPE_NORMAL, profile_); + Browser* browser = new Browser(BrowserType::TABBED_BROWSER, profile_); browser->set_override_bounds(window_bounds); browser->CreateBrowserWindow(); browser->tabstrip_model()->AppendTabContents(detached_contents, true); @@ -1217,7 +1217,8 @@ void Browser::CreateNewStripWithContents(TabContents* detached_contents, int Browser::GetDragActions() const { int result = 0; - if (BrowserList::GetBrowserCountForType(profile_, TYPE_NORMAL) > 1 || + if (BrowserList::GetBrowserCountForType(profile_, + BrowserType::TABBED_BROWSER) > 1 || tab_count() > 1) result |= TAB_TEAROFF_ACTION; if (tab_count() > 1) @@ -1261,7 +1262,7 @@ void Browser::DuplicateContentsAt(int index) { TabContents* new_contents = NULL; DCHECK(contents); - if (type_ == TYPE_NORMAL) { + if (type_ == BrowserType::TABBED_BROWSER) { // 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()); @@ -1277,9 +1278,9 @@ void Browser::DuplicateContentsAt(int index) { PageTransition::LINK, true); } else { Browser* browser = NULL; - if (type_ == TYPE_APP) { + if (type_ == BrowserType::APPLICATION) { browser = Browser::CreateForApp(app_name_, profile_); - } else if (type_ == TYPE_POPUP) { + } else if (type_ == BrowserType::BROWSER) { browser = Browser::CreateForPopup(profile_); } @@ -1466,7 +1467,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_ == TYPE_APP) { + if (disposition != NEW_WINDOW && type_ == BrowserType::APPLICATION) { // 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). @@ -1602,7 +1603,7 @@ void Browser::AddNewContents(TabContents* source, // this in tabbed browser window. if (tabstrip_model_.count() > 0 && disposition != NEW_WINDOW && disposition != NEW_POPUP && - type_ != TYPE_NORMAL) { + type_ != BrowserType::TABBED_BROWSER) { Browser* b = GetOrCreateTabbedBrowser(); DCHECK(b); PageTransition::Type transition = PageTransition::LINK; @@ -1611,7 +1612,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_ == TYPE_APP) + if (type_ == BrowserType::APPLICATION) transition = PageTransition::START_PAGE; b->tabstrip_model()->AddTabContents(new_contents, -1, transition, true); b->window()->Show(); @@ -1671,7 +1672,7 @@ void Browser::CloseContents(TabContents* source) { } void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { - if (type() != TYPE_POPUP) { + if (type() != BrowserType::BROWSER) { NOTREACHED() << "moving invalid browser type"; return; } @@ -1680,7 +1681,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() == TYPE_POPUP); + return (type() == BrowserType::BROWSER); } void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) { @@ -1717,7 +1718,7 @@ void Browser::ContentsZoomChange(bool zoom_in) { } bool Browser::IsApplication() const { - return type_ == TYPE_APP; + return type_ == BrowserType::APPLICATION; } void Browser::ConvertContentsToApplication(TabContents* contents) { @@ -1840,7 +1841,8 @@ void Browser::InitCommandState() { controller_.UpdateCommandEnabled(IDC_STOP, true); controller_.UpdateCommandEnabled(IDC_RELOAD, true); - controller_.UpdateCommandEnabled(IDC_HOME, type() == TYPE_NORMAL); + controller_.UpdateCommandEnabled(IDC_HOME, + type() == BrowserType::TABBED_BROWSER); controller_.UpdateCommandEnabled(IDC_GO, true); controller_.UpdateCommandEnabled(IDC_NEWTAB, true); controller_.UpdateCommandEnabled(IDC_CLOSETAB, true); @@ -1934,11 +1936,13 @@ 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() != TYPE_NORMAL); - controller_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, type() == TYPE_POPUP); + controller_.UpdateCommandEnabled(IDC_CLOSE_WEB_APP, + type() != BrowserType::TABBED_BROWSER); + controller_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, + type() == BrowserType::BROWSER); controller_.UpdateCommandEnabled( IDC_RESTORE_TAB, (!profile_->IsOffTheRecord() && - type() == TYPE_NORMAL)); + type() == BrowserType::TABBED_BROWSER)); controller_.UpdateCommandEnabled(IDC_EXIT, true); // the debugger doesn't work in single process mode controller_.UpdateCommandEnabled(IDC_DEBUGGER, @@ -2280,7 +2284,7 @@ void Browser::ClearUnloadState(TabContents* tab) { Browser* Browser::GetOrCreateTabbedBrowser() { Browser* browser = BrowserList::FindBrowserWithType( - profile_, TYPE_NORMAL); + profile_, BrowserType::TABBED_BROWSER); if (!browser) browser = Browser::Create(profile_); return browser; @@ -2289,7 +2293,8 @@ Browser* Browser::GetOrCreateTabbedBrowser() { void Browser::BuildPopupWindow(TabContents* source, TabContents* new_contents, const gfx::Rect& initial_pos) { - Type type = type_ == TYPE_APP ? type_ : TYPE_POPUP; + BrowserType::Type type = + type_ == BrowserType::APPLICATION ? type_ : BrowserType::BROWSER; 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 4a77152..398f5ae 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -7,6 +7,7 @@ #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" @@ -34,18 +35,12 @@ 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(Type type, Profile* profile); + Browser(BrowserType::Type type, Profile* profile); ~Browser(); // Creates a normal tabbed browser with the specified profile. The Browser's @@ -74,7 +69,7 @@ class Browser : public TabStripModelDelegate, // Accessors //////////////////////////////////////////////////////////////// - Type type() const { return type_; } + BrowserType::Type type() const { return type_; } Profile* profile() const { return profile_; } BrowserWindow* window() const { return window_; } ToolbarModel* toolbar_model() { return &toolbar_model_; } @@ -499,7 +494,7 @@ class Browser : public TabStripModelDelegate, // Data members ///////////////////////////////////////////////////////////// // This Browser's type. - Type type_; + BrowserType::Type type_; // This Browser's profile. Profile* profile_; diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 3a791a3..6f54f24 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -986,6 +986,10 @@ > </File> <File + RelativePath=".\browser_type.h" + > + </File> + <File RelativePath=".\browser_window.h" > </File> @@ -1002,6 +1006,14 @@ > </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 209ebc3..4bf49f6 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() != Browser::TYPE_NORMAL) + if (!browser || browser->type() != BrowserType::TABBED_BROWSER) 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 67d6a56..9e0b2e4 100644 --- a/chrome/browser/browser_list.cc +++ b/chrome/browser/browser_list.cc @@ -6,9 +6,7 @@ #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" @@ -136,36 +134,6 @@ 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) { @@ -208,7 +176,7 @@ Browser* BrowserList::GetLastActive() { } // static -Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) { +Browser* BrowserList::FindBrowserWithType(Profile* p, BrowserType::Type t) { Browser* last_active = GetLastActive(); if (last_active && last_active->profile() == p && last_active->type() == t) return last_active; @@ -225,7 +193,7 @@ Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) { } // static -size_t BrowserList::GetBrowserCountForType(Profile* p, Browser::Type type) { +size_t BrowserList::GetBrowserCountForType(Profile* p, BrowserType::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 ef9a16f..f385777 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, Browser::Type t); + static Browser* FindBrowserWithType(Profile* p, BrowserType::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,9 +70,6 @@ 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); @@ -135,7 +132,7 @@ class BrowserList { // Return the number of browsers with the following profile and type which are // currently open. - static size_t GetBrowserCountForType(Profile* p, Browser::Type type); + static size_t GetBrowserCountForType(Profile* p, BrowserType::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 new file mode 100644 index 0000000..c82fcf3 --- /dev/null +++ b/chrome/browser/browser_type.h @@ -0,0 +1,28 @@ +// 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 new file mode 100644 index 0000000..b7cccd7 --- /dev/null +++ b/chrome/browser/frame_util.cc @@ -0,0 +1,68 @@ +// 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 new file mode 100644 index 0000000..1adaa7f --- /dev/null +++ b/chrome/browser/frame_util.h @@ -0,0 +1,25 @@ +// 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 c646b4a..9f9cf68 100644 --- a/chrome/browser/navigation_controller.cc +++ b/chrome/browser/navigation_controller.cc @@ -8,19 +8,18 @@ #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 cd156b5..5b5408f 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_id.h" +#include "chrome/browser/session_service.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 5c43b1b..64dae5e 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -5,6 +5,7 @@ #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" @@ -157,7 +158,7 @@ class NavigationControllerHistoryTest : public NavigationControllerTest { // Force the session service to be created. SessionService* service = profile->GetSessionService(); - service->SetWindowType(window_id, Browser::TYPE_NORMAL); + service->SetWindowType(window_id, BrowserType::TABBED_BROWSER); 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 258ed7c..b8ec569 100644 --- a/chrome/browser/session_restore.cc +++ b/chrome/browser/session_restore.cc @@ -12,7 +12,6 @@ #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" @@ -287,14 +286,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 == Browser::TYPE_NORMAL) + if (!has_tabbed_browser && (*i)->type == BrowserType::TABBED_BROWSER) has_tabbed_browser = true; - if (i == windows->begin() && (*i)->type == Browser::TYPE_NORMAL && + if (i == windows->begin() && (*i)->type == BrowserType::TABBED_BROWSER && !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() != Browser::TYPE_NORMAL || + if (browser && (browser->type() != BrowserType::TABBED_BROWSER || browser->profile()->IsOffTheRecord())) { browser = NULL; } @@ -305,7 +304,7 @@ class SessionRestoreImpl : public NotificationObserver { browser->set_override_maximized((*i)->is_maximized); browser->CreateBrowserWindow(); } - if ((*i)->type == Browser::TYPE_NORMAL) + if ((*i)->type == BrowserType::TABBED_BROWSER) last_browser = browser; const int initial_tab_count = browser->tab_count(); RestoreTabsToBrowser(*(*i), browser); @@ -317,7 +316,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() == Browser::TYPE_NORMAL) { + current_browser->type() == BrowserType::TABBED_BROWSER) { 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 f5e042e..d1b848b 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, - Browser::Type type) { + BrowserType::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, - Browser::Type type) { + BrowserType::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<Browser::Type>(payload.index); + static_cast<BrowserType::Type>(payload.index); break; } diff --git a/chrome/browser/session_service.h b/chrome/browser/session_service.h index 2ff8608..68b6c74b 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.h" +#include "chrome/browser/browser_type.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(Browser::TYPE_NORMAL), + type(BrowserType::TABBED_BROWSER), 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 - // TYPE_NORMAL and TYPE_POPUP. - Browser::Type type; + // TABBED_BROWSER and BROWSER. + BrowserType::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, Browser::Type type); + void SetWindowType(const SessionID& window_id, BrowserType::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, - Browser::Type type); + BrowserType::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(Browser::Type type) { - return type == Browser::TYPE_NORMAL; + static bool should_track_changes_for_browser_type(BrowserType::Type type) { + return type == BrowserType::TABBED_BROWSER; } // 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 fc2a2d7..08dbf37 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, Browser::TYPE_NORMAL); + service()->SetWindowType(window_id, BrowserType::TABBED_BROWSER); 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(Browser::TYPE_NORMAL, windows[0]->type); + ASSERT_EQ(BrowserType::TABBED_BROWSER, 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, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER); 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, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER); 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, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, BrowserType::TABBED_BROWSER); 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, Browser::TYPE_POPUP); + service()->SetWindowType(window2_id, BrowserType::BROWSER); 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 4fcbe8c..e815a62 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 == Browser::TYPE_NORMAL) { + if (window->type == BrowserType::TABBED_BROWSER) { 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 != Browser::TYPE_NORMAL) + if (window->type != BrowserType::TABBED_BROWSER) 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 176bf94..9c29452 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() == Browser::TYPE_NORMAL; + return browser->type() == BrowserType::TABBED_BROWSER; } // static diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index 5a543cd..6f38c89 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -216,6 +216,14 @@ RelativePath=".\info_bar_view.h" > </File> + <File + RelativePath=".\tab_icon_view.cc" + > + </File> + <File + RelativePath=".\tab_icon_view.h" + > + </File> </Filter> <Filter Name="Options" @@ -770,14 +778,6 @@ > </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 a24e274..0c5846a 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/browser_list.h" +#include "chrome/browser/frame_util.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) { - BrowserList::WindowsSessionEnding(); + FrameUtil::EndSession(); } 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 35fb7b8..01ff721 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -138,16 +138,6 @@ 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); @@ -197,7 +187,7 @@ bool BrowserView::IsOffTheRecord() const { } bool BrowserView::ShouldShowOffTheRecordAvatar() const { - return IsOffTheRecord() && browser_->type() == Browser::TYPE_NORMAL; + return IsOffTheRecord() && browser_->type() == BrowserType::TABBED_BROWSER; } bool BrowserView::AcceleratorPressed(const views::Accelerator& accelerator) { @@ -291,13 +281,13 @@ bool BrowserView::SupportsWindowFeature(WindowFeature feature) const { } // static -unsigned int BrowserView::FeaturesForBrowserType(Browser::Type type) { +unsigned int BrowserView::FeaturesForBrowserType(BrowserType::Type type) { unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; - if (type == Browser::TYPE_NORMAL) + if (type == BrowserType::TABBED_BROWSER) features |= FEATURE_TABSTRIP | FEATURE_TOOLBAR | FEATURE_BOOKMARKBAR; - if (type != Browser::TYPE_APP) + if (type != BrowserType::APPLICATION) features |= FEATURE_LOCATIONBAR; - if (type != Browser::TYPE_NORMAL) + if (type != BrowserType::TABBED_BROWSER) features |= FEATURE_TITLEBAR; return features; } @@ -696,7 +686,7 @@ bool BrowserView::ShouldShowWindowTitle() const { } SkBitmap BrowserView::GetWindowIcon() { - if (browser_->type() == Browser::TYPE_APP) + if (browser_->type() == BrowserType::APPLICATION) return browser_->GetCurrentPageIcon(); return SkBitmap(); } @@ -735,7 +725,7 @@ void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { *bounds = browser_->GetSavedWindowBounds(); - if (browser_->type() == Browser::TYPE_POPUP) { + if (browser_->type() == BrowserType::BROWSER) { // 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). @@ -976,7 +966,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() == Browser::TYPE_NORMAL) { + if (browser_->type() == BrowserType::TABBED_BROWSER) { 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 d777f5a..fcc0ee4 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.h" +#include "chrome/browser/browser_type.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,11 +43,6 @@ 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; @@ -139,7 +134,7 @@ class BrowserView : public BrowserWindow, bool SupportsWindowFeature(WindowFeature feature) const; // Returns the set of WindowFeatures supported by the specified BrowserType. - static unsigned int FeaturesForBrowserType(Browser::Type type); + static unsigned int FeaturesForBrowserType(BrowserType::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 9a6853b..59a8d9d 100644 --- a/chrome/browser/views/frame/browser_window_factory.cc +++ b/chrome/browser/views/frame/browser_window_factory.cc @@ -6,6 +6,7 @@ #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 f04d8e2..3158af7 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/browser_list.h" +#include "chrome/browser/frame_util.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) { - BrowserList::WindowsSessionEnding(); + FrameUtil::EndSession(); } 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 74ee416..460a1f8 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.cc +++ b/chrome/browser/views/frame/opaque_non_client_view.cc @@ -5,7 +5,6 @@ #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" @@ -480,11 +479,11 @@ void OpaqueNonClientView::UpdateWindowIcon() { /////////////////////////////////////////////////////////////////////////////// // OpaqueNonClientView, TabIconView::TabContentsProvider implementation: -bool OpaqueNonClientView::ShouldTabIconViewAnimate() const { - return browser_view_->GetSelectedTabContents()->is_loading(); +TabContents* OpaqueNonClientView::GetCurrentTabContents() { + return browser_view_->GetSelectedTabContents(); } -SkBitmap OpaqueNonClientView::GetFavIconForTabIconView() { +SkBitmap OpaqueNonClientView::GetFavIcon() { 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 93cee85..6d22a5b 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::TabIconViewModel { + public TabIconView::TabContentsProvider { 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::TabIconViewModel: - virtual bool ShouldTabIconViewAnimate() const; - virtual SkBitmap GetFavIconForTabIconView(); + // Overridden from TabIconView::TabContentsProvider: + virtual TabContents* GetCurrentTabContents(); + virtual SkBitmap GetFavIcon(); // 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 3b8b28c..68e09adf 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -11,7 +11,6 @@ #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 0fc2264..9106b3e 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/views/frame/browser_view.h" +#include "chrome/browser/frame_util.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/path.h" #include "chrome/common/resource_bundle.h" @@ -189,8 +189,7 @@ InfoBubble::ContentView* InfoBubble::CreateContentView(View* content) { BrowserWindow* InfoBubble::GetHostingWindow() { HWND owning_frame_hwnd = GetAncestor(GetHWND(), GA_ROOTOWNER); - BrowserWindow* frame = - BrowserView::GetBrowserWindowForHWND(owning_frame_hwnd); + BrowserWindow* frame = FrameUtil::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 46595f6..245a38d 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(TabIconViewModel* model) - : model_(model), +TabIconView::TabIconView(TabContentsProvider* provider) + : provider_(provider), is_light_(false), throbber_running_(false), throbber_frame_(0) { @@ -62,9 +62,10 @@ TabIconView::~TabIconView() { } void TabIconView::Update() { + TabContents* contents = provider_->GetCurrentTabContents(); if (throbber_running_) { // We think the tab is loading. - if (!model_->ShouldTabIconViewAnimate()) { + if (!contents || !contents->is_loading()) { // Woops, tab is invalid or not loading, reset our status and schedule // a paint. throbber_running_ = false; @@ -74,7 +75,7 @@ void TabIconView::Update() { throbber_frame_ = (throbber_frame_ + 1) % g_throbber_frame_count; SchedulePaint(); } - } else if (model_->ShouldTabIconViewAnimate()) { + } else if (contents && contents->is_loading()) { // We didn't think we were loading, but the tab is loading. Reset the // frame and status and schedule a paint. throbber_running_ = true; @@ -105,21 +106,25 @@ void TabIconView::PaintFavIcon(ChromeCanvas* canvas, const SkBitmap& bitmap) { } void TabIconView::Paint(ChromeCanvas* canvas) { + TabContents* contents = provider_->GetCurrentTabContents(); bool rendered = false; - if (throbber_running_) { - rendered = true; - PaintThrobber(canvas); - } else { - SkBitmap favicon = model_->GetFavIconForTabIconView(); - if (!favicon.isNull()) { + if (contents) { + if (throbber_running_) { rendered = true; - PaintFavIcon(canvas, favicon); + PaintThrobber(canvas); + } else { + SkBitmap favicon = provider_->GetFavIcon(); + if (!favicon.isNull()) { + rendered = true; + 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 43302228..11b22d4 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: - // Classes implement this interface to provide state for the TabIconView. - class TabIconViewModel { + class TabContentsProvider { public: - // Returns true if the TabIconView should show a loading animation. - virtual bool ShouldTabIconViewAnimate() const = 0; + // Should return the current tab contents this TabIconView object is + // representing. + virtual TabContents* GetCurrentTabContents() = 0; // Returns the favicon to display in the icon view - virtual SkBitmap GetFavIconForTabIconView() = 0; + virtual SkBitmap GetFavIcon() = 0; }; static void InitializeIfNeeded(); - explicit TabIconView(TabIconViewModel* provider); + explicit TabIconView(TabContentsProvider* 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 model. - TabIconViewModel* model_; + // Our provider of current tab contents. + TabContentsProvider* provider_; // 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 d90bad7..0bca5f1 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" @@ -442,7 +442,7 @@ TabStrip* DraggedTabController::GetTabStripForPoint( if (!other_hwnd) return NULL; - BrowserWindow* other_frame = BrowserView::GetBrowserWindowForHWND(other_hwnd); + BrowserWindow* other_frame = FrameUtil::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 1b56e84..34f6c24 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() == Browser::TYPE_NORMAL) + if (browser->type() == BrowserType::TABBED_BROWSER) display_mode_ = DISPLAYMODE_NORMAL; else display_mode_ = DISPLAYMODE_LOCATION; diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc index c6083a7..7b31a98 100644 --- a/chrome/browser/window_sizer.cc +++ b/chrome/browser/window_sizer.cc @@ -7,6 +7,7 @@ #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" @@ -139,7 +140,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() == Browser::TYPE_NORMAL) { + if (last_active && last_active->type() == BrowserType::TABBED_BROWSER) { 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 53e0954..05160bb 100644 --- a/chrome/common/notification_types.h +++ b/chrome/common/notification_types.h @@ -200,16 +200,6 @@ 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, |