Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/browser/extensions/extension_uninstall_dialog.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: License year update Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/extensions/extension_uninstall_dialog.h" 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/common/extensions/api/icons/icons_handler.h"
10 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_constants.h" 12 #include "chrome/common/extensions/extension_constants.h"
12 #include "chrome/common/extensions/extension_icon_set.h" 13 #include "chrome/common/extensions/extension_icon_set.h"
13 #include "chrome/common/extensions/extension_resource.h" 14 #include "chrome/common/extensions/extension_resource.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
16 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 21
21 namespace { 22 namespace {
22 23
23 // Returns pixel size under maximal scale factor for the icon whose device 24 // Returns pixel size under maximal scale factor for the icon whose device
24 // independent size is |size_in_dip| 25 // independent size is |size_in_dip|
25 int GetSizeForMaxScaleFactor(int size_in_dip) { 26 int GetSizeForMaxScaleFactor(int size_in_dip) {
26 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); 27 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor();
27 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); 28 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor);
28 29
29 return static_cast<int>(size_in_dip * max_scale_factor_scale); 30 return static_cast<int>(size_in_dip * max_scale_factor_scale);
30 } 31 }
31 32
32 // Returns bitmap for the default icon with size equal to the default icon's 33 // Returns bitmap for the default icon with size equal to the default icon's
33 // pixel size under maximal supported scale factor. 34 // pixel size under maximal supported scale factor.
34 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 35 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
35 return extensions::Extension::GetDefaultIcon(is_app). 36 return extensions::IconsInfo::GetDefaultIcon(is_app).
36 GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); 37 GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap();
37 } 38 }
38 39
39 } // namespace 40 } // namespace
40 41
41 // Size of extension icon in top left of dialog. 42 // Size of extension icon in top left of dialog.
42 static const int kIconSize = 69; 43 static const int kIconSize = 69;
43 44
44 ExtensionUninstallDialog::ExtensionUninstallDialog( 45 ExtensionUninstallDialog::ExtensionUninstallDialog(
45 Browser* browser, 46 Browser* browser,
(...skipping 10 matching lines...) Expand all
56 } 57 }
57 58
58 ExtensionUninstallDialog::~ExtensionUninstallDialog() { 59 ExtensionUninstallDialog::~ExtensionUninstallDialog() {
59 } 60 }
60 61
61 void ExtensionUninstallDialog::ConfirmUninstall( 62 void ExtensionUninstallDialog::ConfirmUninstall(
62 const extensions::Extension* extension) { 63 const extensions::Extension* extension) {
63 DCHECK(ui_loop_ == MessageLoop::current()); 64 DCHECK(ui_loop_ == MessageLoop::current());
64 extension_ = extension; 65 extension_ = extension;
65 66
66 ExtensionResource image = 67 ExtensionResource image = extensions::IconsInfo::GetIconResource(
67 extension_->GetIconResource(extension_misc::EXTENSION_ICON_LARGE, 68 extension,
68 ExtensionIconSet::MATCH_BIGGER); 69 extension_misc::EXTENSION_ICON_LARGE,
70 ExtensionIconSet::MATCH_BIGGER);
69 // Load the image asynchronously. The response will be sent to OnImageLoaded. 71 // Load the image asynchronously. The response will be sent to OnImageLoaded.
70 tracker_.reset(new ImageLoadingTracker(this)); 72 tracker_.reset(new ImageLoadingTracker(this));
71 // Load the icon whose pixel size is large enough to be displayed under 73 // Load the icon whose pixel size is large enough to be displayed under
72 // maximal supported scale factor. UI code will scale the icon down if needed. 74 // maximal supported scale factor. UI code will scale the icon down if needed.
73 int pixel_size = GetSizeForMaxScaleFactor(kIconSize); 75 int pixel_size = GetSizeForMaxScaleFactor(kIconSize);
74 tracker_->LoadImage(extension_, image, 76 tracker_->LoadImage(extension_, image,
75 gfx::Size(pixel_size, pixel_size), 77 gfx::Size(pixel_size, pixel_size),
76 ImageLoadingTracker::DONT_CACHE); 78 ImageLoadingTracker::DONT_CACHE);
77 } 79 }
78 80
(...skipping 30 matching lines...) Expand all
109 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING); 111 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING);
110 112
111 browser_ = NULL; 113 browser_ = NULL;
112 if (tracker_.get()) { 114 if (tracker_.get()) {
113 // If we're waiting for the icon, stop doing so because we're not going to 115 // If we're waiting for the icon, stop doing so because we're not going to
114 // show the dialog. 116 // show the dialog.
115 tracker_.reset(); 117 tracker_.reset();
116 delegate_->ExtensionUninstallCanceled(); 118 delegate_->ExtensionUninstallCanceled();
117 } 119 }
118 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698