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

Side by Side Diff: chrome/browser/chromeos/ui/screensaver_extension_dialog.cc

Issue 10191010: Re-implement the screensaver to use WebView instead of ExtensionDialogHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ut fix. Created 8 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/ui/screensaver_extension_dialog.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/sessions/restore_tab_helper.h"
15 #include "chrome/browser/ui/views/extensions/extension_dialog.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_file_util.h"
19
20 using content::BrowserThread;
21
22 namespace {
23
24 ScreensaverExtensionDialog* g_instance = NULL;
25
26 } // namespace
27
28 namespace browser {
29
30 void ShowScreensaverDialog(scoped_refptr<Extension> extension) {
31 ScreensaverExtensionDialog::ShowScreensaverDialog(extension);
32 }
33
34 void CloseScreensaverDialog() {
35 ScreensaverExtensionDialog::CloseScreensaverDialog();
36 }
37
38 } // namespace browser
39
40 // static
41 void ScreensaverExtensionDialog::ShowScreensaverDialog(
42 scoped_refptr<Extension> extension) {
43 if (!g_instance)
44 g_instance = new ScreensaverExtensionDialog(extension);
45 g_instance->Show();
46 }
47
48 // static
49 void ScreensaverExtensionDialog::CloseScreensaverDialog() {
50 if (g_instance)
51 g_instance->Close();
52 }
53
54 ScreensaverExtensionDialog::ScreensaverExtensionDialog(
55 scoped_refptr<Extension> extension)
56 : screensaver_extension_(extension) {
57 }
58
59 void ScreensaverExtensionDialog::Show() {
60 if (!screensaver_extension_)
61 return;
62
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 Profile* default_profile = ProfileManager::GetDefaultProfile();
65 default_profile->GetExtensionService()->AddExtension(screensaver_extension_);
66 extension_dialog_ = ExtensionDialog::ShowFullscreen(
67 screensaver_extension_->GetFullLaunchURL(),
68 default_profile,
69 string16(),
70 this);
71 }
72
73 void ScreensaverExtensionDialog::Close() {
74 if (extension_dialog_) {
75 extension_dialog_->Close();
76 extension_dialog_ = NULL;
77 }
78 }
79
80 ScreensaverExtensionDialog::~ScreensaverExtensionDialog() {
81 if (extension_dialog_)
82 extension_dialog_->ObserverDestroyed();
83 }
84
85 void ScreensaverExtensionDialog::ExtensionDialogClosing(
86 ExtensionDialog* dialog) {
87 // Release our reference to the dialog to allow it to close.
88 extension_dialog_ = NULL;
89 }
90
91 void ScreensaverExtensionDialog::ExtensionTerminated(
92 ExtensionDialog* dialog) {
93 // This needs to be run 'slightly' delayed. When we get the extension
94 // terminated notification, the extension isn't fully unloaded yet. There
95 // is no good way to get around this. The correct solution will be to
96 // not need to reload the extension at all - but the current wiring in
97 // ExtensionViewsHost makes that not possible.
98 MessageLoop::current()->PostTask(FROM_HERE,
99 base::Bind(&ScreensaverExtensionDialog::ReloadAndShow,
100 base::Unretained(this)));
101 dialog->Close();
102 }
103
104 void ScreensaverExtensionDialog::ReloadAndShow() {
105 ProfileManager::GetDefaultProfile()->GetExtensionService()->ReloadExtension(
106 screensaver_extension_->id());
107
108 Show();
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698