summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 03:39:30 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 03:39:30 +0000
commit90791cb7bac6fd9ddfaf933bad3f9b5e13625db5 (patch)
tree9f026e4f71243a2e9b0f2a365ee66763560a2511
parent56141dede4a2c075baa968e24861ce6a3954f194 (diff)
downloadchromium_src-90791cb7bac6fd9ddfaf933bad3f9b5e13625db5.zip
chromium_src-90791cb7bac6fd9ddfaf933bad3f9b5e13625db5.tar.gz
chromium_src-90791cb7bac6fd9ddfaf933bad3f9b5e13625db5.tar.bz2
Revert change 8693 because it breaks the unit_tests.
TBR Review URL: http://codereview.chromium.org/19009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8704 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/browser.cc38
-rw-r--r--chrome/browser/browser.h3
-rw-r--r--chrome/browser/browser.vcproj4
-rw-r--r--chrome/browser/browser_window.h18
-rw-r--r--chrome/browser/browser_window_cocoa.h3
-rw-r--r--chrome/browser/browser_window_cocoa.mm6
-rw-r--r--chrome/browser/location_bar.h44
-rw-r--r--chrome/browser/views/frame/browser_view.cc16
-rw-r--r--chrome/browser/views/frame/browser_view.h4
-rw-r--r--chrome/browser/views/location_bar_view.cc46
-rw-r--r--chrome/browser/views/location_bar_view.h33
-rw-r--r--chrome/test/test_browser_window.h3
13 files changed, 83 insertions, 139 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index fe947c5..f4bccc7 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1948,9 +1948,7 @@ void AutomationProvider::GetAutocompleteEditForBrowser(
if (browser_tracker_->ContainsHandle(browser_handle)) {
Browser* browser = browser_tracker_->GetResource(browser_handle);
- BrowserWindowTesting* testing_interface =
- browser->window()->GetBrowserWindowTesting();
- LocationBarView* loc_bar_view = testing_interface->GetLocationBarView();
+ LocationBarView* loc_bar_view = browser->GetLocationBarView();
AutocompleteEditView* edit_view = loc_bar_view->location_entry();
// Add() returns the existing handle for the resource if any.
autocomplete_edit_handle = autocomplete_edit_tracker_->Add(edit_view);
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 8411642..69fddec 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -8,7 +8,6 @@
#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_list.h"
-#include "chrome/browser/location_bar.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/tab_contents/tab_contents_type.h"
#include "chrome/common/chrome_constants.h"
@@ -276,7 +275,7 @@ void Browser::CreateBrowserWindow() {
local_state->GetBoolean(prefs::kShouldShowFirstRunBubble)) {
// Reset the preference so we don't show the bubble for subsequent windows.
local_state->ClearPref(prefs::kShouldShowFirstRunBubble);
- window_->GetLocationBar()->ShowFirstRunBubble();
+ GetLocationBarView()->ShowFirstRunBubble();
}
}
@@ -622,15 +621,18 @@ void Browser::Home() {
#if defined(OS_WIN)
void Browser::OpenCurrentURL() {
UserMetrics::RecordAction(L"LoadURL", profile_);
- LocationBar* location_bar = window_->GetLocationBar();
- OpenURL(GURL(location_bar->GetInputString()), GURL(),
- location_bar->GetWindowOpenDisposition(),
- location_bar->GetPageTransition());
+ LocationBarView* lbv = GetLocationBarView();
+ if (lbv) {
+ OpenURL(GURL(lbv->location_input()), GURL(), lbv->disposition(),
+ lbv->transition());
+ }
}
void Browser::Go() {
UserMetrics::RecordAction(L"Go", profile_);
- window_->GetLocationBar()->AcceptInput();
+ LocationBarView* lbv = GetLocationBarView();
+ if (lbv)
+ lbv->location_entry()->model()->AcceptInput(CURRENT_TAB, false);
}
#endif
@@ -893,13 +895,23 @@ void Browser::FocusToolbar() {
void Browser::FocusLocationBar() {
UserMetrics::RecordAction(L"FocusLocation", profile_);
- window_->GetLocationBar()->FocusLocation();
+ LocationBarView* lbv = GetLocationBarView();
+ if (lbv) {
+ AutocompleteEditView* aev = lbv->location_entry();
+ aev->SetFocus();
+ aev->SelectAll(true);
+ }
}
void Browser::FocusSearch() {
// TODO(beng): replace this with FocusLocationBar
UserMetrics::RecordAction(L"FocusSearch", profile_);
- window_->GetLocationBar()->FocusSearch();
+ LocationBarView* lbv = GetLocationBarView();
+ if (lbv) {
+ AutocompleteEditView* aev = lbv->location_entry();
+ aev->SetUserText(L"?");
+ aev->SetFocus();
+ }
}
void Browser::OpenFile() {
@@ -1458,10 +1470,12 @@ void Browser::TabSelectedAt(TabContents* old_contents,
if (!chrome_updater_factory_.empty() && old_contents)
ProcessPendingUIUpdates();
+ LocationBarView* location_bar = GetLocationBarView();
if (old_contents) {
// Save what the user's currently typing, so it can be restored when we
// switch back to this tab.
- window_->GetLocationBar()->SaveStateToContents(old_contents);
+ if (location_bar)
+ location_bar->location_entry()->SaveStateToTab(old_contents);
}
// Propagate the profile to the location bar.
@@ -2255,6 +2269,10 @@ void Browser::RemoveScheduledUpdatesFor(TabContents* contents) {
///////////////////////////////////////////////////////////////////////////////
// Browser, Getters for UI (private):
+LocationBarView* Browser::GetLocationBarView() const {
+ return window_->GetLocationBarView();
+}
+
StatusBubble* Browser::GetStatusBubble() {
return window_->GetStatusBubble();
}
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 9668a4d..1e1875b 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -35,7 +35,7 @@ class BrowserIdleTimer;
class BrowserWindow;
class DebuggerWindow;
class GoButton;
-class LocationBar;
+class LocationBarView;
class PrefService;
class Profile;
class StatusBubble;
@@ -458,6 +458,7 @@ class Browser : public TabStripModelDelegate,
// Getters for the location bar and go button.
#endif // OS_WIN
+ LocationBarView* GetLocationBarView() const;
GoButton* GetGoButton();
// Returns the StatusBubble from the current toolbar. It is possible for
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index 32f9051..c1cbed3 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -734,10 +734,6 @@
>
</File>
<File
- RelativePath=".\location_bar.h"
- >
- </File>
- <File
RelativePath=".\login_prompt.cc"
>
</File>
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 408f4ff..38f32b4 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -5,11 +5,13 @@
#ifndef CHROME_BROWSER_BROWSER_WINDOW_H_
#define CHROME_BROWSER_BROWSER_WINDOW_H_
+class BookmarkBarView;
class Browser;
class BrowserList;
+class BrowserView;
class BrowserWindowTesting;
class GURL;
-class LocationBar;
+class LocationBarView;
class HtmlDialogContentsDelegate;
class Profile;
class StatusBubble;
@@ -23,7 +25,7 @@ class Rect;
// BrowserWindow interface
// An interface implemented by the "view" of the Browser window.
//
-// NOTE: All getters except GetTabStrip() may return NULL.
+// NOTE: all getters, save GetTabStrip(), may return NULL.
class BrowserWindow {
public:
// Initialize the frame.
@@ -87,7 +89,7 @@ class BrowserWindow {
virtual bool IsMaximized() = 0;
// Returns the location bar.
- virtual LocationBar* GetLocationBar() const = 0;
+ virtual LocationBarView* GetLocationBarView() const = 0;
// Informs the view whether or not a load is in progress for the current tab.
// The view can use this notification to update the go/stop button.
@@ -155,19 +157,13 @@ class BrowserWindow {
virtual void DestroyBrowser() = 0;
};
-class BookmarkBarView;
-class LocationBarView;
-
// A BrowserWindow utility interface used for accessing elements of the browser
// UI used only by UI test automation.
class BrowserWindowTesting {
- public:
+public:
#if defined(OS_WIN)
- // Returns the BookmarkBarView.
+ // Returns the Bookmark Bar view.
virtual BookmarkBarView* GetBookmarkBarView() = 0;
-
- // Returns the LocationBarView.
- virtual LocationBarView* GetLocationBarView() const = 0;
#endif
};
diff --git a/chrome/browser/browser_window_cocoa.h b/chrome/browser/browser_window_cocoa.h
index fa7e707..88d9fed 100644
--- a/chrome/browser/browser_window_cocoa.h
+++ b/chrome/browser/browser_window_cocoa.h
@@ -35,7 +35,8 @@ class BrowserWindowCocoa : public BrowserWindow {
virtual void SetStarredState(bool is_starred);
virtual gfx::Rect GetNormalBounds() const;
virtual bool IsMaximized();
- virtual LocationBar* GetLocationBar() const;
+ virtual LocationBarView* GetLocationBarView() const;
+ virtual BookmarkBarView* GetBookmarkBarView();
virtual void UpdateStopGoState(bool is_loading);
virtual void UpdateToolbar(TabContents* contents,
bool should_restore_state);
diff --git a/chrome/browser/browser_window_cocoa.mm b/chrome/browser/browser_window_cocoa.mm
index d178f02..095600f 100644
--- a/chrome/browser/browser_window_cocoa.mm
+++ b/chrome/browser/browser_window_cocoa.mm
@@ -81,7 +81,11 @@ bool BrowserWindowCocoa::IsMaximized() {
return [window_ isZoomed];
}
-LocationBar* BrowserWindowCocoa::GetLocationBar() const {
+LocationBarView* BrowserWindowCocoa::GetLocationBarView() const {
+ return NULL;
+}
+
+BookmarkBarView* BrowserWindowCocoa::GetBookmarkBarView() {
return NULL;
}
diff --git a/chrome/browser/location_bar.h b/chrome/browser/location_bar.h
deleted file mode 100644
index 0e6bc83..0000000
--- a/chrome/browser/location_bar.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2009 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_LOCATION_BAR_H_
-#define CHROME_BROWSER_LOCATION_BAR_H_
-
-////////////////////////////////////////////////////////////////////////////////
-// LocationBar
-// An interface providing access to the Location Bar component of the browser
-// window.
-//
-class LocationBar {
- public:
- // Shows the first run information bubble anchored to the location bar.
- virtual void ShowFirstRunBubble() = 0;
-
- // Returns the string of text entered in the location bar.
- virtual std::wstring GetInputString() const = 0;
-
- // Returns the WindowOpenDisposition that should be used to determine where to
- // open a URL entered in the location bar.
- virtual WindowOpenDisposition GetWindowOpenDisposition() const = 0;
-
- // Returns the PageTransition that should be recorded in history when the URL
- // entered in the location bar is loaded.
- virtual PageTransition::Type GetPageTransition() const = 0;
-
- // Accepts the current string of text entered in the location bar.
- virtual void AcceptInput() = 0;
-
- // Focuses and selects the contents of the location bar.
- virtual void FocusLocation() = 0;
-
- // Clears the location bar, inserts an annoying little "?" turd and sets focus
- // to it.
- virtual void FocusSearch() = 0;
-
- // Saves the state of the location bar to the specified TabContents, so that
- // it can be restored later. (Done when switching tabs).
- virtual void SaveStateToContents(TabContents* contents) = 0;
-};
-
-#endif // #ifndef CHROME_BROWSER_LOCATION_BAR_H_
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 2316558..b3229c9 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -171,8 +171,8 @@ void BrowserView::WindowMoved() {
status_bubble_->Reposition();
// Close the omnibox popup, if any.
- if (toolbar_->GetLocationBarView())
- toolbar_->GetLocationBarView()->location_entry()->ClosePopup();
+ if (GetLocationBarView())
+ GetLocationBarView()->location_entry()->ClosePopup();
}
gfx::Rect BrowserView::GetToolbarBounds() const {
@@ -480,10 +480,14 @@ bool BrowserView::IsMaximized() {
return frame_->GetWindow()->IsMaximized();
}
-LocationBar* BrowserView::GetLocationBar() const {
+LocationBarView* BrowserView::GetLocationBarView() const {
return toolbar_->GetLocationBarView();
}
+BrowserView* BrowserView::GetBrowserView() const {
+ return NULL;
+}
+
void BrowserView::UpdateStopGoState(bool is_loading) {
toolbar_->GetGoButton()->ChangeMode(
is_loading ? GoButton::MODE_STOP : GoButton::MODE_GO);
@@ -639,10 +643,6 @@ BookmarkBarView* BrowserView::GetBookmarkBarView() {
return bookmark_bar_view_.get();
}
-LocationBarView* BrowserView::GetLocationBarView() const {
- return toolbar_->GetLocationBarView();
-}
-
///////////////////////////////////////////////////////////////////////////////
// BrowserView, NotificationObserver implementation:
@@ -734,7 +734,7 @@ std::wstring BrowserView::GetWindowTitle() const {
}
views::View* BrowserView::GetInitiallyFocusedView() const {
- return toolbar_->GetLocationBarView();
+ return GetLocationBarView();
}
bool BrowserView::ShouldShowWindowTitle() const {
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index cfe5be4..39c2532 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -162,7 +162,8 @@ class BrowserView : public BrowserWindow,
virtual void SetStarredState(bool is_starred);
virtual gfx::Rect GetNormalBounds() const;
virtual bool IsMaximized();
- virtual LocationBar* GetLocationBar() const;
+ virtual LocationBarView* GetLocationBarView() const;
+ virtual BrowserView* GetBrowserView() const;
virtual void UpdateStopGoState(bool is_loading);
virtual void UpdateToolbar(TabContents* contents, bool should_restore_state);
virtual void FocusToolbar();
@@ -185,7 +186,6 @@ class BrowserView : public BrowserWindow,
// Overridden from BrowserWindowTesting:
virtual BookmarkBarView* GetBookmarkBarView();
- virtual LocationBarView* GetLocationBarView() const;
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 0ee51ea..aa6fb1d 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -876,6 +876,13 @@ void LocationBarView::ShowFirstRunBubbleInternal() {
bounds);
}
+void LocationBarView::ShowFirstRunBubble() {
+ // We wait 30 milliseconds to open. It allows less flicker.
+ Task* task = first_run_bubble_.NewRunnableMethod(
+ &LocationBarView::ShowFirstRunBubbleInternal);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30);
+}
+
// SecurityImageView------------------------------------------------------------
// static
@@ -998,42 +1005,3 @@ bool LocationBarView::OverrideAccelerator(
return location_entry_->OverrideAccelerator(accelerator);
}
-////////////////////////////////////////////////////////////////////////////////
-// LocationBarView, LocationBar implementation:
-
-void LocationBarView::ShowFirstRunBubble() {
- // We wait 30 milliseconds to open. It allows less flicker.
- Task* task = first_run_bubble_.NewRunnableMethod(
- &LocationBarView::ShowFirstRunBubbleInternal);
- MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30);
-}
-
-std::wstring LocationBarView::GetInputString() const {
- return location_input_;
-}
-
-WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const {
- return disposition_;
-}
-
-PageTransition::Type LocationBarView::GetPageTransition() const {
- return transition_;
-}
-
-void LocationBarView::AcceptInput() {
- location_entry_->model()->AcceptInput(CURRENT_TAB, false);
-}
-
-void LocationBarView::FocusLocation() {
- location_entry_->SetFocus();
- location_entry_->SelectAll(true);
-}
-
-void LocationBarView::FocusSearch() {
- location_entry_->SetUserText(L"?");
- location_entry_->SetFocus();
-}
-
-void LocationBarView::SaveStateToContents(TabContents* contents) {
- location_entry_->SaveStateToTab(contents);
-}
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index ec01c63..eb3b4ef 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -9,7 +9,6 @@
#include "base/gfx/rect.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
-#include "chrome/browser/location_bar.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/browser/views/info_bubble.h"
@@ -31,10 +30,10 @@ class Profile;
// of the URL bar strip and contains its content.
//
/////////////////////////////////////////////////////////////////////////////
-class LocationBarView : public LocationBar,
- public views::View,
+class LocationBarView : public views::View,
public AutocompleteEditController {
public:
+
class Delegate {
public:
// Should return the current tab contents.
@@ -108,18 +107,24 @@ class LocationBarView : public LocationBar,
return location_entry_.get();
}
- // Overridden from views::View:
- virtual bool OverrideAccelerator(const views::Accelerator& accelerator);
+ std::wstring location_input() {
+ return location_input_;
+ }
+
+ WindowOpenDisposition disposition() {
+ return disposition_;
+ }
- // Overridden from LocationBar:
- virtual void ShowFirstRunBubble();
- virtual std::wstring GetInputString() const;
- virtual WindowOpenDisposition GetWindowOpenDisposition() const;
- virtual PageTransition::Type GetPageTransition() const;
- virtual void AcceptInput();
- virtual void FocusLocation();
- virtual void FocusSearch();
- virtual void SaveStateToContents(TabContents* contents);
+ PageTransition::Type transition() {
+ return transition_;
+ }
+
+ // Shows a info bubble that tells the user what the omnibox is and allows
+ // to change the search providers.
+ void ShowFirstRunBubble();
+
+ // Overridden from View.
+ virtual bool OverrideAccelerator(const views::Accelerator& accelerator);
static const int kTextVertMargin;
static const COLORREF kBackgroundColorByLevel[];
diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h
index 5d8a0c7..29ab2bc 100644
--- a/chrome/test/test_browser_window.h
+++ b/chrome/test/test_browser_window.h
@@ -34,7 +34,8 @@ class TestBrowserWindow : public BrowserWindow {
virtual void SetStarredState(bool is_starred) {}
virtual gfx::Rect GetNormalBounds() const { return gfx::Rect(); }
virtual bool IsMaximized() { return false; }
- virtual LocationBar* GetLocationBar() const { return NULL; }
+ virtual LocationBarView* GetLocationBarView() const { return NULL; }
+ virtual BookmarkBarView* GetBookmarkBarView() { return NULL; }
virtual void UpdateStopGoState(bool is_loading) {}
virtual void UpdateToolbar(TabContents* contents,
bool should_restore_state) {}