| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/tooltip_icon.h" | 5 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "chrome/browser/ui/views/autofill/info_bubble.h" | 9 #include "chrome/browser/ui/views/autofill/info_bubble.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 private: | 47 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(TooltipBubble); | 48 DISALLOW_COPY_AND_ASSIGN(TooltipBubble); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 TooltipIcon::TooltipIcon(const base::string16& tooltip) | 53 TooltipIcon::TooltipIcon(const base::string16& tooltip) |
| 54 : tooltip_(tooltip), | 54 : tooltip_(tooltip), |
| 55 mouse_inside_(false), | 55 mouse_inside_(false), |
| 56 bubble_(NULL), | 56 bubble_(NULL), |
| 57 bubble_arrow_(views::BubbleBorder::TOP_RIGHT), |
| 57 observer_(this) { | 58 observer_(this) { |
| 58 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); | 59 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); |
| 59 } | 60 } |
| 60 | 61 |
| 61 TooltipIcon::~TooltipIcon() { | 62 TooltipIcon::~TooltipIcon() { |
| 62 HideBubble(); | 63 HideBubble(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 // static | 66 // static |
| 66 const char TooltipIcon::kViewClassName[] = "autofill/TooltipIcon"; | 67 const char TooltipIcon::kViewClassName[] = "autofill/TooltipIcon"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SetImage(rb.GetImageNamed(idr).ToImageSkia()); | 106 SetImage(rb.GetImageNamed(idr).ToImageSkia()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void TooltipIcon::ShowBubble() { | 109 void TooltipIcon::ShowBubble() { |
| 109 if (bubble_) | 110 if (bubble_) |
| 110 return; | 111 return; |
| 111 | 112 |
| 112 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON_H); | 113 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON_H); |
| 113 | 114 |
| 114 bubble_ = new TooltipBubble(this, tooltip_); | 115 bubble_ = new TooltipBubble(this, tooltip_); |
| 116 bubble_->set_arrow(bubble_arrow_); |
| 115 // When shown due to a gesture event, close on deactivate (i.e. don't use | 117 // When shown due to a gesture event, close on deactivate (i.e. don't use |
| 116 // "focusless"). | 118 // "focusless"). |
| 117 bubble_->set_can_activate(!mouse_inside_); | 119 bubble_->set_can_activate(!mouse_inside_); |
| 118 | 120 |
| 119 bubble_->Show(); | 121 bubble_->Show(); |
| 120 observer_.Add(bubble_->GetWidget()); | 122 observer_.Add(bubble_->GetWidget()); |
| 121 | 123 |
| 122 if (mouse_inside_) { | 124 if (mouse_inside_) { |
| 123 views::View* frame = bubble_->GetWidget()->non_client_view()->frame_view(); | 125 views::View* frame = bubble_->GetWidget()->non_client_view()->frame_view(); |
| 124 scoped_ptr<views::MouseWatcherHost> host( | 126 scoped_ptr<views::MouseWatcherHost> host( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 135 | 137 |
| 136 void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) { | 138 void TooltipIcon::OnWidgetDestroyed(views::Widget* widget) { |
| 137 observer_.Remove(widget); | 139 observer_.Remove(widget); |
| 138 | 140 |
| 139 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); | 141 ChangeImageTo(IDR_AUTOFILL_TOOLTIP_ICON); |
| 140 mouse_watcher_.reset(); | 142 mouse_watcher_.reset(); |
| 141 bubble_ = NULL; | 143 bubble_ = NULL; |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace autofill | 146 } // namespace autofill |
| OLD | NEW |