OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 23 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
24 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 24 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
25 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 25 #include "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
26 #include "chrome/browser/ui/cocoa/hover_close_button.h" | 26 #include "chrome/browser/ui/cocoa/hover_close_button.h" |
27 #include "chrome/browser/ui/cocoa/info_bubble_view.h" | 27 #include "chrome/browser/ui/cocoa/info_bubble_view.h" |
28 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 28 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
29 #include "chrome/browser/ui/cocoa/new_tab_button.h" | 29 #include "chrome/browser/ui/cocoa/new_tab_button.h" |
30 #include "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 30 #include "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
31 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 31 #include "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
32 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" | 32 #include "chrome/browser/ui/extensions/extension_install_ui_factory.h" |
33 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" | |
33 #include "chrome/browser/ui/singleton_tabs.h" | 34 #include "chrome/browser/ui/singleton_tabs.h" |
34 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 35 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
35 #include "chrome/common/extensions/api/commands/commands_handler.h" | 36 #include "chrome/common/extensions/api/commands/commands_handler.h" |
36 #include "chrome/common/extensions/api/extension_action/action_info.h" | 37 #include "chrome/common/extensions/api/extension_action/action_info.h" |
37 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 38 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
38 #include "chrome/common/extensions/sync_helper.h" | 39 #include "chrome/common/extensions/sync_helper.h" |
39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
40 #include "chrome/grit/chromium_strings.h" | 41 #include "chrome/grit/chromium_strings.h" |
41 #include "chrome/grit/generated_resources.h" | 42 #include "chrome/grit/generated_resources.h" |
42 #include "content/public/browser/notification_details.h" | 43 #include "content/public/browser/notification_details.h" |
43 #include "content/public/browser/notification_registrar.h" | 44 #include "content/public/browser/notification_registrar.h" |
44 #include "content/public/browser/notification_source.h" | 45 #include "content/public/browser/notification_source.h" |
45 #include "extensions/browser/install/extension_install_ui.h" | 46 #include "extensions/browser/install/extension_install_ui.h" |
46 #include "extensions/common/extension.h" | 47 #include "extensions/common/extension.h" |
47 #import "skia/ext/skia_utils_mac.h" | 48 #import "skia/ext/skia_utils_mac.h" |
48 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" | 49 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" |
49 #import "ui/base/cocoa/controls/hyperlink_text_view.h" | 50 #import "ui/base/cocoa/controls/hyperlink_text_view.h" |
50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
51 | 52 |
52 using content::BrowserThread; | 53 using content::BrowserThread; |
53 using extensions::BundleInstaller; | 54 using extensions::BundleInstaller; |
54 using extensions::Extension; | 55 using extensions::Extension; |
55 using extensions::UnloadedExtensionInfo; | 56 using extensions::UnloadedExtensionInfo; |
56 | 57 |
57 // C++ class that receives EXTENSION_LOADED notifications and proxies them back | 58 class ExtensionInstalledBubbleBridge |
58 // to |controller|. | 59 : public ExtensionInstalledBubble::Delegate { |
59 class ExtensionLoadedNotificationObserver | |
60 : public content::NotificationObserver { | |
61 public: | 60 public: |
62 ExtensionLoadedNotificationObserver( | 61 ExtensionInstalledBubbleBridge( |
Robert Sesek
2015/02/12 23:47:35
explicit
Devlin
2015/02/13 01:11:50
I forget how dependent I am on presubmit checks so
| |
63 ExtensionInstalledBubbleController* controller, Profile* profile) | 62 ExtensionInstalledBubbleController* controller); |
64 : controller_(controller) { | 63 ~ExtensionInstalledBubbleBridge() override; |
65 registrar_.Add(this, | |
66 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | |
67 content::Source<Profile>(profile)); | |
68 registrar_.Add(this, | |
69 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
70 content::Source<Profile>(profile)); | |
71 } | |
72 | 64 |
73 private: | 65 private: |
74 // NotificationObserver implementation. Tells the controller to start showing | 66 // ExtensionInstalledBubble::Delegate: |
75 // its window on the main thread when the extension has finished loading. | 67 bool MaybeShowNow() override; |
76 void Observe(int type, | |
77 const content::NotificationSource& source, | |
78 const content::NotificationDetails& details) override { | |
79 if (type == extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) { | |
80 const Extension* extension = | |
81 content::Details<const Extension>(details).ptr(); | |
82 if (extension == [controller_ extension]) { | |
83 [controller_ performSelectorOnMainThread:@selector(showWindow:) | |
84 withObject:controller_ | |
85 waitUntilDone:NO]; | |
86 } | |
87 } else if (type == extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { | |
88 const Extension* extension = | |
89 content::Details<const UnloadedExtensionInfo>(details)->extension; | |
90 if (extension == [controller_ extension]) { | |
91 [controller_ performSelectorOnMainThread:@selector(extensionUnloaded:) | |
92 withObject:controller_ | |
93 waitUntilDone:NO]; | |
94 } | |
95 } else { | |
96 NOTREACHED() << "Received unexpected notification."; | |
97 } | |
98 } | |
99 | 68 |
100 content::NotificationRegistrar registrar_; | 69 // The (owning) installed bubble controller. |
101 ExtensionInstalledBubbleController* controller_; // weak, owns us | 70 ExtensionInstalledBubbleController* controller_; |
102 }; | 71 }; |
Robert Sesek
2015/02/12 23:47:35
DISALLOW_COPY_AND_ASSIGN
Devlin
2015/02/13 01:11:50
Done.
| |
103 | 72 |
73 ExtensionInstalledBubbleBridge::ExtensionInstalledBubbleBridge( | |
74 ExtensionInstalledBubbleController* controller) | |
75 : controller_(controller) { | |
76 } | |
77 | |
78 ExtensionInstalledBubbleBridge::~ExtensionInstalledBubbleBridge() { | |
79 } | |
80 | |
81 bool ExtensionInstalledBubbleBridge::MaybeShowNow() { | |
82 [controller_ showWindow:controller_]; | |
83 return true; | |
84 } | |
85 | |
104 @implementation ExtensionInstalledBubbleController | 86 @implementation ExtensionInstalledBubbleController |
105 | 87 |
106 @synthesize extension = extension_; | |
107 @synthesize bundle = bundle_; | 88 @synthesize bundle = bundle_; |
108 // Exposed for unit test. | 89 // Exposed for unit test. |
109 @synthesize pageActionPreviewShowing = pageActionPreviewShowing_; | 90 @synthesize pageActionPreviewShowing = pageActionPreviewShowing_; |
110 | 91 |
111 - (id)initWithParentWindow:(NSWindow*)parentWindow | 92 - (id)initWithParentWindow:(NSWindow*)parentWindow |
112 extension:(const Extension*)extension | 93 extension:(const Extension*)extension |
113 bundle:(const BundleInstaller*)bundle | 94 bundle:(const BundleInstaller*)bundle |
114 browser:(Browser*)browser | 95 browser:(Browser*)browser |
115 icon:(SkBitmap)icon { | 96 icon:(SkBitmap)icon { |
116 NSString* nibName = bundle ? @"ExtensionInstalledBubbleBundle" : | 97 NSString* nibName = bundle ? @"ExtensionInstalledBubbleBundle" : |
117 @"ExtensionInstalledBubble"; | 98 @"ExtensionInstalledBubble"; |
118 if ((self = [super initWithWindowNibPath:nibName | 99 if ((self = [super initWithWindowNibPath:nibName |
119 parentWindow:parentWindow | 100 parentWindow:parentWindow |
120 anchoredAt:NSZeroPoint])) { | 101 anchoredAt:NSZeroPoint])) { |
121 extension_ = extension; | |
122 bundle_ = bundle; | 102 bundle_ = bundle; |
123 DCHECK(browser); | 103 DCHECK(browser); |
124 browser_ = browser; | 104 browser_ = browser; |
125 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]); | 105 icon_.reset([gfx::SkBitmapToNSImage(icon) retain]); |
126 pageActionPreviewShowing_ = NO; | 106 pageActionPreviewShowing_ = NO; |
127 | 107 |
128 if (bundle_) { | 108 if (bundle_) { |
129 type_ = extension_installed_bubble::kBundle; | 109 type_ = extension_installed_bubble::kBundle; |
130 } else if (extension->is_app()) { | 110 } else if (extension->is_app()) { |
131 type_ = extension_installed_bubble::kApp; | 111 type_ = extension_installed_bubble::kApp; |
132 } else if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) { | 112 } else if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) { |
133 type_ = extension_installed_bubble::kOmniboxKeyword; | 113 type_ = extension_installed_bubble::kOmniboxKeyword; |
134 } else if (extensions::ActionInfo::GetBrowserActionInfo(extension)) { | 114 } else if (extensions::ActionInfo::GetBrowserActionInfo(extension)) { |
135 type_ = extension_installed_bubble::kBrowserAction; | 115 type_ = extension_installed_bubble::kBrowserAction; |
136 } else if (extensions::ActionInfo::GetPageActionInfo(extension) && | 116 } else if (extensions::ActionInfo::GetPageActionInfo(extension) && |
137 extensions::ActionInfo::IsVerboseInstallMessage(extension)) { | 117 extensions::ActionInfo::IsVerboseInstallMessage(extension)) { |
138 type_ = extension_installed_bubble::kPageAction; | 118 type_ = extension_installed_bubble::kPageAction; |
139 } else { | 119 } else { |
140 type_ = extension_installed_bubble::kGeneric; | 120 type_ = extension_installed_bubble::kGeneric; |
141 } | 121 } |
142 | 122 |
143 if (type_ == extension_installed_bubble::kBundle) { | 123 if (type_ == extension_installed_bubble::kBundle) { |
144 [self showWindow:self]; | 124 [self showWindow:self]; |
145 } else { | 125 } else { |
146 // Start showing window only after extension has fully loaded. | 126 // Start showing window only after extension has fully loaded. |
147 extensionObserver_.reset(new ExtensionLoadedNotificationObserver( | 127 installedBubbleBridge_.reset(new ExtensionInstalledBubbleBridge(self)); |
148 self, browser->profile())); | 128 installedBubble_.reset(new ExtensionInstalledBubble( |
129 installedBubbleBridge_.get(), | |
130 extension, | |
131 browser, | |
132 icon)); | |
133 installedBubble_->IgnoreBrowserClosing(); | |
149 } | 134 } |
150 } | 135 } |
151 return self; | 136 return self; |
152 } | 137 } |
153 | 138 |
139 - (const Extension*)extension { | |
140 return installedBubble_->extension(); | |
141 } | |
142 | |
154 // Sets |promo_| based on |promoPlaceholder_|, sets |promoPlaceholder_| to nil. | 143 // Sets |promo_| based on |promoPlaceholder_|, sets |promoPlaceholder_| to nil. |
155 - (void)initializeLabel { | 144 - (void)initializeLabel { |
156 // Replace the promo placeholder NSTextField with the real label NSTextView. | 145 // Replace the promo placeholder NSTextField with the real label NSTextView. |
157 // The former doesn't show links in a nice way, but the latter can't be added | 146 // The former doesn't show links in a nice way, but the latter can't be added |
158 // in IB without a containing scroll view, so create the NSTextView | 147 // in IB without a containing scroll view, so create the NSTextView |
159 // programmatically. | 148 // programmatically. |
160 promo_.reset([[HyperlinkTextView alloc] | 149 promo_.reset([[HyperlinkTextView alloc] |
161 initWithFrame:[promoPlaceholder_ frame]]); | 150 initWithFrame:[promoPlaceholder_ frame]]); |
162 [promo_.get() setAutoresizingMask:[promoPlaceholder_ autoresizingMask]]; | 151 [promo_.get() setAutoresizingMask:[promoPlaceholder_ autoresizingMask]]; |
163 [[promoPlaceholder_ superview] | 152 [[promoPlaceholder_ superview] |
164 replaceSubview:promoPlaceholder_ with:promo_.get()]; | 153 replaceSubview:promoPlaceholder_ with:promo_.get()]; |
165 promoPlaceholder_ = nil; // Now released. | 154 promoPlaceholder_ = nil; // Now released. |
166 [promo_.get() setDelegate:self]; | 155 [promo_.get() setDelegate:self]; |
167 } | 156 } |
168 | 157 |
169 // Returns YES if the sync promo should be shown in the bubble. | 158 // Returns YES if the sync promo should be shown in the bubble. |
170 - (BOOL)showSyncPromo { | 159 - (BOOL)showSyncPromo { |
171 return extensions::sync_helper::IsSyncableExtension(extension_) && | 160 return extensions::sync_helper::IsSyncableExtension([self extension]) && |
172 SyncPromoUI::ShouldShowSyncPromo(browser_->profile()); | 161 SyncPromoUI::ShouldShowSyncPromo(browser_->profile()); |
173 } | 162 } |
174 | 163 |
175 - (void)windowWillClose:(NSNotification*)notification { | 164 - (void)windowWillClose:(NSNotification*)notification { |
176 // Turn off page action icon preview when the window closes, unless we | 165 // Turn off page action icon preview when the window closes, unless we |
177 // already removed it when the window resigned key status. | 166 // already removed it when the window resigned key status. |
178 [self removePageActionPreviewIfNecessary]; | 167 [self removePageActionPreviewIfNecessary]; |
179 extension_ = NULL; | |
180 browser_ = NULL; | 168 browser_ = NULL; |
181 [closeButton_ setTrackingEnabled:NO]; | 169 [closeButton_ setTrackingEnabled:NO]; |
182 [super windowWillClose:notification]; | 170 [super windowWillClose:notification]; |
183 } | 171 } |
184 | 172 |
185 // The controller is the delegate of the window, so it receives "did resign | 173 // The controller is the delegate of the window, so it receives "did resign |
186 // key" notifications. When key is resigned, close the window. | 174 // key" notifications. When key is resigned, close the window. |
187 - (void)windowDidResignKey:(NSNotification*)notification { | 175 - (void)windowDidResignKey:(NSNotification*)notification { |
188 // If the browser window is closing, we need to remove the page action | 176 // If the browser window is closing, we need to remove the page action |
189 // immediately, otherwise the closing animation may overlap with | 177 // immediately, otherwise the closing animation may overlap with |
(...skipping 11 matching lines...) Expand all Loading... | |
201 clickedOnLink:(id)link | 189 clickedOnLink:(id)link |
202 atIndex:(NSUInteger)charIndex { | 190 atIndex:(NSUInteger)charIndex { |
203 DCHECK_EQ(promo_.get(), aTextView); | 191 DCHECK_EQ(promo_.get(), aTextView); |
204 chrome::ShowBrowserSignin(browser_, | 192 chrome::ShowBrowserSignin(browser_, |
205 signin_metrics::SOURCE_EXTENSION_INSTALL_BUBBLE); | 193 signin_metrics::SOURCE_EXTENSION_INSTALL_BUBBLE); |
206 return YES; | 194 return YES; |
207 } | 195 } |
208 | 196 |
209 // Extracted to a function here so that it can be overridden for unit testing. | 197 // Extracted to a function here so that it can be overridden for unit testing. |
210 - (void)removePageActionPreviewIfNecessary { | 198 - (void)removePageActionPreviewIfNecessary { |
211 if (!extension_ || !pageActionPreviewShowing_) | 199 if (![self extension] || !pageActionPreviewShowing_) |
212 return; | 200 return; |
213 ExtensionAction* page_action = | 201 ExtensionAction* page_action = |
214 extensions::ExtensionActionManager::Get(browser_->profile())-> | 202 extensions::ExtensionActionManager::Get(browser_->profile())-> |
215 GetPageAction(*extension_); | 203 GetPageAction(*[self extension]); |
216 if (!page_action) | 204 if (!page_action) |
217 return; | 205 return; |
218 pageActionPreviewShowing_ = NO; | 206 pageActionPreviewShowing_ = NO; |
219 | 207 |
220 BrowserWindowCocoa* window = | 208 BrowserWindowCocoa* window = |
221 static_cast<BrowserWindowCocoa*>(browser_->window()); | 209 static_cast<BrowserWindowCocoa*>(browser_->window()); |
222 LocationBarViewMac* locationBarView = | 210 LocationBarViewMac* locationBarView = |
223 [window->cocoa_controller() locationBarBridge]; | 211 [window->cocoa_controller() locationBarBridge]; |
224 locationBarView->SetPreviewEnabledPageAction(page_action, | 212 locationBarView->SetPreviewEnabledPageAction(page_action, |
225 false); // disables preview. | 213 false); // disables preview. |
(...skipping 24 matching lines...) Expand all Loading... | |
250 case extension_installed_bubble::kOmniboxKeyword: { | 238 case extension_installed_bubble::kOmniboxKeyword: { |
251 LocationBarViewMac* locationBarView = | 239 LocationBarViewMac* locationBarView = |
252 [window->cocoa_controller() locationBarBridge]; | 240 [window->cocoa_controller() locationBarBridge]; |
253 arrowPoint = locationBarView->GetPageInfoBubblePoint(); | 241 arrowPoint = locationBarView->GetPageInfoBubblePoint(); |
254 break; | 242 break; |
255 } | 243 } |
256 case extension_installed_bubble::kBrowserAction: { | 244 case extension_installed_bubble::kBrowserAction: { |
257 BrowserActionsController* controller = | 245 BrowserActionsController* controller = |
258 [[window->cocoa_controller() toolbarController] | 246 [[window->cocoa_controller() toolbarController] |
259 browserActionsController]; | 247 browserActionsController]; |
260 arrowPoint = [controller popupPointForId:extension_->id()]; | 248 arrowPoint = [controller popupPointForId:[self extension]->id()]; |
261 break; | 249 break; |
262 } | 250 } |
263 case extension_installed_bubble::kPageAction: { | 251 case extension_installed_bubble::kPageAction: { |
264 LocationBarViewMac* locationBarView = | 252 LocationBarViewMac* locationBarView = |
265 [window->cocoa_controller() locationBarBridge]; | 253 [window->cocoa_controller() locationBarBridge]; |
266 | 254 |
267 ExtensionAction* page_action = | 255 ExtensionAction* page_action = |
268 extensions::ExtensionActionManager::Get(browser_->profile())-> | 256 extensions::ExtensionActionManager::Get(browser_->profile())-> |
269 GetPageAction(*extension_); | 257 GetPageAction(*[self extension]); |
270 | 258 |
271 // Tell the location bar to show a preview of the page action icon, which | 259 // Tell the location bar to show a preview of the page action icon, which |
272 // would ordinarily only be displayed on a page of the appropriate type. | 260 // would ordinarily only be displayed on a page of the appropriate type. |
273 // We remove this preview when the extension installed bubble closes. | 261 // We remove this preview when the extension installed bubble closes. |
274 locationBarView->SetPreviewEnabledPageAction(page_action, true); | 262 locationBarView->SetPreviewEnabledPageAction(page_action, true); |
275 pageActionPreviewShowing_ = YES; | 263 pageActionPreviewShowing_ = YES; |
276 | 264 |
277 // Find the center of the bottom of the page action icon. | 265 // Find the center of the bottom of the page action icon. |
278 arrowPoint = | 266 arrowPoint = |
279 locationBarView->GetPageActionBubblePoint(page_action); | 267 locationBarView->GetPageActionBubblePoint(page_action); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 } | 331 } |
344 [iconImage_ setImage:icon_]; | 332 [iconImage_ setImage:icon_]; |
345 [iconImage_ setNeedsDisplay:YES]; | 333 [iconImage_ setNeedsDisplay:YES]; |
346 return window; | 334 return window; |
347 } | 335 } |
348 | 336 |
349 - (bool)hasActivePageAction:(extensions::Command*)command { | 337 - (bool)hasActivePageAction:(extensions::Command*)command { |
350 extensions::CommandService* command_service = | 338 extensions::CommandService* command_service = |
351 extensions::CommandService::Get(browser_->profile()); | 339 extensions::CommandService::Get(browser_->profile()); |
352 if (type_ == extension_installed_bubble::kPageAction) { | 340 if (type_ == extension_installed_bubble::kPageAction) { |
353 if (extensions::CommandsInfo::GetPageActionCommand(extension_) && | 341 if (extensions::CommandsInfo::GetPageActionCommand([self extension]) && |
354 command_service->GetPageActionCommand( | 342 command_service->GetPageActionCommand( |
355 extension_->id(), | 343 [self extension]->id(), |
356 extensions::CommandService::ACTIVE, | 344 extensions::CommandService::ACTIVE, |
357 command, | 345 command, |
358 NULL)) { | 346 NULL)) { |
359 return true; | 347 return true; |
360 } | 348 } |
361 } | 349 } |
362 | 350 |
363 return false; | 351 return false; |
364 } | 352 } |
365 | 353 |
366 - (bool)hasActiveBrowserAction:(extensions::Command*)command { | 354 - (bool)hasActiveBrowserAction:(extensions::Command*)command { |
367 extensions::CommandService* command_service = | 355 extensions::CommandService* command_service = |
368 extensions::CommandService::Get(browser_->profile()); | 356 extensions::CommandService::Get(browser_->profile()); |
369 if (type_ == extension_installed_bubble::kBrowserAction) { | 357 if (type_ == extension_installed_bubble::kBrowserAction) { |
370 if (extensions::CommandsInfo::GetBrowserActionCommand(extension_) && | 358 if (extensions::CommandsInfo::GetBrowserActionCommand([self extension]) && |
371 command_service->GetBrowserActionCommand( | 359 command_service->GetBrowserActionCommand( |
372 extension_->id(), | 360 [self extension]->id(), |
373 extensions::CommandService::ACTIVE, | 361 extensions::CommandService::ACTIVE, |
374 command, | 362 command, |
375 NULL)) { | 363 NULL)) { |
376 return true; | 364 return true; |
377 } | 365 } |
378 } | 366 } |
379 | 367 |
380 return false; | 368 return false; |
381 } | 369 } |
382 | 370 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 // it with text (it tells you it is single-line even if it is multiline), so | 445 // it with text (it tells you it is single-line even if it is multiline), so |
458 // here the hidden howToUse_ TextField is temporarily repurposed to | 446 // here the hidden howToUse_ TextField is temporarily repurposed to |
459 // calculate the correct height for the TextView. | 447 // calculate the correct height for the TextView. |
460 [[howToUse_ cell] setAttributedStringValue:[promo_ attributedString]]; | 448 [[howToUse_ cell] setAttributedStringValue:[promo_ attributedString]]; |
461 [GTMUILocalizerAndLayoutTweaker | 449 [GTMUILocalizerAndLayoutTweaker |
462 sizeToFitFixedWidthTextField:howToUse_]; | 450 sizeToFitFixedWidthTextField:howToUse_]; |
463 sync_promo_height = NSHeight([howToUse_ frame]); | 451 sync_promo_height = NSHeight([howToUse_ frame]); |
464 } | 452 } |
465 | 453 |
466 // First part of extension installed message, the heading. | 454 // First part of extension installed message, the heading. |
467 base::string16 extension_name = base::UTF8ToUTF16(extension_->name().c_str()); | 455 base::string16 extension_name = |
456 base::UTF8ToUTF16([self extension]->name().c_str()); | |
468 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 457 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
469 [heading_ setStringValue:l10n_util::GetNSStringF( | 458 [heading_ setStringValue:l10n_util::GetNSStringF( |
470 IDS_EXTENSION_INSTALLED_HEADING, extension_name)]; | 459 IDS_EXTENSION_INSTALLED_HEADING, extension_name)]; |
471 [GTMUILocalizerAndLayoutTweaker | 460 [GTMUILocalizerAndLayoutTweaker |
472 sizeToFitFixedWidthTextField:heading_]; | 461 sizeToFitFixedWidthTextField:heading_]; |
473 newWindowHeight += NSHeight([heading_ frame]) + | 462 newWindowHeight += NSHeight([heading_ frame]) + |
474 extension_installed_bubble::kInnerVerticalMargin; | 463 extension_installed_bubble::kInnerVerticalMargin; |
475 | 464 |
476 // If type is browser/page action, include a special message about them. | 465 // If type is browser/page action, include a special message about them. |
477 if (type_ == extension_installed_bubble::kBrowserAction || | 466 if (type_ == extension_installed_bubble::kBrowserAction || |
478 type_ == extension_installed_bubble::kPageAction) { | 467 type_ == extension_installed_bubble::kPageAction) { |
479 [howToUse_ setStringValue:[self | 468 [howToUse_ setStringValue:[self |
480 installMessageForCurrentExtensionAction]]; | 469 installMessageForCurrentExtensionAction]]; |
481 [howToUse_ setHidden:NO]; | 470 [howToUse_ setHidden:NO]; |
482 [[howToUse_ cell] | 471 [[howToUse_ cell] |
483 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 472 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
484 [GTMUILocalizerAndLayoutTweaker | 473 [GTMUILocalizerAndLayoutTweaker |
485 sizeToFitFixedWidthTextField:howToUse_]; | 474 sizeToFitFixedWidthTextField:howToUse_]; |
486 newWindowHeight += NSHeight([howToUse_ frame]) + | 475 newWindowHeight += NSHeight([howToUse_ frame]) + |
487 extension_installed_bubble::kInnerVerticalMargin; | 476 extension_installed_bubble::kInnerVerticalMargin; |
488 } | 477 } |
489 | 478 |
490 // If type is omnibox keyword, include a special message about the keyword. | 479 // If type is omnibox keyword, include a special message about the keyword. |
491 if (type_ == extension_installed_bubble::kOmniboxKeyword) { | 480 if (type_ == extension_installed_bubble::kOmniboxKeyword) { |
492 [howToUse_ setStringValue:l10n_util::GetNSStringF( | 481 [howToUse_ setStringValue:l10n_util::GetNSStringF( |
493 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 482 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
494 base::UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension_)))]; | 483 base::UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword( |
484 [self extension])))]; | |
495 [howToUse_ setHidden:NO]; | 485 [howToUse_ setHidden:NO]; |
496 [[howToUse_ cell] | 486 [[howToUse_ cell] |
497 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 487 setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
498 [GTMUILocalizerAndLayoutTweaker | 488 [GTMUILocalizerAndLayoutTweaker |
499 sizeToFitFixedWidthTextField:howToUse_]; | 489 sizeToFitFixedWidthTextField:howToUse_]; |
500 newWindowHeight += NSHeight([howToUse_ frame]) + | 490 newWindowHeight += NSHeight([howToUse_ frame]) + |
501 extension_installed_bubble::kInnerVerticalMargin; | 491 extension_installed_bubble::kInnerVerticalMargin; |
502 } | 492 } |
503 | 493 |
504 // If type is app, hide howToManage_, and include a "show me" link in the | 494 // If type is app, hide howToManage_, and include a "show me" link in the |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 return; | 597 return; |
608 } | 598 } |
609 | 599 |
610 NSRect headingFrame = [heading_ frame]; | 600 NSRect headingFrame = [heading_ frame]; |
611 headingFrame.origin.y = newWindowHeight - ( | 601 headingFrame.origin.y = newWindowHeight - ( |
612 NSHeight(headingFrame) + | 602 NSHeight(headingFrame) + |
613 extension_installed_bubble::kOuterVerticalMargin); | 603 extension_installed_bubble::kOuterVerticalMargin); |
614 [heading_ setFrame:headingFrame]; | 604 [heading_ setFrame:headingFrame]; |
615 | 605 |
616 NSRect howToManageFrame = [howToManage_ frame]; | 606 NSRect howToManageFrame = [howToManage_ frame]; |
617 if (!extensions::OmniboxInfo::GetKeyword(extension_).empty() || | 607 if (!extensions::OmniboxInfo::GetKeyword([self extension]).empty() || |
618 extensions::ActionInfo::GetBrowserActionInfo(extension_) || | 608 extensions::ActionInfo::GetBrowserActionInfo([self extension]) || |
619 extensions::ActionInfo::IsVerboseInstallMessage(extension_)) { | 609 extensions::ActionInfo::IsVerboseInstallMessage([self extension])) { |
620 // For browser actions, page actions and omnibox keyword show the | 610 // For browser actions, page actions and omnibox keyword show the |
621 // 'how to use' message before the 'how to manage' message. | 611 // 'how to use' message before the 'how to manage' message. |
622 NSRect howToUseFrame = [howToUse_ frame]; | 612 NSRect howToUseFrame = [howToUse_ frame]; |
623 howToUseFrame.origin.y = headingFrame.origin.y - ( | 613 howToUseFrame.origin.y = headingFrame.origin.y - ( |
624 NSHeight(howToUseFrame) + | 614 NSHeight(howToUseFrame) + |
625 extension_installed_bubble::kInnerVerticalMargin); | 615 extension_installed_bubble::kInnerVerticalMargin); |
626 [howToUse_ setFrame:howToUseFrame]; | 616 [howToUse_ setFrame:howToUseFrame]; |
627 | 617 |
628 howToManageFrame.origin.y = howToUseFrame.origin.y - ( | 618 howToManageFrame.origin.y = howToUseFrame.origin.y - ( |
629 NSHeight(howToManageFrame) + | 619 NSHeight(howToManageFrame) + |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 } | 660 } |
671 | 661 |
672 - (NSRect)frameOfSigninPromo { | 662 - (NSRect)frameOfSigninPromo { |
673 return [promo_ frame]; | 663 return [promo_ frame]; |
674 } | 664 } |
675 | 665 |
676 - (NSButton*)appInstalledShortcutLink { | 666 - (NSButton*)appInstalledShortcutLink { |
677 return appShortcutLink_; | 667 return appShortcutLink_; |
678 } | 668 } |
679 | 669 |
680 - (void)extensionUnloaded:(id)sender { | |
681 extension_ = NULL; | |
682 } | |
683 | |
684 - (IBAction)onManageShortcutClicked:(id)sender { | 670 - (IBAction)onManageShortcutClicked:(id)sender { |
685 [self close]; | 671 [self close]; |
686 std::string configure_url = chrome::kChromeUIExtensionsURL; | 672 std::string configure_url = chrome::kChromeUIExtensionsURL; |
687 configure_url += chrome::kExtensionConfigureCommandsSubPage; | 673 configure_url += chrome::kExtensionConfigureCommandsSubPage; |
688 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( | 674 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( |
689 browser_, GURL(configure_url))); | 675 browser_, GURL(configure_url))); |
690 chrome::Navigate(¶ms); | 676 chrome::Navigate(¶ms); |
691 } | 677 } |
692 | 678 |
693 - (IBAction)onAppShortcutClicked:(id)sender { | 679 - (IBAction)onAppShortcutClicked:(id)sender { |
694 scoped_ptr<extensions::ExtensionInstallUI> install_ui( | 680 scoped_ptr<extensions::ExtensionInstallUI> install_ui( |
695 extensions::CreateExtensionInstallUI(browser_->profile())); | 681 extensions::CreateExtensionInstallUI(browser_->profile())); |
696 install_ui->OpenAppInstalledUI(extension_->id()); | 682 install_ui->OpenAppInstalledUI([self extension]->id()); |
697 } | 683 } |
698 | 684 |
699 - (void)awakeFromNib { | 685 - (void)awakeFromNib { |
700 if (bundle_) | 686 if (bundle_) |
701 return; | 687 return; |
702 [self initializeLabel]; | 688 [self initializeLabel]; |
703 } | 689 } |
704 | 690 |
705 @end | 691 @end |
OLD | NEW |