OLD | NEW |
1 // Copyright (c) 2011 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" | |
21 #include "unicode/locid.h" | 20 #include "unicode/locid.h" |
22 #include "webkit/glue/webkit_glue.h" | 21 #include "webkit/glue/webkit_glue.h" |
23 #include "webkit/plugins/npapi/default_plugin_shared.h" | 22 #include "webkit/plugins/npapi/default_plugin_shared.h" |
24 | 23 |
25 // TODO(thakis): Most methods in this class are stubbed out and need to be | 24 // TODO(thakis): Most methods in this class are stubbed out and need to be |
26 // implemented. | 25 // implemented. |
27 | 26 |
28 PluginInstallerImpl::PluginInstallerImpl(int16 mode) | 27 PluginInstallerImpl::PluginInstallerImpl(int16 mode) |
29 : image_(nil), | 28 : image_(nil), |
30 command_(nil) { | 29 command_(nil) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 132 } |
134 | 133 |
135 void PluginInstallerImpl::DownloadPlugin() { | 134 void PluginInstallerImpl::DownloadPlugin() { |
136 } | 135 } |
137 | 136 |
138 void PluginInstallerImpl::DownloadCancelled() { | 137 void PluginInstallerImpl::DownloadCancelled() { |
139 DisplayAvailablePluginStatus(); | 138 DisplayAvailablePluginStatus(); |
140 } | 139 } |
141 | 140 |
142 int16 PluginInstallerImpl::OnDrawRect(CGContextRef context, CGRect dirty_rect) { | 141 int16 PluginInstallerImpl::OnDrawRect(CGContextRef context, CGRect dirty_rect) { |
143 gfx::ScopedNSGraphicsContextSaveGState scoped_state; | 142 [NSGraphicsContext saveGraphicsState]; |
144 NSGraphicsContext* ns_context = [NSGraphicsContext | 143 NSGraphicsContext* ns_context = [NSGraphicsContext |
145 graphicsContextWithGraphicsPort:context flipped:YES]; | 144 graphicsContextWithGraphicsPort:context flipped:YES]; |
146 [NSGraphicsContext setCurrentContext:ns_context]; | 145 [NSGraphicsContext setCurrentContext:ns_context]; |
147 | 146 |
148 // Fill background. | 147 // Fill background. |
149 NSColor* bg_color = [NSColor colorWithCalibratedRed:252 / 255.0 | 148 NSColor* bg_color = [NSColor colorWithCalibratedRed:252 / 255.0 |
150 green:235 / 255.0 | 149 green:235 / 255.0 |
151 blue:162 / 255.0 | 150 blue:162 / 255.0 |
152 alpha:1.0]; | 151 alpha:1.0]; |
153 [bg_color setFill]; | 152 [bg_color setFill]; |
(...skipping 23 matching lines...) Expand all Loading... |
177 nil]; | 176 nil]; |
178 | 177 |
179 NSSize text_size = [command_ sizeWithAttributes:attributes]; | 178 NSSize text_size = [command_ sizeWithAttributes:attributes]; |
180 NSPoint label_point = NSMakePoint((width_ - text_size.width) / 2, | 179 NSPoint label_point = NSMakePoint((width_ - text_size.width) / 2, |
181 (height_ - text_size.height) / 2); | 180 (height_ - text_size.height) / 2); |
182 if (image_) | 181 if (image_) |
183 label_point.y += [image_ size].height / 2 + text_size.height / 2 + 10; | 182 label_point.y += [image_ size].height / 2 + text_size.height / 2 + 10; |
184 label_point = NSMakePoint(roundf(label_point.x), roundf(label_point.y)); | 183 label_point = NSMakePoint(roundf(label_point.x), roundf(label_point.y)); |
185 [command_ drawAtPoint:label_point withAttributes:attributes]; | 184 [command_ drawAtPoint:label_point withAttributes:attributes]; |
186 | 185 |
| 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 |