summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 00:54:36 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 00:54:36 +0000
commit99edc98ac36d8efa403eb9b0a194d021cc22c192 (patch)
tree7d55aaaf9c93aef6f5c9d9a30cadba9315d100cf /chrome
parent10dd7531c0eace81434783ddb9b7c224dbe0e9f9 (diff)
downloadchromium_src-99edc98ac36d8efa403eb9b0a194d021cc22c192.zip
chromium_src-99edc98ac36d8efa403eb9b0a194d021cc22c192.tar.gz
chromium_src-99edc98ac36d8efa403eb9b0a194d021cc22c192.tar.bz2
[Mac] Find page-action bubble point from location bar.
Push the AutocompleteTextFieldCell knowledge into LocationBarViewMac. BUG=none TEST=none Review URL: http://codereview.chromium.org/2806031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.mm17
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h3
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm9
3 files changed, 15 insertions, 14 deletions
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
index 15f1e72..2074b8e 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
@@ -9,7 +9,6 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/extensions/browser_actions_controller.h"
@@ -151,7 +150,6 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
locationBarView->SetPreviewEnabledPageAction(extension_->page_action(),
false); // disables preview.
- [locationBarView->GetAutocompleteTextField() setNeedsDisplay:YES];
}
// The extension installed bubble points at the browser action icon or the
@@ -185,18 +183,9 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
true);
// Find the center of the bottom of the page action icon.
- AutocompleteTextField* field =
- locationBarView->GetAutocompleteTextField();
- size_t index =
- locationBarView->GetPageActionIndex(extension_->page_action());
- NSRect iconRect = [[field autocompleteTextFieldCell]
- pageActionFrameForIndex:index inFrame:[field bounds]];
- NSRect boundsrect = [[field superview] convertRect:iconRect
- toView:nil];
- NSRect fieldFrame = [field bounds];
- fieldFrame = [field convertRect:fieldFrame toView:nil];
- arrowPoint = NSMakePoint(fieldFrame.origin.x + NSMidX(boundsrect),
- NSMinY(boundsrect));
+ const NSRect frame =
+ locationBarView->GetPageActionFrame(extension_->page_action());
+ arrowPoint = NSMakePoint(NSMidX(frame), NSMinY(frame));
break;
}
default: {
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index aa32c0a..f7d77fe 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -104,6 +104,9 @@ class LocationBarViewMac : public AutocompleteEditController,
void SetPreviewEnabledPageAction(ExtensionAction* page_action,
bool preview_enabled);
+ // Return |page_action|'s frame in window coordinates.
+ NSRect GetPageActionFrame(ExtensionAction* page_action);
+
// Return the index of a given page_action.
size_t GetPageActionIndex(ExtensionAction* page_action);
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index bd8fc2f..2053046 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -350,6 +350,7 @@ void LocationBarViewMac::SetPreviewEnabledPageAction(
if (!contents)
return;
page_action_views_.RefreshViews();
+ [field_ setNeedsDisplay:YES];
LocationBarViewMac::PageActionImageView* page_action_image_view =
GetPageActionImageView(page_action);
@@ -362,6 +363,14 @@ void LocationBarViewMac::SetPreviewEnabledPageAction(
GURL(WideToUTF8(toolbar_model_->GetText())));
}
+NSRect LocationBarViewMac::GetPageActionFrame(ExtensionAction* page_action) {
+ const size_t index = GetPageActionIndex(page_action);
+ AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
+ const NSRect iconRect =
+ [cell pageActionFrameForIndex:index inFrame:[field_ bounds]];
+ return [field_ convertRect:iconRect toView:nil];
+}
+
size_t LocationBarViewMac::GetPageActionIndex(ExtensionAction* page_action) {
DCHECK(page_action);
for (size_t i = 0; i < page_action_views_.Count(); ++i) {