diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-09 04:56:48 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-09 04:56:48 +0000 |
commit | 3259aa9cdf3e25c815b7e74da1e836920a544318 (patch) | |
tree | d61b160f1813ad6e371ca0891dfa23d79b70238b /chrome/default_plugin | |
parent | cafded64bab3482f0844b4170ec87e402a2971d8 (diff) | |
download | chromium_src-3259aa9cdf3e25c815b7e74da1e836920a544318.zip chromium_src-3259aa9cdf3e25c815b7e74da1e836920a544318.tar.gz chromium_src-3259aa9cdf3e25c815b7e74da1e836920a544318.tar.bz2 |
Mac: Make default plugin appearance match windows.
Still no plugin download functionality.
This adds a dependency from default_plugin to app. Since webkit_glue no longer depends on default_plugin, that's ok.
BUG=17392
TEST=Go to e.g. http://www.santacruzsurfschool.com/ . The missing plugin view on the right should now look like it does on windows (yellow background, centered plugin icon, localized text below it – http://img43.imageshack.us/img43/6254/missingplugin.gif ).
Review URL: http://codereview.chromium.org/2843027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/default_plugin')
-rw-r--r-- | chrome/default_plugin/default_plugin.gyp | 43 | ||||
-rw-r--r-- | chrome/default_plugin/default_plugin_resources.grd | 16 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_mac.h | 12 | ||||
-rw-r--r-- | chrome/default_plugin/plugin_impl_mac.mm | 70 |
4 files changed, 116 insertions, 25 deletions
diff --git a/chrome/default_plugin/default_plugin.gyp b/chrome/default_plugin/default_plugin.gyp index b2852bf..a0d8a6d 100644 --- a/chrome/default_plugin/default_plugin.gyp +++ b/chrome/default_plugin/default_plugin.gyp @@ -5,12 +5,16 @@ { 'variables': { 'chromium_code': 1, + 'grit_info_cmd': ['python', '../../tools/grit/grit_info.py',], + 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', + 'grit_cmd': ['python', '../../tools/grit/grit.py'], }, 'targets': [ { 'target_name': 'default_plugin', 'type': '<(library)', 'dependencies': [ + ':default_plugin_resources', '<(DEPTH)/net/net.gyp:net_resources', '<(DEPTH)/third_party/icu/icu.gyp:icui18n', '<(DEPTH)/third_party/icu/icu.gyp:icuuc', @@ -56,6 +60,45 @@ }], ], }, + # This can't be part of chrome.gyp:chrome_resources because then there'd + # be a cyclic dependency. + { + 'target_name': 'default_plugin_resources', + 'type': 'none', + 'actions': [ + { + 'action_name': 'default_plugin_resources', + 'variables': { + 'input_path': 'default_plugin_resources.grd', + }, + 'inputs': [ + '<!@(<(grit_info_cmd) --inputs <(input_path))', + ], + 'outputs': [ + '<!@(<(grit_info_cmd) --outputs \'<(grit_out_dir)/default_plugin_resources\' <(input_path))', + ], + 'action': ['<@(grit_cmd)', + '-i', '<(input_path)', 'build', + '-o', '<(grit_out_dir)/default_plugin_resources'], + 'conditions': [ + ['toolkit_views==1', { + 'action': ['-D', 'toolkit_views'], + }], + ], + 'message': 'Generating resources from <(input_path)', + }, + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(grit_out_dir)/default_plugin_resources', + ], + }, + 'conditions': [ + ['OS=="win"', { + 'dependencies': ['../../build/win/system.gyp:cygwin'], + }], + ], + }, ], } diff --git a/chrome/default_plugin/default_plugin_resources.grd b/chrome/default_plugin/default_plugin_resources.grd new file mode 100644 index 0000000..f959220 --- /dev/null +++ b/chrome/default_plugin/default_plugin_resources.grd @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<grit latest_public_release="0" current_release="1"> + <outputs> + <output filename="grit/default_plugin_resources.h" type="rc_header"> + <emit emit_type='prepend'></emit> + </output> + <output filename="default_plugin_resources.pak" type="data_package" /> + <output filename="default_plugin_resources.rc" type="rc_all" /> + </outputs> + <release seq="1"> + <includes> + <!-- Medium-term, all the default plugin strings should be moved here. --> + <include name="IDR_PLUGIN_ICON" file="plugin_icon.png" type="BINDATA" /> + </includes> + </release> +</grit> diff --git a/chrome/default_plugin/plugin_impl_mac.h b/chrome/default_plugin/plugin_impl_mac.h index 9e3b7fc..f2d10a8 100644 --- a/chrome/default_plugin/plugin_impl_mac.h +++ b/chrome/default_plugin/plugin_impl_mac.h @@ -11,6 +11,14 @@ #include "gfx/native_widget_types.h" #include "third_party/npapi/bindings/npapi.h" +#ifdef __OBJ__ +@class NSImage; +@class NSString; +#else +class NSImage; +class NSString; +#endif + // Possible plugin installer states. enum PluginInstallerState { PluginInstallerStateUndefined, @@ -277,6 +285,10 @@ class PluginInstallerImpl { // Dimensions of the plugin uint32_t width_; uint32_t height_; + // Plugin icon + NSImage* image_; + // Displayed text + NSString* command_; DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); }; diff --git a/chrome/default_plugin/plugin_impl_mac.mm b/chrome/default_plugin/plugin_impl_mac.mm index 253e786..9c8bff4 100644 --- a/chrome/default_plugin/plugin_impl_mac.mm +++ b/chrome/default_plugin/plugin_impl_mac.mm @@ -6,11 +6,14 @@ #import <Cocoa/Cocoa.h> +#include "app/l10n_util_mac.h" +#include "app/resource_bundle.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/string_util.h" #include "chrome/default_plugin/plugin_main.h" #include "googleurl/src/gurl.h" +#include "grit/default_plugin_resources.h" #include "grit/webkit_strings.h" #include "unicode/locid.h" #include "webkit/glue/webkit_glue.h" @@ -19,10 +22,14 @@ // TODO(thakis): Most methods in this class are stubbed out and need to be // implemented. -PluginInstallerImpl::PluginInstallerImpl(int16 mode) { +PluginInstallerImpl::PluginInstallerImpl(int16 mode) + : image_(nil), + command_(nil) { } PluginInstallerImpl::~PluginInstallerImpl() { + [image_ release]; + [command_ release]; } bool PluginInstallerImpl::Initialize(void* module_handle, NPP instance, @@ -40,6 +47,12 @@ bool PluginInstallerImpl::Initialize(void* module_handle, NPP instance, instance_ = instance; mime_type_ = mime_type; + command_ = [l10n_util::FixUpWindowsStyleLabel(webkit_glue::GetLocalizedString( + IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG)) retain]; + + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + image_ = [rb.GetNSImageNamed(IDR_PLUGIN_ICON) retain]; + return true; } @@ -125,42 +138,49 @@ void PluginInstallerImpl::DownloadCancelled() { } int16 PluginInstallerImpl::OnDrawRect(CGContextRef context, CGRect dirty_rect) { - const NSString* text = @"Missing Plug-in"; - const float kTextMarginX = 6; - const float kTextMarginY = 1; - NSSize bounds = NSMakeSize(width_, height_); - [NSGraphicsContext saveGraphicsState]; NSGraphicsContext* ns_context = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES]; [NSGraphicsContext setCurrentContext:ns_context]; + // Fill background. + NSColor* bg_color = [NSColor colorWithCalibratedRed:252 / 255.0 + green:235 / 255.0 + blue:162 / 255.0 + alpha:1.0]; + [bg_color setFill]; + NSRectFill(NSRectFromCGRect(dirty_rect)); + + [[NSColor blackColor] set]; + NSFrameRect(NSMakeRect(0, 0, width_, height_)); + + // Drag image. + DCHECK(image_); + if (image_) { + NSPoint point = NSMakePoint((width_ - [image_ size].width) / 2, + (height_ + [image_ size].height) / 2); + [image_ dissolveToPoint:point fraction:1.0]; + } + + // Draw text. NSShadow* shadow = [[[NSShadow alloc] init] autorelease]; - [shadow setShadowColor:[NSColor colorWithDeviceWhite:0.0 alpha:0.5]]; + [shadow setShadowColor:[NSColor colorWithDeviceWhite:1.0 alpha:0.5]]; [shadow setShadowOffset:NSMakeSize(0, -1)]; - NSFont* font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]]; + NSFont* font = [NSFont systemFontOfSize: + [NSFont systemFontSizeForControlSize:NSSmallControlSize]]; NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: font, NSFontAttributeName, - [NSColor whiteColor], NSForegroundColorAttributeName, + [NSColor blackColor], NSForegroundColorAttributeName, shadow, NSShadowAttributeName, nil]; - NSSize text_size = [text sizeWithAttributes:attributes]; - NSRect text_rect; - text_rect.size.width = text_size.width + 2*kTextMarginX; - text_rect.size.height = text_size.height + 2*kTextMarginY; - text_rect.origin.x = (bounds.width - NSWidth(text_rect))/2; - text_rect.origin.y = (bounds.height - NSHeight(text_rect))/2; - - [[NSColor colorWithCalibratedWhite:0.52 alpha:1.0] setFill]; - [[NSBezierPath bezierPathWithRoundedRect:text_rect - xRadius:NSHeight(text_rect)/2 - yRadius:NSHeight(text_rect)/2] fill]; - - NSPoint label_point = NSMakePoint( - roundf(text_rect.origin.x + (text_rect.size.width - text_size.width)/2), - roundf(text_rect.origin.y + (text_rect.size.height - text_size.height)/2)); - [text drawAtPoint:label_point withAttributes:attributes]; + NSSize text_size = [command_ sizeWithAttributes:attributes]; + NSPoint label_point = NSMakePoint((width_ - text_size.width) / 2, + (height_ - text_size.height) / 2); + if (image_) + label_point.y += [image_ size].height / 2 + text_size.height / 2 + 10; + label_point = NSMakePoint(roundf(label_point.x), roundf(label_point.y)); + [command_ drawAtPoint:label_point withAttributes:attributes]; [NSGraphicsContext restoreGraphicsState]; return 1; |