summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authormelevin@chromium.org <melevin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 01:11:04 +0000
committermelevin@chromium.org <melevin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 01:11:04 +0000
commitec4aad544c94b17ad2a01537e5bbbec5cd4d13d4 (patch)
tree95bc5a69c4627ec014856268fbc077f56a3472d2 /chrome/browser/ui
parente34dc5abef02c60b672ba0fae814233682bbbd01 (diff)
downloadchromium_src-ec4aad544c94b17ad2a01537e5bbbec5cd4d13d4.zip
chromium_src-ec4aad544c94b17ad2a01537e5bbbec5cd4d13d4.tar.gz
chromium_src-ec4aad544c94b17ad2a01537e5bbbec5cd4d13d4.tar.bz2
Implement the Instant extended API startMargin, endMargin, and rtl properties and the onmarginchange event for Views only.
BUG=153403 Review URL: https://chromiumcodereview.appspot.com/11359198 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc4
-rw-r--r--chrome/browser/ui/browser_instant_controller.h3
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm2
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc8
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.h5
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc15
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h1
7 files changed, 31 insertions, 7 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index f5aee48..ba89cdf 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -171,6 +171,10 @@ void BrowserInstantController::OpenURLInCurrentTab(
false));
}
+void BrowserInstantController::SetMarginSize(int start, int end) {
+ instant_.SetMarginSize(start, end);
+}
+
void BrowserInstantController::ResetInstant() {
instant_.SetInstantEnabled(IsInstantEnabled(browser_->profile()));
}
diff --git a/chrome/browser/ui/browser_instant_controller.h b/chrome/browser/ui/browser_instant_controller.h
index e66ff5f..401cfbd 100644
--- a/chrome/browser/ui/browser_instant_controller.h
+++ b/chrome/browser/ui/browser_instant_controller.h
@@ -87,6 +87,9 @@ class BrowserInstantController : public content::NotificationObserver,
// Invoked by the InstantController when it wants to open a URL.
void OpenURLInCurrentTab(const GURL& url, content::PageTransition transition);
+ // Sets the start and end margins of the omnibox text area.
+ void SetMarginSize(int start, int end);
+
private:
// Sets the value of |instant_| based on value from profile. Invoked
// on pref change.
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 40c571e..3f7e7b9 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -930,7 +930,7 @@ void OmniboxViewMac::OnFrameChanged() {
// things even cheaper by refactoring between the popup-placement
// code and the matrix-population code.
popup_view_->UpdatePopupAppearance();
- model()->PopupBoundsChangedTo(popup_view_->GetTargetBounds());
+ model()->OnPopupBoundsChanged(popup_view_->GetTargetBounds());
// Give controller a chance to rearrange decorations.
model()->OnChanged();
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 507cf65..b1e489d 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -1027,10 +1027,10 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
MaybeAcceptKeywordBySpace(user_text_));
}
-void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) {
+void OmniboxEditModel::OnPopupBoundsChanged(const gfx::Rect& bounds) {
InstantController* instant = controller_->GetInstant();
if (instant)
- instant->SetOmniboxBounds(bounds);
+ instant->SetPopupBounds(bounds);
}
void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
@@ -1067,14 +1067,14 @@ void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
}
if (popup_->IsOpen()) {
- PopupBoundsChangedTo(popup_->view()->GetTargetBounds());
+ OnPopupBoundsChanged(popup_->view()->GetTargetBounds());
} else if (was_open) {
// Accepts the temporary text as the user text, because it makes little
// sense to have temporary text when the popup is closed.
InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
has_temporary_text_ = false;
is_temporary_text_set_by_instant_ = false;
- PopupBoundsChangedTo(gfx::Rect());
+ OnPopupBoundsChanged(gfx::Rect());
NotifySearchTabHelper();
}
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.h b/chrome/browser/ui/omnibox/omnibox_edit_model.h
index 7952ef7..7524dc7 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.h
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.h
@@ -318,8 +318,9 @@ class OmniboxEditModel : public AutocompleteControllerDelegate {
bool just_deleted_text,
bool allow_keyword_ui_change);
- // Invoked when the popup is going to change its bounds to |bounds|.
- void PopupBoundsChangedTo(const gfx::Rect& bounds);
+ // Invoked when the popup has changed its bounds to |bounds|. |bounds| here
+ // is in screen coordinates.
+ void OnPopupBoundsChanged(const gfx::Rect& bounds);
private:
enum PasteState {
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 860c75b..9714e3c 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -8,6 +8,7 @@
#include <map>
#include "base/command_line.h"
+#include "base/i18n/rtl.h"
#include "base/stl_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
@@ -26,6 +27,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_instant_controller.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
@@ -1368,6 +1370,19 @@ bool LocationBarView::HasFocus() const {
return location_entry_->model()->has_focus();
}
+void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
+ if (browser_ && browser_->instant_controller() && parent()) {
+ // Pass the side margins of the location bar to the Instant Controller.
+ const gfx::Rect bounds = GetBoundsInScreen();
+ const gfx::Rect parent_bounds = parent()->GetBoundsInScreen();
+ int start = bounds.x() - parent_bounds.x();
+ int end = parent_bounds.right() - bounds.right();
+ if (base::i18n::IsRTL())
+ std::swap(start, end);
+ browser_->instant_controller()->SetMarginSize(start, end);
+ }
+}
+
void LocationBarView::WriteDragDataForView(views::View* sender,
const gfx::Point& press_pt,
OSExchangeData* data) {
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h
index a42bbd0..abccf47 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -271,6 +271,7 @@ class LocationBarView : public LocationBar,
const ui::KeyEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual bool HasFocus() const OVERRIDE;
+ virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
// Overridden from views::DragController:
virtual void WriteDragDataForView(View* sender,