Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1289)

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 6685069: Disambiguate OnMouseCaptureLost from OnMouseReleased, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address most TODOs and sync. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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/location_bar/content_setting_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_setting_bubble_model.h" 9 #include "chrome/browser/content_setting_bubble_model.h"
10 #include "chrome/browser/content_setting_image_model.h" 10 #include "chrome/browser/content_setting_image_model.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 preferred_size.set_width(preferred_size.width() + visible_text_size_); 117 preferred_size.set_width(preferred_size.width() + visible_text_size_);
118 return preferred_size; 118 return preferred_size;
119 } 119 }
120 120
121 bool ContentSettingImageView::OnMousePressed(const views::MouseEvent& event) { 121 bool ContentSettingImageView::OnMousePressed(const views::MouseEvent& event) {
122 // We want to show the bubble on mouse release; that is the standard behavior 122 // We want to show the bubble on mouse release; that is the standard behavior
123 // for buttons. 123 // for buttons.
124 return true; 124 return true;
125 } 125 }
126 126
127 void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event, 127 void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
128 bool canceled) { 128 if (!HitTest(event.location()))
129 if (canceled || !HitTest(event.location()))
130 return; 129 return;
131 130
132 TabContents* tab_contents = parent_->GetTabContentsWrapper()->tab_contents(); 131 TabContents* tab_contents = parent_->GetTabContentsWrapper()->tab_contents();
133 if (!tab_contents) 132 if (!tab_contents)
134 return; 133 return;
135 134
136 // Prerender does not have a bubble. 135 // Prerender does not have a bubble.
137 ContentSettingsType content_settings_type = 136 ContentSettingsType content_settings_type =
138 content_setting_image_model_->get_content_settings_type(); 137 content_setting_image_model_->get_content_settings_type();
139 if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER) 138 if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER)
140 return; 139 return;
141 140
142 gfx::Rect screen_bounds(GetImageBounds()); 141 gfx::Rect screen_bounds(GetImageBounds());
143 gfx::Point origin(screen_bounds.origin()); 142 gfx::Point origin(screen_bounds.origin());
144 views::View::ConvertPointToScreen(this, &origin); 143 views::View::ConvertPointToScreen(this, &origin);
145 screen_bounds.set_origin(origin); 144 screen_bounds.set_origin(origin);
146 ContentSettingBubbleContents* bubble_contents = 145 ContentSettingBubbleContents* bubble_contents =
147 new ContentSettingBubbleContents( 146 new ContentSettingBubbleContents(
148 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 147 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
149 tab_contents, profile_, content_settings_type), 148 tab_contents, profile_, content_settings_type),
150 profile_, tab_contents); 149 profile_, tab_contents);
151 info_bubble_ = InfoBubble::Show(GetWidget(), screen_bounds, 150 info_bubble_ = InfoBubble::Show(GetWidget(), screen_bounds,
152 BubbleBorder::TOP_RIGHT, bubble_contents, this); 151 BubbleBorder::TOP_RIGHT, bubble_contents, this);
153 bubble_contents->set_info_bubble(info_bubble_); 152 bubble_contents->set_info_bubble(info_bubble_);
154 } 153 }
155 154
155 void ContentSettingImageView::InfoBubbleClosing(InfoBubble* info_bubble,
156 bool closed_by_escape) {
157 info_bubble_ = NULL;
158 }
159
160 bool ContentSettingImageView::CloseOnEscape() {
161 return true;
162 }
163
164 bool ContentSettingImageView::FadeInOnShow() {
165 return false;
166 }
167
156 void ContentSettingImageView::VisibilityChanged(View* starting_from, 168 void ContentSettingImageView::VisibilityChanged(View* starting_from,
157 bool is_visible) { 169 bool is_visible) {
158 if (!is_visible && info_bubble_) 170 if (!is_visible && info_bubble_)
159 info_bubble_->Close(); 171 info_bubble_->Close();
160 } 172 }
161 173
162 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) { 174 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) {
163 gfx::Insets current_insets; 175 gfx::Insets current_insets;
164 if (border()) 176 if (border())
165 border()->GetInsets(&current_insets); 177 border()->GetInsets(&current_insets);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 kBoxCornerRadius, paint); 223 kBoxCornerRadius, paint);
212 SkPaint outer_paint; 224 SkPaint outer_paint;
213 outer_paint.setStyle(SkPaint::kStroke_Style); 225 outer_paint.setStyle(SkPaint::kStroke_Style);
214 outer_paint.setColor(kBorderColor); 226 outer_paint.setColor(kBorderColor);
215 color_rect.inset(SkIntToScalar(kEdgeThickness), 227 color_rect.inset(SkIntToScalar(kEdgeThickness),
216 SkIntToScalar(kEdgeThickness)); 228 SkIntToScalar(kEdgeThickness));
217 canvas->AsCanvasSkia()->drawRoundRect(color_rect, kBoxCornerRadius, 229 canvas->AsCanvasSkia()->drawRoundRect(color_rect, kBoxCornerRadius,
218 kBoxCornerRadius, outer_paint); 230 kBoxCornerRadius, outer_paint);
219 } 231 }
220 232
221 void ContentSettingImageView::InfoBubbleClosing(InfoBubble* info_bubble,
222 bool closed_by_escape) {
223 info_bubble_ = NULL;
224 }
225
226 bool ContentSettingImageView::CloseOnEscape() {
227 return true;
228 }
229
230 bool ContentSettingImageView::FadeInOnShow() {
231 return false;
232 }
233
234 void ContentSettingImageView::AnimateToState(double state) { 233 void ContentSettingImageView::AnimateToState(double state) {
235 if (state >= 1.0) { 234 if (state >= 1.0) {
236 // Animaton is over, clear the variables. 235 // Animaton is over, clear the variables.
237 animation_in_progress_ = false; 236 animation_in_progress_ = false;
238 visible_text_size_ = 0; 237 visible_text_size_ = 0;
239 } else if (state < kAnimatingFraction) { 238 } else if (state < kAnimatingFraction) {
240 visible_text_size_ = static_cast<int>(text_size_ * state / 239 visible_text_size_ = static_cast<int>(text_size_ * state /
241 kAnimatingFraction); 240 kAnimatingFraction);
242 } else if (state > (1.0 - kAnimatingFraction)) { 241 } else if (state > (1.0 - kAnimatingFraction)) {
243 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) / 242 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) /
244 kAnimatingFraction); 243 kAnimatingFraction);
245 } else { 244 } else {
246 visible_text_size_ = text_size_; 245 visible_text_size_ = text_size_;
247 } 246 }
248 parent_->Layout(); 247 parent_->Layout();
249 parent_->SchedulePaint(); 248 parent_->SchedulePaint();
250 } 249 }
251 250
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698