| 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/compositor/paint_context.h" |
| 17 #include "ui/compositor/paint_recorder.h" |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 const char PageActionImageView::kViewClassName[] = "PageActionImageView"; | 23 const char PageActionImageView::kViewClassName[] = "PageActionImageView"; |
| 23 | 24 |
| 24 PageActionImageView::PageActionImageView(LocationBarView* owner, | 25 PageActionImageView::PageActionImageView(LocationBarView* owner, |
| 25 ExtensionAction* page_action, | 26 ExtensionAction* page_action, |
| 26 Browser* browser) | 27 Browser* browser) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (!icon.IsEmpty()) | 106 if (!icon.IsEmpty()) |
| 106 SetImage(*icon.ToImageSkia()); | 107 SetImage(*icon.ToImageSkia()); |
| 107 | 108 |
| 108 SetVisible(true); | 109 SetVisible(true); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void PageActionImageView::PaintChildren(const ui::PaintContext& context) { | 112 void PageActionImageView::PaintChildren(const ui::PaintContext& context) { |
| 112 View::PaintChildren(context); | 113 View::PaintChildren(context); |
| 113 int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents()); | 114 int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents()); |
| 114 if (tab_id >= 0) { | 115 if (tab_id >= 0) { |
| 115 gfx::Canvas* canvas = context.canvas(); | 116 ui::PaintRecorder recorder(context); |
| 116 view_controller_->extension_action()->PaintBadge( | 117 view_controller_->extension_action()->PaintBadge(recorder.canvas(), |
| 117 canvas, GetLocalBounds(), tab_id); | 118 GetLocalBounds(), tab_id); |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 void PageActionImageView::UpdateState() { | 122 void PageActionImageView::UpdateState() { |
| 122 UpdateVisibility(GetCurrentWebContents()); | 123 UpdateVisibility(GetCurrentWebContents()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 views::View* PageActionImageView::GetAsView() { | 126 views::View* PageActionImageView::GetAsView() { |
| 126 return this; | 127 return this; |
| 127 } | 128 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 147 return this; | 148 return this; |
| 148 } | 149 } |
| 149 | 150 |
| 150 views::MenuButton* PageActionImageView::GetContextMenuButton() { | 151 views::MenuButton* PageActionImageView::GetContextMenuButton() { |
| 151 return NULL; // No menu button for page action views. | 152 return NULL; // No menu button for page action views. |
| 152 } | 153 } |
| 153 | 154 |
| 154 content::WebContents* PageActionImageView::GetCurrentWebContents() const { | 155 content::WebContents* PageActionImageView::GetCurrentWebContents() const { |
| 155 return owner_->GetWebContents(); | 156 return owner_->GetWebContents(); |
| 156 } | 157 } |
| OLD | NEW |