OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string16.h" | 7 #include "base/string16.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/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_editor.h" | 11 #include "chrome/browser/bookmarks/bookmark_editor.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/views/bubble/bubble.h" | 17 #include "chrome/browser/ui/views/bubble/bubble.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "content/browser/user_metrics.h" | 19 #include "content/browser/user_metrics.h" |
19 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "ui/base/keycodes/keyboard_codes.h" | 23 #include "ui/base/keycodes/keyboard_codes.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
26 #include "ui/gfx/color_utils.h" | 27 #include "ui/gfx/color_utils.h" |
27 #include "views/controls/button/text_button.h" | 28 #include "views/controls/button/text_button.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // asynchronously. However, that can happen during the Show call above if the | 98 // asynchronously. However, that can happen during the Show call above if the |
98 // window loses activation while we are getting to ready to show the bubble, | 99 // window loses activation while we are getting to ready to show the bubble, |
99 // so we must check to make sure we still have a valid bubble before | 100 // so we must check to make sure we still have a valid bubble before |
100 // proceeding. | 101 // proceeding. |
101 if (!bookmark_bubble_) | 102 if (!bookmark_bubble_) |
102 return; | 103 return; |
103 bookmark_bubble_->set_bubble(bubble); | 104 bookmark_bubble_->set_bubble(bubble); |
104 bubble->SizeToContents(); | 105 bubble->SizeToContents(); |
105 GURL url_ptr(url); | 106 GURL url_ptr(url); |
106 NotificationService::current()->Notify( | 107 NotificationService::current()->Notify( |
107 NotificationType::BOOKMARK_BUBBLE_SHOWN, | 108 chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, |
108 Source<Profile>(profile->GetOriginalProfile()), | 109 Source<Profile>(profile->GetOriginalProfile()), |
109 Details<GURL>(&url_ptr)); | 110 Details<GURL>(&url_ptr)); |
110 bookmark_bubble_->BubbleShown(); | 111 bookmark_bubble_->BubbleShown(); |
111 } | 112 } |
112 | 113 |
113 // static | 114 // static |
114 bool BookmarkBubbleView::IsShowing() { | 115 bool BookmarkBubbleView::IsShowing() { |
115 return bookmark_bubble_ != NULL; | 116 return bookmark_bubble_ != NULL; |
116 } | 117 } |
117 | 118 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 } | 319 } |
319 | 320 |
320 // We have to reset |bubble_| here, not in our destructor, because we'll be | 321 // We have to reset |bubble_| here, not in our destructor, because we'll be |
321 // destroyed asynchronously and the shown state will be checked before then. | 322 // destroyed asynchronously and the shown state will be checked before then. |
322 DCHECK(bookmark_bubble_ == this); | 323 DCHECK(bookmark_bubble_ == this); |
323 bookmark_bubble_ = NULL; | 324 bookmark_bubble_ = NULL; |
324 | 325 |
325 if (delegate_) | 326 if (delegate_) |
326 delegate_->BubbleClosing(bubble, closed_by_escape); | 327 delegate_->BubbleClosing(bubble, closed_by_escape); |
327 NotificationService::current()->Notify( | 328 NotificationService::current()->Notify( |
328 NotificationType::BOOKMARK_BUBBLE_HIDDEN, | 329 chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, |
329 Source<Profile>(profile_->GetOriginalProfile()), | 330 Source<Profile>(profile_->GetOriginalProfile()), |
330 NotificationService::NoDetails()); | 331 NotificationService::NoDetails()); |
331 } | 332 } |
332 | 333 |
333 bool BookmarkBubbleView::CloseOnEscape() { | 334 bool BookmarkBubbleView::CloseOnEscape() { |
334 return delegate_ ? delegate_->CloseOnEscape() : true; | 335 return delegate_ ? delegate_->CloseOnEscape() : true; |
335 } | 336 } |
336 | 337 |
337 bool BookmarkBubbleView::FadeInOnShow() { | 338 bool BookmarkBubbleView::FadeInOnShow() { |
338 return false; | 339 return false; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 const BookmarkNode* new_parent = | 422 const BookmarkNode* new_parent = |
422 parent_model_.GetNodeAt(parent_combobox_->selected_item()); | 423 parent_model_.GetNodeAt(parent_combobox_->selected_item()); |
423 if (new_parent != node->parent()) { | 424 if (new_parent != node->parent()) { |
424 UserMetrics::RecordAction( | 425 UserMetrics::RecordAction( |
425 UserMetricsAction("BookmarkBubble_ChangeParent")); | 426 UserMetricsAction("BookmarkBubble_ChangeParent")); |
426 model->Move(node, new_parent, new_parent->child_count()); | 427 model->Move(node, new_parent, new_parent->child_count()); |
427 } | 428 } |
428 } | 429 } |
429 } | 430 } |
430 } | 431 } |
OLD | NEW |