summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/Toolbar.xib78
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm72
2 files changed, 147 insertions, 3 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib
index 3308db3..c9937bc 100644
--- a/chrome/app/nibs/Toolbar.xib
+++ b/chrome/app/nibs/Toolbar.xib
@@ -2,13 +2,15 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9F33</string>
+ <string key="IBDocument.SystemVersion">9L30</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.34</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="48"/>
<integer value="1"/>
+ <integer value="42"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -664,6 +666,9 @@
<object class="NSCustomObject" id="1044322163">
<string key="NSClassName">ChromeUILocalizer</string>
</object>
+ <object class="NSUserDefaultsController" id="306232897">
+ <bool key="NSSharedInstance">YES</bool>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -1480,6 +1485,11 @@
<reference key="object" ref="306298564"/>
<reference key="parent" ref="558188039"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">130</int>
+ <reference key="object" ref="306232897"/>
+ <reference key="parent" ref="701738477"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1511,16 +1521,21 @@
<string>15.CustomClassName</string>
<string>15.IBPluginDependency</string>
<string>2.CustomClassName</string>
+ <string>2.IBAttributePlaceholdersKey</string>
<string>2.IBPluginDependency</string>
+ <string>3.IBAttributePlaceholdersKey</string>
<string>3.IBPluginDependency</string>
+ <string>32.IBAttributePlaceholdersKey</string>
<string>32.IBPluginDependency</string>
<string>33.CustomClassName</string>
<string>33.IBPluginDependency</string>
<string>36.CustomClassName</string>
+ <string>36.IBAttributePlaceholdersKey</string>
<string>36.IBPluginDependency</string>
<string>37.CustomClassName</string>
<string>37.IBPluginDependency</string>
<string>38.CustomClassName</string>
+ <string>38.IBAttributePlaceholdersKey</string>
<string>38.IBPluginDependency</string>
<string>39.CustomClassName</string>
<string>39.IBPluginDependency</string>
@@ -1559,8 +1574,10 @@
<string>68.IBPluginDependency</string>
<string>69.IBPluginDependency</string>
<string>7.CustomClassName</string>
+ <string>7.IBAttributePlaceholdersKey</string>
<string>7.IBPluginDependency</string>
<string>70.IBPluginDependency</string>
+ <string>8.IBAttributePlaceholdersKey</string>
<string>8.IBPluginDependency</string>
<string>82.IBPluginDependency</string>
<string>83.IBPluginDependency</string>
@@ -1600,16 +1617,57 @@
<string>ClickHoldButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>DelayedMenuButton</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="634265909"/>
+ <string key="toolTip">^IDS_TOOLTIP_BACK</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="458854861"/>
+ <string key="toolTip">^IDS_TOOLTIP_RELOAD</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>MenuButton</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="571076484"/>
+ <string key="toolTip">^IDS_PAGEMENU_TOOLTIP</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ClickHoldButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>MenuButton</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="602421009"/>
+ <string key="toolTip">^IDS_APPMENU_TOOLTIP</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ClickHoldButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1648,8 +1706,24 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>DelayedMenuButton</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="781044416"/>
+ <string key="toolTip">^IDS_TOOLTIP_FORWARD</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="368496192"/>
+ <string key="toolTip">^IDS_TOOLTIP_HOME</string>
+ </object>
+ </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1683,7 +1757,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">129</int>
+ <int key="maxID">133</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index 99f84e8..c7c0ad3 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -4,10 +4,12 @@
#import "chrome/browser/cocoa/toolbar_controller.h"
+#include "app/l10n_util_mac.h"
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#include "base/gfx/rect.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
#import "chrome/browser/cocoa/autocomplete_text_field.h"
#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
@@ -17,12 +19,14 @@
#import "chrome/browser/cocoa/menu_button.h"
#include "chrome/browser/cocoa/nsimage_cache.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "grit/generated_resources.h"
// Name of image in the bundle for the yellow of the star icon.
static NSString* const kStarredImageName = @"starred.pdf";
@@ -187,6 +191,10 @@ class PrefObserverBridge : public NotificationObserver {
owner:self
userInfo:nil]);
[[self view] addTrackingArea:trackingArea_.get()];
+
+ // We want a dynamic tooltip on the go button, so tell the go button to ask
+ // use for the tooltip
+ [goButton_ addToolTipRect:[goButton_ bounds] owner:self userData:nil];
}
- (void)removeFromSuperview {
NSLog(@"remove");
@@ -289,10 +297,22 @@ class PrefObserverBridge : public NotificationObserver {
- (void)setStarredState:(BOOL)isStarred {
NSImage* starImage = nil;
- if (isStarred)
+ NSString* toolTip;
+ if (isStarred) {
starImage = nsimage_cache::ImageNamed(kStarredImageName);
+ // Cache the string since we'll need it a lot
+ static NSString* starredToolTip =
+ [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STARRED) retain];
+ toolTip = starredToolTip;
+ } else {
+ // Cache the string since we'll need it a lot
+ static NSString* starToolTip =
+ [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain];
+ toolTip = starToolTip;
+ }
[(GradientButtonCell*)[starButton_ cell] setUnderlayImage:starImage];
+ [starButton_ setToolTip:toolTip];
}
- (void)setIsLoading:(BOOL)isLoading {
@@ -444,6 +464,56 @@ class PrefObserverBridge : public NotificationObserver {
fromView:starButton_];
}
+- (NSString *)view:(NSView *)view
+ stringForToolTip:(NSToolTipTag)tag
+ point:(NSPoint)point
+ userData:(void *)userData {
+ DCHECK(view == goButton_);
+
+ // Following chrome/browser/views/go_button.cc: GoButton::GetTooltipText()
+
+ // Is it currently 'stop'?
+ if ([goButton_ tag] == IDC_STOP) {
+ return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STOP);
+ }
+
+ // It is 'go', so see what it would do...
+
+ // Fetch the EditView and EditModel
+ LocationBar* locationBar = [self locationBar];
+ DCHECK(locationBar);
+ AutocompleteEditView* editView = locationBar->location_entry();
+ DCHECK(editView);
+ AutocompleteEditModel* editModel = editView->model();
+ DCHECK(editModel);
+
+ std::wstring currentText(editView->GetText());
+ if (currentText.empty()) {
+ return nil;
+ }
+ string16 currentText16(WideToUTF16Hack(currentText));
+
+ // It is simply an url it is gonna go to, build the tip with the info.
+ if (editModel->CurrentTextIsURL()) {
+ return l10n_util::GetNSStringF(IDS_TOOLTIP_GO_SITE, currentText16);
+ }
+
+ // Build the tip based on what provide/template it will get.
+ std::wstring keyword(editModel->keyword());
+ TemplateURLModel* template_url_model =
+ editModel->profile()->GetTemplateURLModel();
+ const TemplateURL* provider =
+ (keyword.empty() || editModel->is_keyword_hint()) ?
+ template_url_model->GetDefaultSearchProvider() :
+ template_url_model->GetTemplateURLForKeyword(keyword);
+ if (!provider)
+ return nil;
+ std::wstring shortName(provider->AdjustedShortNameForLocaleDirection());
+ return l10n_util::GetNSStringF(IDS_TOOLTIP_GO_SEARCH,
+ WideToUTF16(shortName), currentText16);
+
+}
+
- (gfx::Rect)autocompletePopupPosition {
// The popup should span from the left edge of the star button to the right
// edge of the go button. The returned height is ignored.