| 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/page_action_image_view.h" | 5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/platform_util.h" | 9 #include "chrome/browser/platform_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/sessions/session_tab_helper.h" | 11 #include "chrome/browser/sessions/session_tab_helper.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.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 "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 #include "ui/accessibility/ax_view_state.h" | 15 #include "ui/accessibility/ax_view_state.h" |
| 16 #include "ui/compositor/paint_context.h" |
| 16 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
| 17 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 19 | 20 |
| 20 // static | 21 // static |
| 21 const char PageActionImageView::kViewClassName[] = "PageActionImageView"; | 22 const char PageActionImageView::kViewClassName[] = "PageActionImageView"; |
| 22 | 23 |
| 23 PageActionImageView::PageActionImageView(LocationBarView* owner, | 24 PageActionImageView::PageActionImageView(LocationBarView* owner, |
| 24 ExtensionAction* page_action, | 25 ExtensionAction* page_action, |
| 25 Browser* browser) | 26 Browser* browser) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 SetTooltipText(base::UTF8ToUTF16(tooltip_)); | 101 SetTooltipText(base::UTF8ToUTF16(tooltip_)); |
| 101 | 102 |
| 102 // Set the image. | 103 // Set the image. |
| 103 gfx::Image icon = view_controller_->GetIcon(contents); | 104 gfx::Image icon = view_controller_->GetIcon(contents); |
| 104 if (!icon.IsEmpty()) | 105 if (!icon.IsEmpty()) |
| 105 SetImage(*icon.ToImageSkia()); | 106 SetImage(*icon.ToImageSkia()); |
| 106 | 107 |
| 107 SetVisible(true); | 108 SetVisible(true); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void PageActionImageView::PaintChildren(const PaintContext& context) { | 111 void PageActionImageView::PaintChildren(const ui::PaintContext& context) { |
| 111 View::PaintChildren(context); | 112 View::PaintChildren(context); |
| 112 int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents()); | 113 int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents()); |
| 113 if (tab_id >= 0) { | 114 if (tab_id >= 0) { |
| 114 gfx::Canvas* canvas = context.canvas(); | 115 gfx::Canvas* canvas = context.canvas(); |
| 115 view_controller_->extension_action()->PaintBadge( | 116 view_controller_->extension_action()->PaintBadge( |
| 116 canvas, GetLocalBounds(), tab_id); | 117 canvas, GetLocalBounds(), tab_id); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 | 120 |
| 120 void PageActionImageView::UpdateState() { | 121 void PageActionImageView::UpdateState() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 return this; | 147 return this; |
| 147 } | 148 } |
| 148 | 149 |
| 149 views::MenuButton* PageActionImageView::GetContextMenuButton() { | 150 views::MenuButton* PageActionImageView::GetContextMenuButton() { |
| 150 return NULL; // No menu button for page action views. | 151 return NULL; // No menu button for page action views. |
| 151 } | 152 } |
| 152 | 153 |
| 153 content::WebContents* PageActionImageView::GetCurrentWebContents() const { | 154 content::WebContents* PageActionImageView::GetCurrentWebContents() const { |
| 154 return owner_->GetWebContents(); | 155 return owner_->GetWebContents(); |
| 155 } | 156 } |
| OLD | NEW |