summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_provider.cc8
-rw-r--r--chrome/browser/browser.cc151
-rw-r--r--chrome/browser/browser.h9
-rw-r--r--chrome/browser/browser_list.cc2
-rw-r--r--chrome/browser/browser_window.h45
-rw-r--r--chrome/browser/history/history.cc6
-rw-r--r--chrome/browser/repost_form_warning_dialog.cc8
-rw-r--r--chrome/browser/tab_contents_delegate.h4
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model.h9
-rw-r--r--chrome/browser/views/frame/browser_view.cc101
-rw-r--r--chrome/browser/views/frame/browser_view.h11
-rw-r--r--chrome/browser/views/importer_view.cc4
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc10
-rw-r--r--chrome/browser/views/toolbar_star_toggle.cc6
-rw-r--r--chrome/browser/web_contents_view_win.cc8
16 files changed, 235 insertions, 151 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 3304de1..aaf7978 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1407,7 +1407,8 @@ void AutomationProvider::WindowSimulateDrag(const IPC::Message& message,
// since SendInput is system-wide.
Browser* browser = browser_tracker_->GetResource(handle);
DCHECK(browser);
- HWND browser_hwnd = browser->GetTopLevelHWND();
+ HWND browser_hwnd =
+ reinterpret_cast<HWND>(browser->window()->GetNativeHandle());
// We can't simulate drags to the non-client area of the window, because
// Windows spawns a nested modal message loop in cases where drags occur
@@ -1967,7 +1968,7 @@ void AutomationProvider::GetWindowForBrowser(const IPC::Message& message,
if (browser_tracker_->ContainsHandle(browser_handle)) {
Browser* browser = browser_tracker_->GetResource(browser_handle);
- HWND hwnd = browser->GetTopLevelHWND();
+ HWND hwnd = reinterpret_cast<HWND>(browser->window()->GetNativeHandle());
// Add() returns the existing handle for the resource if any.
window_handle = window_tracker_->Add(hwnd);
success = true;
@@ -2004,7 +2005,8 @@ void AutomationProvider::GetBrowserForWindow(const IPC::Message& message,
BrowserList::const_iterator iter = BrowserList::begin();
Browser* browser = NULL;
for (;iter != BrowserList::end(); ++iter) {
- if (window == (*iter)->GetTopLevelHWND()) {
+ HWND hwnd = reinterpret_cast<HWND>((*iter)->window()->GetNativeHandle());
+ if (window == hwnd) {
browser = *iter;
break;
}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 5bbfc65..2b2a381 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/browser.h"
#include "base/command_line.h"
-#include "base/file_version_info.h"
#include "base/idle_timer.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -25,7 +24,6 @@
#include "chrome/browser/debugger/debugger_window.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/download/save_package.h"
-#include "chrome/browser/frame_util.h"
#include "chrome/browser/history_tab_ui.h"
#include "chrome/browser/interstitial_page.h"
#include "chrome/browser/navigation_controller.h"
@@ -40,21 +38,10 @@
#include "chrome/browser/url_fixer_upper.h"
#include "chrome/browser/user_metrics.h"
#include "chrome/browser/view_ids.h"
-#include "chrome/browser/views/about_chrome_view.h"
-#include "chrome/browser/views/bookmark_bar_view.h"
-#include "chrome/browser/views/bookmark_manager_view.h"
-#include "chrome/browser/views/bug_report_view.h"
-#include "chrome/browser/views/clear_browsing_data.h"
-#include "chrome/browser/views/download_shelf_view.h"
#include "chrome/browser/views/download_tab_view.h"
#include "chrome/browser/views/go_button.h"
-#include "chrome/browser/views/html_dialog_view.h"
-#include "chrome/browser/views/importer_view.h"
-#include "chrome/browser/views/keyword_editor_view.h"
#include "chrome/browser/views/location_bar_view.h"
-#include "chrome/browser/views/password_manager_view.h"
#include "chrome/browser/views/status_bubble.h"
-#include "chrome/browser/views/tabs/tab_strip.h"
#include "chrome/browser/views/toolbar_star_toggle.h"
#include "chrome/browser/web_contents_view.h"
#include "chrome/browser/window_sizer.h"
@@ -320,13 +307,6 @@ bool Browser::IsCommandEnabled(int id) const {
}
///////////////////////////////////////////////////////////////////////////////
-// Browser, DEPRECATED DEPRECATED DEPRECATED:
-
-HWND Browser::GetTopLevelHWND() const {
- return window_ ? reinterpret_cast<HWND>(window_->GetNativeHandle()) : NULL;
-}
-
-///////////////////////////////////////////////////////////////////////////////
// Browser, State Storage and Retrieval for UI:
void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
@@ -959,63 +939,22 @@ void Browser::OverrideEncoding(int encoding_id) {
void Browser::OpenKeywordEditor() {
UserMetrics::RecordAction(L"EditSearchEngines", profile_);
- KeywordEditorView::Show(profile());
+ window_->ShowSearchEnginesDialog();
}
void Browser::OpenClearBrowsingDataDialog() {
UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_);
- views::Window::CreateChromeWindow(
- GetTopLevelHWND(),
- gfx::Rect(),
- new ClearBrowsingDataView(profile_))->Show();
+ window_->ShowClearBrowsingDataDialog();
}
void Browser::OpenImportSettingsDialog() {
UserMetrics::RecordAction(L"Import_ShowDlg", profile_);
- views::Window::CreateChromeWindow(GetTopLevelHWND(), gfx::Rect(),
- new ImporterView(profile_))->Show();
+ window_->ShowImportDialog();
}
void Browser::OpenBugReportDialog() {
UserMetrics::RecordAction(L"ReportBug", profile_);
-
- // Retrieve the URL for the current tab (if any) and tell the BugReportView
- TabContents* current_tab = GetSelectedTabContents();
- if (!current_tab)
- return;
-
- BugReportView* bug_report_view = new BugReportView(profile_, current_tab);
-
- if (current_tab->controller()->GetLastCommittedEntry()) {
- if (current_tab->type() == TAB_CONTENTS_WEB) {
- // URL for the current page
- bug_report_view->SetUrl(
- current_tab->controller()->GetActiveEntry()->url());
- }
- }
-
- // retrieve the application version info
- std::wstring version;
- scoped_ptr<FileVersionInfo> version_info(
- FileVersionInfo::CreateFileVersionInfoForCurrentModule());
- if (version_info.get()) {
- version = version_info->product_name() + L" - " +
- version_info->file_version() +
- L" (" + version_info->last_change() + L")";
- }
- bug_report_view->set_version(version);
-
- // Grab an exact snapshot of the window that the user is seeing (i.e. as
- // rendered--do not re-render, and include windowed plugins)
- std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>;
- win_util::GrabWindowSnapshot(GetTopLevelHWND(), screenshot_png);
- // the BugReportView takes ownership of the png data, and will dispose of
- // it in its destructor.
- bug_report_view->set_png_data(screenshot_png);
-
- // Create and show the dialog
- views::Window::CreateChromeWindow(GetTopLevelHWND(), gfx::Rect(),
- bug_report_view)->Show();
+ window_->ShowReportBugDialog();
}
void Browser::OpenDebuggerWindow() {
@@ -1049,23 +988,25 @@ void Browser::OpenCreateShortcutsDialog() {
}
void Browser::OpenPasswordManager() {
- PasswordManagerView::Show(profile_);
+ window_->ShowPasswordManager();
}
void Browser::OpenAboutChromeDialog() {
UserMetrics::RecordAction(L"AboutChrome", profile_);
- views::Window::CreateChromeWindow(GetTopLevelHWND(), gfx::Rect(),
- new AboutChromeView(profile_))->Show();
+ window_->ShowAboutChromeDialog();
}
void Browser::OpenFile() {
UserMetrics::RecordAction(L"OpenFile", profile_);
if (!select_file_dialog_.get())
select_file_dialog_ = SelectFileDialog::Create(this);
+
+ // TODO(beng): figure out how to juggle this.
+ HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle());
select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE,
std::wstring(), std::wstring(),
std::wstring(), std::wstring(),
- GetTopLevelHWND(), NULL);
+ parent_hwnd, NULL);
}
void Browser::OpenTaskManager() {
@@ -1096,12 +1037,12 @@ void Browser::ShowDownloadsTab() {
void Browser::OpenBookmarksManager() {
UserMetrics::RecordAction(L"ShowBookmarkManager", profile_);
- BookmarkManagerView::Show(profile_);
+ window_->ShowBookmarkManager();
}
void Browser::ToggleBookmarksBar() {
UserMetrics::RecordAction(L"ShowBookmarksBar", profile_);
- BookmarkBarView::ToggleWhenVisible(profile_);
+ window_->ToggleBookmarkBar();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1286,28 +1227,19 @@ GURL Browser::GetBlankTabURL() const {
}
void Browser::CreateNewStripWithContents(TabContents* detached_contents,
- const gfx::Point& drop_point) {
+ const gfx::Rect& window_bounds) {
DCHECK(type_ == BrowserType::TABBED_BROWSER);
-
+
// Create an empty new browser window the same size as the old one.
- // TODO(beng): move elsewhere
- CRect browser_rect;
- GetWindowRect(reinterpret_cast<HWND>(window_->GetNativeHandle()),
- &browser_rect);
- gfx::Rect rect(0, 0);
- if (drop_point.x() != 0 || drop_point.y() != 0) {
- rect.SetRect(drop_point.x(), drop_point.y(), browser_rect.Width(),
- browser_rect.Height());
- }
Browser* browser = new Browser(BrowserType::TABBED_BROWSER, profile_);
- browser->set_override_bounds(rect);
+ browser->set_override_bounds(window_bounds);
browser->CreateBrowserWindow();
browser->tabstrip_model()->AppendTabContents(detached_contents, true);
browser->window()->Show();
// When we detach a tab we need to make sure any associated Find window moves
- // along with it to its new home (basically we just make new_window the parent
- // of the Find window).
+ // along with it to its new home (basically we just make new_window the
+ // parent of the Find window).
// TODO(brettw) this could probably be improved, see
// WebContentsView::ReparentFindWindow for more.
if (detached_contents->AsWebContents())
@@ -1334,8 +1266,9 @@ TabContents* Browser::CreateTabContentsForURL(
TabContentsType type = TabContents::TypeForURL(&real_url);
DCHECK(type != TAB_CONTENTS_UNKNOWN_TYPE);
- TabContents* contents =
- TabContents::CreateWithType(type, GetTopLevelHWND(), profile, instance);
+ HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle());
+ TabContents* contents = TabContents::CreateWithType(type, parent_hwnd,
+ profile, instance);
contents->SetupController(profile);
if (!defer_load) {
@@ -1363,8 +1296,9 @@ void Browser::DuplicateContentsAt(int index) {
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());
new_contents = contents->controller()->Clone(
- GetTopLevelHWND())->active_contents();
+ parent_hwnd)->active_contents();
// If you duplicate a tab that is not selected, we need to make sure to
// select the tab being duplicated so that DetermineInsertionIndex returns
// the right index (if tab 5 is selected and we right-click tab 1 we want
@@ -1386,8 +1320,9 @@ void Browser::DuplicateContentsAt(int index) {
browser->window()->Show();
// The page transition below is only for the purpose of inserting the tab.
+ HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle());
new_contents = browser->AddTabWithNavigationController(
- contents->controller()->Clone(browser->GetTopLevelHWND()),
+ contents->controller()->Clone(parent_hwnd),
PageTransition::LINK);
}
@@ -1412,7 +1347,7 @@ void Browser::CloseFrameAfterDragSession() {
method_factory_.NewRunnableMethod(&Browser::CloseFrame));
}
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// Browser, TabStripModelObserver implementation:
void Browser::TabInsertedAt(TabContents* contents,
@@ -1506,8 +1441,8 @@ void Browser::TabSelectedAt(TabContents* old_contents,
if (profile_->HasSessionService()) {
SessionService* session_service = profile_->GetSessionService();
if (session_service && !tabstrip_model_.closing_all()) {
- session_service->SetSelectedTabInWindow(session_id(),
- tabstrip_model_.selected_index());
+ session_service->SetSelectedTabInWindow(
+ session_id(), tabstrip_model_.selected_index());
}
}
}
@@ -1630,8 +1565,8 @@ void Browser::OpenURLFromTab(TabContents* source,
}
}
current_tab->controller()->LoadURL(url, referrer, transition);
- // The TabContents might have changed as part of the navigation (ex: new tab
- // page can become WebContents).
+ // The TabContents might have changed as part of the navigation (ex: new
+ // tab page can become WebContents).
new_contents = current_tab->controller()->active_contents();
GetStatusBubble()->Hide();
@@ -1785,10 +1720,7 @@ void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) {
NOTREACHED() << "moving invalid browser type";
return;
}
-
- ::SetWindowPos(GetTopLevelHWND(), NULL, pos.x(), pos.y(), pos.width(),
- pos.height(), 0);
- win_util::AdjustWindowToFit(GetTopLevelHWND());
+ window_->SetBounds(pos);
}
bool Browser::IsPopup(TabContents* source) {
@@ -1880,7 +1812,8 @@ void Browser::BeforeUnloadFired(TabContents* tab,
}
if (RemoveFromVector(&tabs_needing_before_unload_fired_, tab)) {
- // Now that beforeunload has fired, put the tab on the queue to fire unload.
+ // Now that beforeunload has fired, put the tab on the queue to fire
+ // unload.
tabs_needing_unload_fired_.push_back(tab);
ProcessPendingTabs();
// We want to handle firing the unload event ourselves since we want to
@@ -1894,12 +1827,8 @@ void Browser::BeforeUnloadFired(TabContents* tab,
}
void Browser::ShowHtmlDialog(HtmlDialogContentsDelegate* delegate,
- HWND parent_hwnd) {
- parent_hwnd = parent_hwnd ? parent_hwnd : GetTopLevelHWND();
- HtmlDialogView* html_view = new HtmlDialogView(this, profile_, delegate);
- views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view);
- html_view->InitDialog();
- html_view->window()->Show();
+ void* parent_window) {
+ window_->ShowHTMLDialog(delegate, parent_window);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2187,9 +2116,9 @@ void Browser::ProcessPendingUIUpdates() {
chrome_updater_factory_.RevokeAll();
- // We could have many updates for the same thing in the queue. This map tracks
- // the bits of the stuff we've already updated for each TabContents so we
- // don't update again.
+ // We could have many updates for the same thing in the queue. This map
+ // tracks the bits of the stuff we've already updated for each TabContents so
+ // we don't update again.
typedef std::map<const TabContents*, unsigned> UpdateTracker;
UpdateTracker updated_stuff;
@@ -2308,8 +2237,9 @@ NavigationController* Browser::BuildRestoredNavigationController(
// Create a NavigationController. This constructor creates the appropriate
// set of TabContents.
+ HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle());
return new NavigationController(
- profile_, navigations, selected_navigation, GetTopLevelHWND());
+ profile_, navigations, selected_navigation, parent_hwnd);
} else {
// No navigations. Create a tab with about:blank.
TabContents* contents =
@@ -2371,7 +2301,8 @@ void Browser::CancelWindowClose() {
is_attempting_to_close_browser_ = false;
}
-bool Browser::RemoveFromVector(UnloadListenerVector* vector, TabContents* tab) {
+bool Browser::RemoveFromVector(UnloadListenerVector* vector,
+ TabContents* tab) {
DCHECK(is_attempting_to_close_browser_);
for (UnloadListenerVector::iterator it = vector->begin();
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 278c39d..353ab4b 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -95,11 +95,6 @@ class Browser : public TabStripModelDelegate,
bool SupportsCommand(int id) const;
bool IsCommandEnabled(int id) const;
- // DEPRECATED DEPRECATED DEPRECATED /////////////////////////////////////////
-
- // Returns the HWND of the top-level system window for this Browser.
- HWND GetTopLevelHWND() const;
-
// State Storage and Retrieval for UI ///////////////////////////////////////
// Save and restore the window position.
@@ -296,7 +291,7 @@ class Browser : public TabStripModelDelegate,
// Overridden from TabStripModelDelegate:
virtual GURL GetBlankTabURL() const;
virtual void CreateNewStripWithContents(TabContents* detached_contents,
- const gfx::Point& drop_point);
+ const gfx::Rect& window_bounds);
virtual int GetDragActions() const;
// Construct a TabContents for a given URL, profile and transition type.
// If instance is not null, its process will be used to render the tab.
@@ -360,7 +355,7 @@ class Browser : public TabStripModelDelegate,
bool proceed,
bool* proceed_to_fire_unload);
virtual void ShowHtmlDialog(HtmlDialogContentsDelegate* delegate,
- HWND parent_hwnd);
+ void* parent_window);
// Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const std::wstring& path, void* params);
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 45d12c7..9e0b2e4 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -109,7 +109,7 @@ void BrowserList::CloseAllBrowsers(bool use_post) {
BrowserList::const_iterator iter;
for (iter = BrowserList::begin(); iter != BrowserList::end();) {
if (use_post) {
- ::PostMessage((*iter)->GetTopLevelHWND(), WM_CLOSE, 0, 0);
+ (*iter)->window()->Close();
++iter;
} else {
// This path is hit during logoff/power-down. In this case we won't get
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 97a8292..f500c42 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -5,25 +5,21 @@
#ifndef CHROME_BROWSER_BROWSER_WINDOW_H_
#define CHROME_BROWSER_BROWSER_WINDOW_H_
-#include <map>
-
-#include "base/gfx/point.h"
-#include "base/gfx/rect.h"
-#include "chrome/views/accelerator.h"
-
class BookmarkBarView;
class Browser;
class BrowserList;
class BrowserView;
class GoButton;
class LocationBarView;
+class HtmlDialogContentsDelegate;
class Profile;
class StatusBubble;
class TabContents;
class TabStrip;
class ToolbarStarToggle;
-namespace views {
-class RootView;
+
+namespace gfx {
+class Rect;
}
////////////////////////////////////////////////////////////////////////////////
@@ -38,6 +34,9 @@ class BrowserWindow {
// Show the window, or activates it if it's already visible.
virtual void Show() = 0;
+ // Sets the window's size and position to the specified values.
+ virtual void SetBounds(const gfx::Rect& bounds) = 0;
+
// Closes the frame as soon as possible. If the frame is not in a drag
// session, it will close immediately; otherwise, it will move offscreen (so
// events are still fired) until the drag ends, then close.
@@ -109,6 +108,36 @@ class BrowserWindow {
// Returns whether the bookmark bar is visible or not.
virtual bool IsBookmarkBarVisible() const = 0;
+ // Shows or hides the bookmark bar depending on its current visibility.
+ virtual void ToggleBookmarkBar() = 0;
+
+ // Shows the About Chrome dialog box.
+ virtual void ShowAboutChromeDialog() = 0;
+
+ // Shows the Bookmark Manager window.
+ virtual void ShowBookmarkManager() = 0;
+
+ // Shows the Report a Bug dialog box.
+ virtual void ShowReportBugDialog() = 0;
+
+ // Shows the Clear Browsing Data dialog box.
+ virtual void ShowClearBrowsingDataDialog() = 0;
+
+ // Shows the Import Bookmarks & Settings dialog box.
+ virtual void ShowImportDialog() = 0;
+
+ // Shows the Search Engines dialog box.
+ virtual void ShowSearchEnginesDialog() = 0;
+
+ // Shows the Password Manager dialog box.
+ virtual void ShowPasswordManager() = 0;
+
+ // Shows a dialog box with HTML content, e.g. for Gears. |parent_window| is
+ // the window the dialog should be opened modal to and is a native window
+ // handle.
+ virtual void ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
+ void* parent_window) = 0;
+
// Construct a BrowserWindow implementation for the specified |browser|.
static BrowserWindow* CreateBrowserWindow(Browser* browser);
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 53afbd5..4e64b55 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -597,7 +597,11 @@ void HistoryService::SetInMemoryBackend(
void HistoryService::NotifyTooNew() {
// Find the last browser window to display our message box from.
Browser* cur_browser = BrowserList::GetLastActive();
- HWND cur_hwnd = cur_browser ? cur_browser->GetTopLevelHWND() : NULL;
+ // TODO(brettw): Do this some other way or beng will kick you. e.g. move to
+ // BrowserView.
+ HWND parent_hwnd =
+ reinterpret_cast<HWND>(cur_browser->window()->GetNativeHandle());
+ HWND cur_hwnd = cur_browser ? parent_hwnd : NULL;
std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME);
std::wstring message = l10n_util::GetString(IDS_PROFILE_TOO_NEW_ERROR);
diff --git a/chrome/browser/repost_form_warning_dialog.cc b/chrome/browser/repost_form_warning_dialog.cc
index 5ae4d0e..c030265 100644
--- a/chrome/browser/repost_form_warning_dialog.cc
+++ b/chrome/browser/repost_form_warning_dialog.cc
@@ -77,9 +77,13 @@ RepostFormWarningDialog::RepostFormWarningDialog(
MessageBoxView::kIsConfirmMessageBox,
l10n_util::GetString(IDS_HTTP_POST_WARNING),
L"");
+ // TODO(beng): fix this - this dialog box should be shown by a method on the
+ // Browser.
HWND root_hwnd = NULL;
- if (BrowserList::GetLastActive())
- root_hwnd = BrowserList::GetLastActive()->GetTopLevelHWND();
+ if (BrowserList::GetLastActive()) {
+ root_hwnd = reinterpret_cast<HWND>(BrowserList::GetLastActive()->
+ window()->GetNativeHandle());
+ }
views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show();
NotificationService::current()->
AddObserver(this, NOTIFY_LOAD_START, NotificationService::AllSources());
diff --git a/chrome/browser/tab_contents_delegate.h b/chrome/browser/tab_contents_delegate.h
index 2365757..c845dec 100644
--- a/chrome/browser/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents_delegate.h
@@ -123,10 +123,10 @@ class TabContentsDelegate : public PageNavigator {
// Show a dialog with HTML content. |delegate| contains a pointer to the
// delegate who knows how to display the dialog (which file URL and JSON
- // string input to use during initialization). |parent_hwnd| is the window
+ // string input to use during initialization). |parent_window| is the window
// that should be parent of the dialog, or NULL for the default.
virtual void ShowHtmlDialog(HtmlDialogContentsDelegate* delegate,
- HWND parent_hwnd) { }
+ void* parent_window) { }
// Tells us that we've finished firing this tab's beforeunload event.
// The proceed bool tells us whether the user chose to proceed closing the
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index a7bd855..ac5b2dc 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -406,9 +406,9 @@ void TabStripModel::SelectLastTab() {
}
void TabStripModel::TearOffTabContents(TabContents* detached_contents,
- const gfx::Point& drop_point) {
+ const gfx::Rect& window_bounds) {
DCHECK(detached_contents);
- delegate_->CreateNewStripWithContents(detached_contents, drop_point);
+ delegate_->CreateNewStripWithContents(detached_contents, window_bounds);
}
// Context menu functions.
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index bd93a96..ebdec91 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -99,12 +99,9 @@ class TabStripModelDelegate {
virtual GURL GetBlankTabURL() const = 0;
// Ask for a new TabStripModel to be created and the given tab contents to
- // be added to it. Its presentation (e.g. a browser window) anchored at the
- // specified creation point. It is left up to the delegate to decide how to
- // size the window. ass an empty point (0, 0) to allow the delegate to decide
- // where to position the window.
+ // be added to it. Its size and position are reflected in |window_bounds|.
virtual void CreateNewStripWithContents(TabContents* contents,
- const gfx::Point& creation_point) = 0;
+ const gfx::Rect& window_bounds) = 0;
enum {
TAB_MOVE_ACTION = 1,
@@ -370,7 +367,7 @@ class TabStripModel : public NotificationObserver {
// The specified contents should be opened in a new tabstrip.
void TearOffTabContents(TabContents* detached_contents,
- const gfx::Point& drop_point);
+ const gfx::Rect& window_bounds);
// Context menu functions.
enum ContextMenuCommand {
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 1cb672c..8e5cff1 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -6,16 +6,26 @@
#include "chrome/browser/views/frame/browser_view.h"
+#include "base/file_version_info.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/app_modal_dialog_queue.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/encoding_menu_controller_delegate.h"
+#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/view_ids.h"
+#include "chrome/browser/views/about_chrome_view.h"
#include "chrome/browser/views/bookmark_bar_view.h"
+#include "chrome/browser/views/bookmark_manager_view.h"
+#include "chrome/browser/views/bug_report_view.h"
+#include "chrome/browser/views/clear_browsing_data.h"
#include "chrome/browser/views/download_shelf_view.h"
#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/html_dialog_view.h"
+#include "chrome/browser/views/importer_view.h"
+#include "chrome/browser/views/keyword_editor_view.h"
+#include "chrome/browser/views/password_manager_view.h"
#include "chrome/browser/views/status_bubble.h"
#include "chrome/browser/views/tab_contents_container_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
@@ -355,6 +365,10 @@ void BrowserView::Show() {
frame_->GetWindow()->Activate();
}
+void BrowserView::SetBounds(const gfx::Rect& bounds) {
+ frame_->GetWindow()->SetBounds(bounds);
+}
+
void BrowserView::Close() {
frame_->GetWindow()->Close();
}
@@ -478,6 +492,93 @@ bool BrowserView::IsBookmarkBarVisible() const {
return bookmark_bar_view_->GetPreferredSize().height() > 1;
}
+void BrowserView::ToggleBookmarkBar() {
+ BookmarkBarView::ToggleWhenVisible(browser_->profile());
+}
+
+void BrowserView::ShowAboutChromeDialog() {
+ views::Window::CreateChromeWindow(
+ GetContainer()->GetHWND(), gfx::Rect(),
+ new AboutChromeView(browser_->profile()))->Show();
+}
+
+void BrowserView::ShowBookmarkManager() {
+ BookmarkManagerView::Show(browser_->profile());
+}
+
+void BrowserView::ShowReportBugDialog() {
+ // Retrieve the URL for the current tab (if any) and tell the BugReportView
+ TabContents* current_tab = browser_->GetSelectedTabContents();
+ if (!current_tab)
+ return;
+
+ BugReportView* bug_report_view = new BugReportView(browser_->profile(),
+ current_tab);
+
+ if (current_tab->controller()->GetLastCommittedEntry()) {
+ if (current_tab->type() == TAB_CONTENTS_WEB) {
+ // URL for the current page
+ bug_report_view->SetUrl(
+ current_tab->controller()->GetActiveEntry()->url());
+ }
+ }
+
+ // retrieve the application version info
+ std::wstring version;
+ scoped_ptr<FileVersionInfo> version_info(
+ FileVersionInfo::CreateFileVersionInfoForCurrentModule());
+ if (version_info.get()) {
+ version = version_info->product_name() + L" - " +
+ version_info->file_version() +
+ L" (" + version_info->last_change() + L")";
+ }
+ bug_report_view->set_version(version);
+
+ // Grab an exact snapshot of the window that the user is seeing (i.e. as
+ // rendered--do not re-render, and include windowed plugins)
+ std::vector<unsigned char> *screenshot_png = new std::vector<unsigned char>;
+ win_util::GrabWindowSnapshot(GetContainer()->GetHWND(), screenshot_png);
+ // the BugReportView takes ownership of the png data, and will dispose of
+ // it in its destructor.
+ bug_report_view->set_png_data(screenshot_png);
+
+ // Create and show the dialog
+ views::Window::CreateChromeWindow(GetContainer()->GetHWND(), gfx::Rect(),
+ bug_report_view)->Show();
+}
+
+void BrowserView::ShowClearBrowsingDataDialog() {
+ views::Window::CreateChromeWindow(
+ GetContainer()->GetHWND(), gfx::Rect(),
+ new ClearBrowsingDataView(browser_->profile()))->Show();
+}
+
+void BrowserView::ShowImportDialog() {
+ views::Window::CreateChromeWindow(
+ GetContainer()->GetHWND(), gfx::Rect(),
+ new ImporterView(browser_->profile()))->Show();
+}
+
+void BrowserView::ShowSearchEnginesDialog() {
+ KeywordEditorView::Show(browser_->profile());
+}
+
+void BrowserView::ShowPasswordManager() {
+ PasswordManagerView::Show(browser_->profile());
+}
+
+void BrowserView::ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
+ void* parent_window) {
+ HWND parent_hwnd = reinterpret_cast<HWND>(parent_window);
+ parent_hwnd = parent_hwnd ? parent_hwnd : GetContainer()->GetHWND();
+ HtmlDialogView* html_view = new HtmlDialogView(browser_.get(),
+ browser_->profile(),
+ delegate);
+ views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view);
+ html_view->InitDialog();
+ html_view->window()->Show();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, NotificationObserver implementation:
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 549cbd6..fde7d12 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -142,6 +142,7 @@ class BrowserView : public BrowserWindow,
// Overridden from BrowserWindow:
virtual void Init();
virtual void Show();
+ virtual void SetBounds(const gfx::Rect& bounds);
virtual void Close();
virtual void Activate();
virtual void FlashFrame();
@@ -162,6 +163,16 @@ class BrowserView : public BrowserWindow,
virtual void FocusToolbar();
virtual void DestroyBrowser();
virtual bool IsBookmarkBarVisible() const;
+ virtual void ToggleBookmarkBar();
+ virtual void ShowAboutChromeDialog();
+ virtual void ShowBookmarkManager();
+ virtual void ShowReportBugDialog();
+ virtual void ShowClearBrowsingDataDialog();
+ virtual void ShowImportDialog();
+ virtual void ShowSearchEnginesDialog();
+ virtual void ShowPasswordManager();
+ virtual void ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
+ void* parent_window);
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc
index 3d9e93f..87d3001 100644
--- a/chrome/browser/views/importer_view.cc
+++ b/chrome/browser/views/importer_view.cc
@@ -125,7 +125,9 @@ bool ImporterView::Accept() {
Browser* browser = BrowserList::GetLastActive();
int selected_index = profile_combobox_->GetSelectedItem();
- StartImportingWithUI(browser->GetTopLevelHWND(), items, importer_host_.get(),
+ HWND parent_hwnd =
+ reinterpret_cast<HWND>(browser->window()->GetNativeHandle());
+ StartImportingWithUI(parent_hwnd, items, importer_host_.get(),
importer_host_->GetSourceProfileInfoAt(selected_index),
profile_, this, false);
// We return false here to prevent the window from being closed. We will be
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 58c25127..0bca5f1 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -748,9 +748,13 @@ bool DraggedTabController::CompleteDrag() {
destroy_immediately = false;
} else {
// Compel the model to construct a new window for the detached TabContents.
- source_tabstrip_->model()->TearOffTabContents(
- dragged_contents_,
- GetWindowCreatePoint());
+ CRect browser_rect;
+ GetWindowRect(source_tabstrip_->GetContainer()->GetHWND(), &browser_rect);
+ gfx::Rect window_bounds(
+ GetWindowCreatePoint(),
+ gfx::Size(browser_rect.Width(), browser_rect.Height()));
+ source_tabstrip_->model()->TearOffTabContents(dragged_contents_,
+ window_bounds);
CleanUpHiddenFrame();
}
diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc
index fe72283..9a485ee 100644
--- a/chrome/browser/views/toolbar_star_toggle.cc
+++ b/chrome/browser/views/toolbar_star_toggle.cc
@@ -46,8 +46,10 @@ void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
// of the star.
gfx::Rect star_bounds(star_location.x() + 1, star_location.y(), width(),
height());
- BookmarkBubbleView::Show(host_->browser()->GetTopLevelHWND(), star_bounds,
- this, host_->profile(), url, newly_bookmarked);
+ HWND parent_hwnd =
+ reinterpret_cast<HWND>(host_->browser()->window()->GetNativeHandle());
+ BookmarkBubbleView::Show(parent_hwnd, star_bounds, this, host_->profile(),
+ url, newly_bookmarked);
is_bubble_showing_ = true;
}
diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc
index 3ba7173..dcf8136 100644
--- a/chrome/browser/web_contents_view_win.cc
+++ b/chrome/browser/web_contents_view_win.cc
@@ -234,7 +234,7 @@ void WebContentsViewWin::FindInPage(const Browser& browser,
bool find_next, bool forward_direction) {
if (!find_bar_.get()) {
// We want the Chrome top-level (Frame) window.
- HWND hwnd = browser.GetTopLevelHWND();
+ HWND hwnd = reinterpret_cast<HWND>(browser.window()->GetNativeHandle());
find_bar_.reset(new FindBarWin(this, hwnd));
} else if (!find_bar_->IsVisible()) {
find_bar_->Show();
@@ -254,8 +254,10 @@ void WebContentsViewWin::HideFindBar(bool end_session) {
}
void WebContentsViewWin::ReparentFindWindow(Browser* new_browser) const {
- if (find_bar_.get())
- find_bar_->SetParent(new_browser->GetTopLevelHWND());
+ if (find_bar_.get()) {
+ find_bar_->SetParent(
+ reinterpret_cast<HWND>(new_browser->window()->GetNativeHandle()));
+ }
}
bool WebContentsViewWin::GetFindBarWindowInfo(gfx::Point* position,