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/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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
13 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 13 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
15 #include "chrome/browser/ui/views/window.h" | 15 #include "chrome/browser/ui/views/window.h" |
| 16 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "third_party/skia/include/core/SkShader.h" | 18 #include "third_party/skia/include/core/SkShader.h" |
18 #include "ui/base/animation/slide_animation.h" | 19 #include "ui/base/animation/slide_animation.h" |
19 #include "ui/base/animation/tween.h" | 20 #include "ui/base/animation/tween.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/canvas_skia.h" | 24 #include "ui/gfx/canvas_skia.h" |
24 #include "ui/gfx/skia_util.h" | 25 #include "ui/gfx/skia_util.h" |
25 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
26 | 27 |
| 28 using content::NavigationController; |
27 using content::WebContents; | 29 using content::WebContents; |
28 | 30 |
29 namespace { | 31 namespace { |
30 // Animation parameters. | 32 // Animation parameters. |
31 const int kOpenTimeMs = 150; | 33 const int kOpenTimeMs = 150; |
32 const int kFullOpenedTimeMs = 3200; | 34 const int kFullOpenedTimeMs = 3200; |
33 const int kMoveTimeMs = kFullOpenedTimeMs + 2 * kOpenTimeMs; | 35 const int kMoveTimeMs = kFullOpenedTimeMs + 2 * kOpenTimeMs; |
34 const int kFrameRateHz = 60; | 36 const int kFrameRateHz = 60; |
35 // Colors for the animated box. | 37 // Colors for the animated box. |
36 const SkColor kTopBoxColor = SkColorSetRGB(0xff, 0xf8, 0xd4); | 38 const SkColor kTopBoxColor = SkColorSetRGB(0xff, 0xf8, 0xd4); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 159 } |
158 | 160 |
159 void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) { | 161 void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) { |
160 if (!HitTest(event.location())) | 162 if (!HitTest(event.location())) |
161 return; | 163 return; |
162 | 164 |
163 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); | 165 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); |
164 if (!tab_contents) | 166 if (!tab_contents) |
165 return; | 167 return; |
166 | 168 |
167 Profile* profile = parent_->browser()->profile(); | 169 Browser* browser = parent_->FindBrowser(); |
| 170 if (!browser) |
| 171 return; |
| 172 |
| 173 Profile* profile = browser->profile(); |
168 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( | 174 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( |
169 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 175 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
170 parent_->browser(), | 176 browser, |
171 tab_contents, | 177 tab_contents, |
172 profile, | 178 profile, |
173 content_setting_image_model_->get_content_settings_type()), | 179 content_setting_image_model_->get_content_settings_type()), |
174 profile, | 180 profile, |
175 tab_contents->web_contents(), | 181 tab_contents->web_contents(), |
176 this, | 182 this, |
177 views::BubbleBorder::TOP_RIGHT); | 183 views::BubbleBorder::TOP_RIGHT); |
178 browser::CreateViewsBubble(bubble); | 184 browser::CreateViewsBubble(bubble); |
179 bubble->Show(); | 185 bubble->Show(); |
180 } | 186 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 canvas->GetSkCanvas()->drawRoundRect(color_rect, kBoxCornerRadius, | 233 canvas->GetSkCanvas()->drawRoundRect(color_rect, kBoxCornerRadius, |
228 kBoxCornerRadius, paint); | 234 kBoxCornerRadius, paint); |
229 SkPaint outer_paint; | 235 SkPaint outer_paint; |
230 outer_paint.setStyle(SkPaint::kStroke_Style); | 236 outer_paint.setStyle(SkPaint::kStroke_Style); |
231 outer_paint.setColor(kBorderColor); | 237 outer_paint.setColor(kBorderColor); |
232 color_rect.inset(SkIntToScalar(kEdgeThickness), | 238 color_rect.inset(SkIntToScalar(kEdgeThickness), |
233 SkIntToScalar(kEdgeThickness)); | 239 SkIntToScalar(kEdgeThickness)); |
234 canvas->GetSkCanvas()->drawRoundRect(color_rect, kBoxCornerRadius, | 240 canvas->GetSkCanvas()->drawRoundRect(color_rect, kBoxCornerRadius, |
235 kBoxCornerRadius, outer_paint); | 241 kBoxCornerRadius, outer_paint); |
236 } | 242 } |
OLD | NEW |