blob: 86df3469df5b48595f2274d0ebfd4d7cd67eaa63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h"
#include "base/message_loop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h"
#import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"
namespace {
void ShowExtensionInstallDialogImpl(
content::WebContents* parent_web_contents,
ExtensionInstallPrompt::Delegate* delegate,
const ExtensionInstallPrompt::Prompt& prompt) {
// This object will delete itself when the dialog closes.
new ExtensionInstallDialogController(parent_web_contents,
delegate,
prompt);
}
} // namespace
ExtensionInstallDialogController::ExtensionInstallDialogController(
content::WebContents* web_contents,
ExtensionInstallPrompt::Delegate* delegate,
const ExtensionInstallPrompt::Prompt& prompt) : delegate_(delegate) {
view_controller_.reset([[ExtensionInstallViewController alloc]
initWithNavigator:web_contents
delegate:this
prompt:prompt]);
scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc]
initWithContentRect:[[view_controller_ view] bounds]]);
[[window contentView] addSubview:[view_controller_ view]];
constrained_window_.reset(new ConstrainedWindowMac2(
this, web_contents, window));
}
ExtensionInstallDialogController::~ExtensionInstallDialogController() {
}
void ExtensionInstallDialogController::InstallUIProceed() {
delegate_->InstallUIProceed();
delegate_ = NULL;
constrained_window_->CloseConstrainedWindow();
}
void ExtensionInstallDialogController::InstallUIAbort(bool user_initiated) {
delegate_->InstallUIAbort(user_initiated);
delegate_ = NULL;
constrained_window_->CloseConstrainedWindow();
}
void ExtensionInstallDialogController::OnConstrainedWindowClosed(
ConstrainedWindowMac2* window) {
if (delegate_)
delegate_->InstallUIAbort(false);
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
// static
ExtensionInstallPrompt::ShowDialogCallback
ExtensionInstallPrompt::GetDefaultShowDialogCallback() {
return base::Bind(&ShowExtensionInstallDialogImpl);
}
|