| 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/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/ui/content_settings/content_setting_bubble_model.h" |
| 10 #include "chrome/browser/content_setting_image_model.h" | 10 #include "chrome/browser/ui/content_settings/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" |
| 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
| 16 #include "third_party/skia/include/core/SkShader.h" | 16 #include "third_party/skia/include/core/SkShader.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/canvas_skia.h" | 20 #include "ui/gfx/canvas_skia.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (!HitTest(event.location())) | 128 if (!HitTest(event.location())) |
| 129 return; | 129 return; |
| 130 | 130 |
| 131 TabContents* tab_contents = parent_->GetTabContentsWrapper()->tab_contents(); | 131 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); |
| 132 if (!tab_contents) | 132 if (!tab_contents) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 // Prerender does not have a bubble. | 135 // Prerender does not have a bubble. |
| 136 ContentSettingsType content_settings_type = | 136 ContentSettingsType content_settings_type = |
| 137 content_setting_image_model_->get_content_settings_type(); | 137 content_setting_image_model_->get_content_settings_type(); |
| 138 if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER) | 138 if (content_settings_type == CONTENT_SETTINGS_TYPE_PRERENDER) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 gfx::Rect screen_bounds(GetImageBounds()); | 141 gfx::Rect screen_bounds(GetImageBounds()); |
| 142 gfx::Point origin(screen_bounds.origin()); | 142 gfx::Point origin(screen_bounds.origin()); |
| 143 views::View::ConvertPointToScreen(this, &origin); | 143 views::View::ConvertPointToScreen(this, &origin); |
| 144 screen_bounds.set_origin(origin); | 144 screen_bounds.set_origin(origin); |
| 145 ContentSettingBubbleContents* bubble_contents = | 145 ContentSettingBubbleContents* bubble_contents = |
| 146 new ContentSettingBubbleContents( | 146 new ContentSettingBubbleContents( |
| 147 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 147 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 148 tab_contents, profile_, content_settings_type), | 148 tab_contents, profile_, content_settings_type), |
| 149 profile_, tab_contents); | 149 profile_, tab_contents->tab_contents()); |
| 150 bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT, | 150 bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT, |
| 151 bubble_contents, this); | 151 bubble_contents, this); |
| 152 bubble_contents->set_bubble(bubble_); | 152 bubble_contents->set_bubble(bubble_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ContentSettingImageView::VisibilityChanged(View* starting_from, | 155 void ContentSettingImageView::VisibilityChanged(View* starting_from, |
| 156 bool is_visible) { | 156 bool is_visible) { |
| 157 if (!is_visible && bubble_) | 157 if (!is_visible && bubble_) |
| 158 bubble_->Close(); | 158 bubble_->Close(); |
| 159 } | 159 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } else if (state > (1.0 - kAnimatingFraction)) { | 241 } else if (state > (1.0 - kAnimatingFraction)) { |
| 242 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) / | 242 visible_text_size_ = static_cast<int>(text_size_ * (1.0 - state) / |
| 243 kAnimatingFraction); | 243 kAnimatingFraction); |
| 244 } else { | 244 } else { |
| 245 visible_text_size_ = text_size_; | 245 visible_text_size_ = text_size_; |
| 246 } | 246 } |
| 247 parent_->Layout(); | 247 parent_->Layout(); |
| 248 parent_->SchedulePaint(); | 248 parent_->SchedulePaint(); |
| 249 } | 249 } |
| 250 | 250 |
| OLD | NEW |