Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/default_plugin/plugin_impl_mac.h" | 5 #include "chrome/default_plugin/plugin_impl_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/default_plugin/plugin_main.h" | 12 #include "chrome/default_plugin/plugin_main.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "grit/default_plugin_resources.h" | 14 #include "grit/default_plugin_resources.h" |
| 15 #include "grit/webkit_strings.h" | 15 #include "grit/webkit_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/l10n/l10n_util_mac.h" | 17 #include "ui/base/l10n/l10n_util_mac.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | |
| 20 #include "unicode/locid.h" | 21 #include "unicode/locid.h" |
| 21 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
| 22 #include "webkit/plugins/npapi/default_plugin_shared.h" | 23 #include "webkit/plugins/npapi/default_plugin_shared.h" |
| 23 | 24 |
| 24 // TODO(thakis): Most methods in this class are stubbed out and need to be | 25 // TODO(thakis): Most methods in this class are stubbed out and need to be |
| 25 // implemented. | 26 // implemented. |
| 26 | 27 |
| 27 PluginInstallerImpl::PluginInstallerImpl(int16 mode) | 28 PluginInstallerImpl::PluginInstallerImpl(int16 mode) |
| 28 : image_(nil), | 29 : image_(nil), |
| 29 command_(nil) { | 30 command_(nil) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 } | 133 } |
| 133 | 134 |
| 134 void PluginInstallerImpl::DownloadPlugin() { | 135 void PluginInstallerImpl::DownloadPlugin() { |
| 135 } | 136 } |
| 136 | 137 |
| 137 void PluginInstallerImpl::DownloadCancelled() { | 138 void PluginInstallerImpl::DownloadCancelled() { |
| 138 DisplayAvailablePluginStatus(); | 139 DisplayAvailablePluginStatus(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 int16 PluginInstallerImpl::OnDrawRect(CGContextRef context, CGRect dirty_rect) { | 142 int16 PluginInstallerImpl::OnDrawRect(CGContextRef context, CGRect dirty_rect) { |
| 142 [NSGraphicsContext saveGraphicsState]; | 143 gfx::ScopedNSGraphicsContextSaveGState scoped_state; |
| 143 NSGraphicsContext* ns_context = [NSGraphicsContext | 144 NSGraphicsContext* ns_context = [NSGraphicsContext |
| 144 graphicsContextWithGraphicsPort:context flipped:YES]; | 145 graphicsContextWithGraphicsPort:context flipped:YES]; |
| 145 [NSGraphicsContext setCurrentContext:ns_context]; | 146 [NSGraphicsContext setCurrentContext:ns_context]; |
|
Mark Mentovai
2011/08/05 01:15:45
☞
| |
| 146 | 147 |
| 147 // Fill background. | 148 // Fill background. |
| 148 NSColor* bg_color = [NSColor colorWithCalibratedRed:252 / 255.0 | 149 NSColor* bg_color = [NSColor colorWithCalibratedRed:252 / 255.0 |
| 149 green:235 / 255.0 | 150 green:235 / 255.0 |
| 150 blue:162 / 255.0 | 151 blue:162 / 255.0 |
| 151 alpha:1.0]; | 152 alpha:1.0]; |
| 152 [bg_color setFill]; | 153 [bg_color setFill]; |
| 153 NSRectFill(NSRectFromCGRect(dirty_rect)); | 154 NSRectFill(NSRectFromCGRect(dirty_rect)); |
| 154 | 155 |
| 155 [[NSColor blackColor] set]; | 156 [[NSColor blackColor] set]; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 176 nil]; | 177 nil]; |
| 177 | 178 |
| 178 NSSize text_size = [command_ sizeWithAttributes:attributes]; | 179 NSSize text_size = [command_ sizeWithAttributes:attributes]; |
| 179 NSPoint label_point = NSMakePoint((width_ - text_size.width) / 2, | 180 NSPoint label_point = NSMakePoint((width_ - text_size.width) / 2, |
| 180 (height_ - text_size.height) / 2); | 181 (height_ - text_size.height) / 2); |
| 181 if (image_) | 182 if (image_) |
| 182 label_point.y += [image_ size].height / 2 + text_size.height / 2 + 10; | 183 label_point.y += [image_ size].height / 2 + text_size.height / 2 + 10; |
| 183 label_point = NSMakePoint(roundf(label_point.x), roundf(label_point.y)); | 184 label_point = NSMakePoint(roundf(label_point.x), roundf(label_point.y)); |
| 184 [command_ drawAtPoint:label_point withAttributes:attributes]; | 185 [command_ drawAtPoint:label_point withAttributes:attributes]; |
| 185 | 186 |
| 186 [NSGraphicsContext restoreGraphicsState]; | |
| 187 return 1; | 187 return 1; |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 void PluginInstallerImpl::ShowInstallDialog() { | 191 void PluginInstallerImpl::ShowInstallDialog() { |
| 192 } | 192 } |
| 193 | 193 |
| 194 void PluginInstallerImpl::NotifyPluginStatus(int status) { | 194 void PluginInstallerImpl::NotifyPluginStatus(int status) { |
| 195 default_plugin::g_browser->getvalue( | 195 default_plugin::g_browser->getvalue( |
| 196 instance_, | 196 instance_, |
| 197 static_cast<NPNVariable>( | 197 static_cast<NPNVariable>( |
| 198 webkit::npapi::default_plugin::kMissingPluginStatusStart + status), | 198 webkit::npapi::default_plugin::kMissingPluginStatusStart + status), |
| 199 NULL); | 199 NULL); |
| 200 } | 200 } |
| OLD | NEW |