What's new? | Help | Directory | Sign in
Google
             
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2008, Google Inc.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Implementation of native dialogs for OSX. These are temporary standins
// till we can fix the underlying bug in WebKit that's preventing us from
// using HTML Dialogs like the other Gears ports.

// Since the dialogs are so similar, we define a BaseNativeDialog that
// implements nearly all of the functionality and draws the dialog components.
// Terminology used for dialog componets:
// gears_imageview_ - The image at the top left of the permission and location
// dialogs, this is blank in the case of the shortcut dialog.
// site_imageview_ - The site-specific icon portion of the dialogs.
// dialog_text_ - The central text area used to display the origin name
// and description text, we use the basic HTML parsing capabilities of the
// NSAttributedString class to display this.
//
// NativePermissionsDialog & NativeShortcutsDialog derive from the base class,
// they only add argument parsing and generation of the dialog_text html.

#import <Cocoa/Cocoa.h>
#import "gears/base/common/string16.h"

// This is the function that interfaces the native dialogs with the outside
// world.
bool ShowNativeModal(const char16 *html_filename,
const char16 *arguments_string,
std::string16 *results);


// Preload .nib files into memory on Gears startup.
void PreloadNibFiles();
void UnloadNibFiles();

@protocol NativeDialog
- (bool)setArgumentsString:(NSString *)args;
- (NSString *)nibName;
- (NSString *)neverAllowLabel;

- (NSString *)results;
- (NSWindow *)window;

// Can we close the dialog?
-(bool)done;
@end

@interface BaseNativeDialog : NSObject {
// All the Gears dialogs basically have the same parts.
IBOutlet NSWindow *window_;
IBOutlet NSImageView *gears_imageview_;
IBOutlet NSImageView *site_imageview_;
IBOutlet NSTextField *dialog_origin_title_;
IBOutlet NSTextField *dialog_origin_subtitle_;
IBOutlet NSTextView *dialog_origin_description_;
IBOutlet NSTextField *never_allow_link_;
IBOutlet NSTextField *top_label_;
IBOutlet NSTextField *location_dialog_label_;

// Name of the icon to display in the gears_imageview_, keep NULL
// in order to keep icon blank.
const char16 *icon_name_;

// The Checkbox toggles the allow button in some dialogs so we need these
// here.
IBOutlet NSButton *trust_checkbox_;
IBOutlet NSButton *allow_button_;

// Arguments
NSString *origin_;
NSString *site_icon_url_;
NSString *custom_site_name_;
NSString *site_description_;

// Results
bool done_;
NSString *result_string_;
}

- (IBAction)trustCheckboxValueChanged:(id)sender;

// Show the site icon.
- (void)handleSiteIconDisplay;

- (NSString *)getDialogTextHtml:(int)dialog_width;

// Called when nib is loaded.
- (void)awakeFromNib;

// Methods called by buttons.
- (IBAction)allow:(id)sender;
- (IBAction)deny:(id)sender;
- (IBAction)neverAllow:(id)sender;

@end

// Local & Location permissions dialogs.
@interface NativePermissionsDialog : BaseNativeDialog {
bool is_location_dialog;
}
- (bool)setArgumentsString:(NSString *)args;
- (NSString *)nibName;
@end

// Shortcuts dialog.
@interface NativeShortcutsDialog : BaseNativeDialog
- (bool)setArgumentsString:(NSString *)args;
- (NSString *)nibName;
@end
Show details Hide details

Change log

r2503 by gears.daemon on Jul 24, 2008   Diff
[Author: playmobil]

Add missing "Never Allow" button to Safari
Shortcuts dialog.

PRESUBMIT=passed
R=zork
CC=gears-eng@googlegroups.com
DELTA=96  (69 added, 21 deleted, 6
changed)
OCL=7802157
SCL=7804211
Go to: 
Project members, sign in to write a code review

Older revisions

r2429 by gears.daemon on Jul 19, 2008   Diff
[Author: playmobil]

Use Native dialogs for Permissions &
Shortcut dialogs till we can fix the
underlying
...
All revisions of this file

File info

Size: 4667 bytes, 130 lines