| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/extensions/extension_shelf.h" | 5 #include "chrome/browser/views/extensions/extension_shelf.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
| 15 #include "chrome/browser/browser_theme_provider.h" | 15 #include "chrome/browser/browser_theme_provider.h" |
| 16 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
| 17 #include "chrome/browser/extensions/extension_process_manager.h" | 17 #include "chrome/browser/extensions/extension_process_manager.h" |
| 18 #include "chrome/browser/extensions/extensions_service.h" | 18 #include "chrome/browser/extensions/extensions_service.h" |
| 19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "chrome/browser/views/extensions/extension_view.h" | 21 #include "chrome/browser/views/extensions/extension_view.h" |
| 22 #include "chrome/browser/view_ids.h" | 22 #include "chrome/browser/view_ids.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "gfx/canvas_skia.h" |
| 27 #include "views/controls/label.h" | 28 #include "views/controls/label.h" |
| 28 #include "views/screen.h" | 29 #include "views/screen.h" |
| 29 #include "views/widget/root_view.h" | 30 #include "views/widget/root_view.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // This is the slight padding that is there around the edge of the browser. This | 34 // This is the slight padding that is there around the edge of the browser. This |
| 34 // has been determined empirically. | 35 // has been determined empirically. |
| 35 // TODO(sidchat): Compute this value from the root view of the extension shelf. | 36 // TODO(sidchat): Compute this value from the root view of the extension shelf. |
| 36 static const int kExtensionShelfPaddingOnLeft = 4; | 37 static const int kExtensionShelfPaddingOnLeft = 4; |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 SkIntToScalar(0), | 936 SkIntToScalar(0), |
| 936 SkIntToScalar(width()), | 937 SkIntToScalar(width()), |
| 937 SkIntToScalar(height()) | 938 SkIntToScalar(height()) |
| 938 }; | 939 }; |
| 939 | 940 |
| 940 // Tell all extension views about the new background. | 941 // Tell all extension views about the new background. |
| 941 int count = model_->count(); | 942 int count = model_->count(); |
| 942 for (int i = 0; i < count; ++i) { | 943 for (int i = 0; i < count; ++i) { |
| 943 ExtensionView* view = ToolstripAtIndex(i)->view(); | 944 ExtensionView* view = ToolstripAtIndex(i)->view(); |
| 944 | 945 |
| 945 const SkBitmap& background = canvas->getDevice()->accessBitmap(false); | 946 const SkBitmap& background = |
| 947 canvas->AsCanvasSkia()->getDevice()->accessBitmap(false); |
| 946 | 948 |
| 947 SkRect mapped_subset = background_rect; | 949 SkRect mapped_subset = background_rect; |
| 948 gfx::Rect view_bounds = view->bounds(); | 950 gfx::Rect view_bounds = view->bounds(); |
| 949 mapped_subset.offset(SkIntToScalar(view_bounds.x()), | 951 mapped_subset.offset(SkIntToScalar(view_bounds.x()), |
| 950 SkIntToScalar(view_bounds.y())); | 952 SkIntToScalar(view_bounds.y())); |
| 951 bool result = canvas->getTotalMatrix().mapRect(&mapped_subset); | 953 bool result = |
| 954 canvas->AsCanvasSkia()->getTotalMatrix().mapRect(&mapped_subset); |
| 952 DCHECK(result); | 955 DCHECK(result); |
| 953 | 956 |
| 954 SkIRect isubset; | 957 SkIRect isubset; |
| 955 mapped_subset.round(&isubset); | 958 mapped_subset.round(&isubset); |
| 956 SkBitmap subset_bitmap; | 959 SkBitmap subset_bitmap; |
| 957 // This will create another bitmap that just references pixels in the | 960 // This will create another bitmap that just references pixels in the |
| 958 // actual bitmap. | 961 // actual bitmap. |
| 959 result = background.extractSubset(&subset_bitmap, isubset); | 962 result = background.extractSubset(&subset_bitmap, isubset); |
| 960 if (!result) | 963 if (!result) |
| 961 return; | 964 return; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 } | 1098 } |
| 1096 | 1099 |
| 1097 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) { | 1100 void ExtensionShelf::OnFullscreenToggled(bool fullscreen) { |
| 1098 if (fullscreen == fullscreen_) | 1101 if (fullscreen == fullscreen_) |
| 1099 return; | 1102 return; |
| 1100 fullscreen_ = fullscreen; | 1103 fullscreen_ = fullscreen; |
| 1101 if (!IsAlwaysShown()) | 1104 if (!IsAlwaysShown()) |
| 1102 return; | 1105 return; |
| 1103 size_animation_->Reset(fullscreen ? 0 : 1); | 1106 size_animation_->Reset(fullscreen ? 0 : 1); |
| 1104 } | 1107 } |
| OLD | NEW |