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 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
12 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" | 14 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
15 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 15 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
16 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
17 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 17 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
18 #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" | 18 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" |
| 19 #include "chrome/grit/chromium_strings.h" |
19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
20 #include "components/bookmarks/browser/bookmark_model.h" | 21 #include "components/bookmarks/browser/bookmark_model.h" |
21 #include "components/bookmarks/browser/bookmark_utils.h" | 22 #include "components/bookmarks/browser/bookmark_utils.h" |
22 #include "content/public/browser/user_metrics.h" | 23 #include "content/public/browser/user_metrics.h" |
23 #include "ui/accessibility/ax_view_state.h" | 24 #include "ui/accessibility/ax_view_state.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/events/keycodes/keyboard_codes.h" | 27 #include "ui/events/keycodes/keyboard_codes.h" |
27 #include "ui/views/bubble/bubble_frame_view.h" | 28 #include "ui/views/bubble/bubble_frame_view.h" |
28 #include "ui/views/controls/button/label_button.h" | 29 #include "ui/views/controls/button/label_button.h" |
(...skipping 28 matching lines...) Expand all Loading... |
57 | 58 |
58 private: | 59 private: |
59 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); | 60 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); |
60 }; | 61 }; |
61 | 62 |
62 } // namespace | 63 } // namespace |
63 | 64 |
64 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; | 65 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
65 | 66 |
66 // static | 67 // static |
67 void BookmarkBubbleView::ShowBubble(views::View* anchor_view, | 68 void BookmarkBubbleView::ShowBubble( |
68 const gfx::Rect& anchor_rect, | 69 views::View* anchor_view, |
69 gfx::NativeView parent_window, | 70 const gfx::Rect& anchor_rect, |
70 bookmarks::BookmarkBubbleObserver* observer, | 71 gfx::NativeView parent_window, |
71 scoped_ptr<BookmarkBubbleDelegate> delegate, | 72 bookmarks::BookmarkBubbleObserver* observer, |
72 Profile* profile, | 73 scoped_ptr<BubbleSyncPromoDelegate> delegate, |
73 const GURL& url, | 74 Profile* profile, |
74 bool already_bookmarked) { | 75 const GURL& url, |
| 76 bool already_bookmarked) { |
75 if (bookmark_bubble_) | 77 if (bookmark_bubble_) |
76 return; | 78 return; |
77 | 79 |
78 bookmark_bubble_ = | 80 bookmark_bubble_ = |
79 new BookmarkBubbleView(anchor_view, observer, delegate.Pass(), profile, | 81 new BookmarkBubbleView(anchor_view, observer, delegate.Pass(), profile, |
80 url, !already_bookmarked); | 82 url, !already_bookmarked); |
81 if (!anchor_view) { | 83 if (!anchor_view) { |
82 bookmark_bubble_->SetAnchorRect(anchor_rect); | 84 bookmark_bubble_->SetAnchorRect(anchor_rect); |
83 bookmark_bubble_->set_parent_window(parent_window); | 85 bookmark_bubble_->set_parent_window(parent_window); |
84 } | 86 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Use FIXED as we don't want the width of the promo to impact the overall | 250 // Use FIXED as we don't want the width of the promo to impact the overall |
249 // width. | 251 // width. |
250 cs->AddColumn(GridLayout::FILL, | 252 cs->AddColumn(GridLayout::FILL, |
251 GridLayout::FILL, | 253 GridLayout::FILL, |
252 1, | 254 1, |
253 GridLayout::FIXED, | 255 GridLayout::FIXED, |
254 0, | 256 0, |
255 0); | 257 0); |
256 layout->StartRow(0, SYNC_PROMO_COLUMN_SET_ID); | 258 layout->StartRow(0, SYNC_PROMO_COLUMN_SET_ID); |
257 | 259 |
258 sync_promo_view_ = new BookmarkSyncPromoView(delegate_.get()); | 260 sync_promo_view_ = |
| 261 new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, |
| 262 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); |
259 layout->AddView(sync_promo_view_); | 263 layout->AddView(sync_promo_view_); |
260 } | 264 } |
261 | 265 |
262 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 266 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
263 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); | 267 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); |
264 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); | 268 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); |
265 } | 269 } |
266 | 270 |
267 const char* BookmarkBubbleView::GetClassName() const { | 271 const char* BookmarkBubbleView::GetClassName() const { |
268 return "BookmarkBubbleView"; | 272 return "BookmarkBubbleView"; |
269 } | 273 } |
270 | 274 |
271 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { | 275 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { |
272 return title_tf_; | 276 return title_tf_; |
273 } | 277 } |
274 | 278 |
275 BookmarkBubbleView::BookmarkBubbleView( | 279 BookmarkBubbleView::BookmarkBubbleView( |
276 views::View* anchor_view, | 280 views::View* anchor_view, |
277 bookmarks::BookmarkBubbleObserver* observer, | 281 bookmarks::BookmarkBubbleObserver* observer, |
278 scoped_ptr<BookmarkBubbleDelegate> delegate, | 282 scoped_ptr<BubbleSyncPromoDelegate> delegate, |
279 Profile* profile, | 283 Profile* profile, |
280 const GURL& url, | 284 const GURL& url, |
281 bool newly_bookmarked) | 285 bool newly_bookmarked) |
282 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 286 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
283 observer_(observer), | 287 observer_(observer), |
284 delegate_(delegate.Pass()), | 288 delegate_(delegate.Pass()), |
285 profile_(profile), | 289 profile_(profile), |
286 url_(url), | 290 url_(url), |
287 newly_bookmarked_(newly_bookmarked), | 291 newly_bookmarked_(newly_bookmarked), |
288 parent_model_( | 292 parent_model_(BookmarkModelFactory::GetForProfile(profile_), |
289 BookmarkModelFactory::GetForProfile(profile_), | 293 BookmarkModelFactory::GetForProfile(profile_) |
290 BookmarkModelFactory::GetForProfile(profile_)-> | 294 ->GetMostRecentlyAddedUserNodeForURL(url)), |
291 GetMostRecentlyAddedUserNodeForURL(url)), | |
292 remove_button_(NULL), | 295 remove_button_(NULL), |
293 edit_button_(NULL), | 296 edit_button_(NULL), |
294 close_button_(NULL), | 297 close_button_(NULL), |
295 title_tf_(NULL), | 298 title_tf_(NULL), |
296 parent_combobox_(NULL), | 299 parent_combobox_(NULL), |
297 sync_promo_view_(NULL), | 300 sync_promo_view_(NULL), |
298 remove_bookmark_(false), | 301 remove_bookmark_(false), |
299 apply_edits_(true) { | 302 apply_edits_(true) { |
300 set_margins(gfx::Insets(views::kPanelVertMargin, 0, 0, 0)); | 303 set_margins(gfx::Insets(views::kPanelVertMargin, 0, 0, 0)); |
301 // Compensate for built-in vertical padding in the anchor view's image. | 304 // Compensate for built-in vertical padding in the anchor view's image. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (node) { | 380 if (node) { |
378 const base::string16 new_title = title_tf_->text(); | 381 const base::string16 new_title = title_tf_->text(); |
379 if (new_title != node->GetTitle()) { | 382 if (new_title != node->GetTitle()) { |
380 model->SetTitle(node, new_title); | 383 model->SetTitle(node, new_title); |
381 content::RecordAction( | 384 content::RecordAction( |
382 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 385 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
383 } | 386 } |
384 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 387 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
385 } | 388 } |
386 } | 389 } |
OLD | NEW |