| 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/bookmarks/bookmark_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 15 #import "chrome/browser/ui/cocoa/bubble_sync_promo_controller.h" | 15 #import "chrome/browser/ui/cocoa/bubble_sync_promo_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 16 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 17 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 18 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 18 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 19 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| 19 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 20 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 20 #include "chrome/grit/chromium_strings.h" | 21 #include "chrome/grit/chromium_strings.h" |
| 21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/bookmarks/browser/bookmark_model.h" | 23 #include "components/bookmarks/browser/bookmark_model.h" |
| 23 #include "components/bookmarks/browser/bookmark_utils.h" | 24 #include "components/bookmarks/browser/bookmark_utils.h" |
| 24 #include "components/bookmarks/managed/managed_bookmark_service.h" | 25 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 25 #include "components/signin/core/browser/signin_metrics.h" | 26 #include "components/signin/core/browser/signin_metrics.h" |
| 26 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 [window setFrameOrigin:arrowTip]; | 159 [window setFrameOrigin:arrowTip]; |
| 159 | 160 |
| 160 // Default is IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark". | 161 // Default is IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark". |
| 161 // If adding for the 1st time the string becomes "Bookmark Added!" | 162 // If adding for the 1st time the string becomes "Bookmark Added!" |
| 162 if (!alreadyBookmarked_) { | 163 if (!alreadyBookmarked_) { |
| 163 NSString* title = | 164 NSString* title = |
| 164 l10n_util::GetNSString(IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED); | 165 l10n_util::GetNSString(IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED); |
| 165 [bigTitle_ setStringValue:title]; | 166 [bigTitle_ setStringValue:title]; |
| 166 } | 167 } |
| 167 | 168 |
| 169 [self adjustForRTLIfNecessary]; |
| 170 |
| 168 [self fillInFolderList]; | 171 [self fillInFolderList]; |
| 169 | 172 |
| 170 // Ping me when things change out from under us. Unlike a normal | 173 // Ping me when things change out from under us. Unlike a normal |
| 171 // dialog, the bookmark bubble's cancel: means "don't add this as a | 174 // dialog, the bookmark bubble's cancel: means "don't add this as a |
| 172 // bookmark", not "cancel editing". We must take extra care to not | 175 // bookmark", not "cancel editing". We must take extra care to not |
| 173 // touch the bookmark in this selector. | 176 // touch the bookmark in this selector. |
| 174 bookmarkObserver_.reset(new BookmarkModelObserverForCocoa(model_, ^() { | 177 bookmarkObserver_.reset(new BookmarkModelObserverForCocoa(model_, ^() { |
| 175 [self dismissWithoutEditing:nil]; | 178 [self dismissWithoutEditing:nil]; |
| 176 })); | 179 })); |
| 177 bookmarkObserver_->StartObservingNode(node_); | 180 bookmarkObserver_->StartObservingNode(node_); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 311 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
| 309 [folderPopUpButton_ selectItemAtIndex:idx]; | 312 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 310 } | 313 } |
| 311 | 314 |
| 312 - (LocationBarDecoration*)decorationForBubble { | 315 - (LocationBarDecoration*)decorationForBubble { |
| 313 LocationBarViewMac* locationBar = | 316 LocationBarViewMac* locationBar = |
| 314 [[[self parentWindow] windowController] locationBarBridge]; | 317 [[[self parentWindow] windowController] locationBarBridge]; |
| 315 return locationBar ? locationBar->star_decoration() : nullptr; | 318 return locationBar ? locationBar->star_decoration() : nullptr; |
| 316 } | 319 } |
| 317 | 320 |
| 321 - (void)adjustForRTLIfNecessary { |
| 322 // Info bubble view to: |
| 323 // - Fix the leading margin on the title. |
| 324 // - Flip containers. |
| 325 cocoa_l10n_util::FlipAllSubviewsIfNecessary([bigTitle_ superview]); |
| 326 // Margin on the labels. |
| 327 cocoa_l10n_util::FlipAllSubviewsIfNecessary(fieldLabelsContainer_); |
| 328 // Margin on the fields. |
| 329 cocoa_l10n_util::FlipAllSubviewsIfNecessary([nameTextField_ superview]); |
| 330 // Relative order of the done and options buttons. |
| 331 cocoa_l10n_util::FlipAllSubviewsIfNecessary(trailingButtonContainer_); |
| 332 } |
| 333 |
| 318 @end // BookmarkBubbleController | 334 @end // BookmarkBubbleController |
| 319 | 335 |
| 320 | 336 |
| 321 @implementation BookmarkBubbleController (ExposedForUnitTesting) | 337 @implementation BookmarkBubbleController (ExposedForUnitTesting) |
| 322 | 338 |
| 323 - (NSView*)syncPromoPlaceholder { | 339 - (NSView*)syncPromoPlaceholder { |
| 324 return syncPromoPlaceholder_; | 340 return syncPromoPlaceholder_; |
| 325 } | 341 } |
| 326 | 342 |
| 327 - (bookmarks::BookmarkBubbleObserver*)bookmarkBubbleObserver { | 343 - (bookmarks::BookmarkBubbleObserver*)bookmarkBubbleObserver { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 390 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
| 375 DCHECK(idx != -1); | 391 DCHECK(idx != -1); |
| 376 [folderPopUpButton_ selectItemAtIndex:idx]; | 392 [folderPopUpButton_ selectItemAtIndex:idx]; |
| 377 } | 393 } |
| 378 | 394 |
| 379 - (NSPopUpButton*)folderPopUpButton { | 395 - (NSPopUpButton*)folderPopUpButton { |
| 380 return folderPopUpButton_; | 396 return folderPopUpButton_; |
| 381 } | 397 } |
| 382 | 398 |
| 383 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) | 399 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) |
| OLD | NEW |