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

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

Issue 256022: Loads local resources from current locale subtree if available, if not it fal... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_disabled_infobar_delegate.h" 5 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_file_util.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 11 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extensions_service.h" 12 #include "chrome/browser/extensions/extensions_service.h"
12 #include "chrome/browser/tab_contents/infobar_delegate.h" 13 #include "chrome/browser/tab_contents/infobar_delegate.h"
13 #include "chrome/browser/tab_contents/tab_contents.h" 14 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "chrome/browser/browser_list.h" 15 #include "chrome/browser/browser_list.h"
16 #include "chrome/common/extensions/extension_resource.h"
15 #include "chrome/common/notification_registrar.h" 17 #include "chrome/common/notification_registrar.h"
16 #include "chrome/common/notification_service.h" 18 #include "chrome/common/notification_service.h"
17 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
18 20
19 class ExtensionDisabledDialogDelegate 21 class ExtensionDisabledDialogDelegate
20 : public ExtensionInstallUI::Delegate, 22 : public ExtensionInstallUI::Delegate,
21 public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> { 23 public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> {
22 public: 24 public:
23 ExtensionDisabledDialogDelegate(Profile* profile, 25 ExtensionDisabledDialogDelegate(Profile* profile,
24 ExtensionsService* service, 26 ExtensionsService* service,
25 Extension* extension) 27 Extension* extension)
26 : profile_(profile), service_(service), extension_(extension), 28 : profile_(profile), service_(service), extension_(extension),
27 ui_loop_(MessageLoop::current()) { 29 ui_loop_(MessageLoop::current()) {
28 AddRef(); // balanced in ContinueInstall or AbortInstall. 30 AddRef(); // balanced in ContinueInstall or AbortInstall.
29 31
30 // Do this now because we can't touch extension on the file loop. 32 // Do this now because we can't touch extension on the file loop.
31 install_icon_path_ = 33 install_icon_resource_ =
32 extension_->GetIconPath(Extension::EXTENSION_ICON_LARGE); 34 extension_->GetIconPath(Extension::EXTENSION_ICON_LARGE);
33 35
34 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, 36 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE,
35 NewRunnableMethod(this, &ExtensionDisabledDialogDelegate::Start)); 37 NewRunnableMethod(this, &ExtensionDisabledDialogDelegate::Start));
36 } 38 }
37 39
38 // ExtensionInstallUI::Delegate 40 // ExtensionInstallUI::Delegate
39 virtual void ContinueInstall() { 41 virtual void ContinueInstall() {
40 service_->EnableExtension(extension_->id()); 42 service_->EnableExtension(extension_->id());
41 Release(); 43 Release();
42 } 44 }
43 virtual void AbortInstall() { 45 virtual void AbortInstall() {
44 // Do nothing. The extension will remain disabled. 46 // Do nothing. The extension will remain disabled.
45 Release(); 47 Release();
46 } 48 }
47 49
48 private: 50 private:
49 void Start() { 51 void Start() {
50 // We start on the file thread so we can decode the install icon. 52 // We start on the file thread so we can decode the install icon.
51 CrxInstaller::DecodeInstallIcon(install_icon_path_, &install_icon_); 53 FilePath install_icon_path = install_icon_resource_.GetFilePath();
54 CrxInstaller::DecodeInstallIcon(install_icon_path, &install_icon_);
52 // Then we display the UI on the UI thread. 55 // Then we display the UI on the UI thread.
53 ui_loop_->PostTask(FROM_HERE, 56 ui_loop_->PostTask(FROM_HERE,
54 NewRunnableMethod(this, 57 NewRunnableMethod(this,
55 &ExtensionDisabledDialogDelegate::ConfirmInstall)); 58 &ExtensionDisabledDialogDelegate::ConfirmInstall));
56 } 59 }
57 60
58 void ConfirmInstall() { 61 void ConfirmInstall() {
59 DCHECK(MessageLoop::current() == ui_loop_); 62 DCHECK(MessageLoop::current() == ui_loop_);
60 ExtensionInstallUI ui(profile_); 63 ExtensionInstallUI ui(profile_);
61 ui.ConfirmInstall(this, extension_, install_icon_.get()); 64 ui.ConfirmInstall(this, extension_, install_icon_.get());
62 } 65 }
63 66
64 Profile* profile_; 67 Profile* profile_;
65 ExtensionsService* service_; 68 ExtensionsService* service_;
66 Extension* extension_; 69 Extension* extension_;
67 FilePath install_icon_path_; 70 ExtensionResource install_icon_resource_;
68 scoped_ptr<SkBitmap> install_icon_; 71 scoped_ptr<SkBitmap> install_icon_;
69 MessageLoop* ui_loop_; 72 MessageLoop* ui_loop_;
70 }; 73 };
71 74
72 class ExtensionDisabledInfobarDelegate 75 class ExtensionDisabledInfobarDelegate
73 : public ConfirmInfoBarDelegate, 76 : public ConfirmInfoBarDelegate,
74 public NotificationObserver { 77 public NotificationObserver {
75 public: 78 public:
76 ExtensionDisabledInfobarDelegate(TabContents* tab_contents, 79 ExtensionDisabledInfobarDelegate(TabContents* tab_contents,
77 ExtensionsService* service, 80 ExtensionsService* service,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!browser) 144 if (!browser)
142 return; 145 return;
143 146
144 TabContents* tab_contents = browser->GetSelectedTabContents(); 147 TabContents* tab_contents = browser->GetSelectedTabContents();
145 if (!tab_contents) 148 if (!tab_contents)
146 return; 149 return;
147 150
148 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( 151 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate(
149 tab_contents, service, extension)); 152 tab_contents, service, extension));
150 } 153 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/execute_code_in_tab_function.cc ('k') | chrome/browser/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698