What's new? | Help | Directory | Sign in
Google
gears
Improving Your Web Browser
  
  
  
    
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// 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.

#include "gears/desktop/file_dialog.h"

#include "gears/desktop/file_dialog_gtk.h"
#include "gears/desktop/file_dialog_osx.h"
#include "gears/desktop/file_dialog_win32.h"

#if BROWSER_FF
#include "gears/base/firefox/dom_utils.h"
#elif BROWSER_IE
#include "gears/base/ie/activex_utils.h"
#ifdef WINCE
#include "gears/base/ie/bho.h"
#endif
#include "gears/base/common/base_class.h"
#endif

#if defined(LINUX) && !defined(OS_MACOSX)

static FileDialog* NewFileDialogGtk(const FileDialog::Mode mode) {
// If the parent is null the the dialog will not be modal.
// The user will still be able interact with the browser window.
GtkWindow* parent = NULL;

#if BROWSER_FF
if (NS_FAILED(DOMUtils::GetNativeWindow(&parent)))
return NULL;
#endif

FileDialog* dialog = NULL;

switch (mode) {
case FileDialog::SINGLE_FILE:
case FileDialog::MULTIPLE_FILES:
dialog = new FileDialogGtk(parent, FileDialog::MULTIPLE_FILES == mode);
break;

default:
dialog = NULL;
break;
}

return dialog;
}

#elif defined(WIN32)

static FileDialog* NewFileDialogWin32(const FileDialog::Mode mode,
const ModuleImplBaseClass& module) {
// If the parent is null the the dialog will not be modal.
// The user will still be able interact with the browser window.
HWND parent = NULL;

#if BROWSER_FF

if (NS_FAILED(DOMUtils::GetNativeWindow(&parent)))
return NULL;

#elif BROWSER_IE

#ifdef WINCE
// On WinCE, only the BHO has an IWebBrowser2 pointer to the browser.
parent = BrowserHelperObject::GetBrowserWindow();
if (NULL == parent) {
return NULL;
}
#else
IWebBrowser2* web_browser = NULL;
HRESULT hr = ActiveXUtils::GetWebBrowser2(module.EnvPageIUnknownSite(),
&web_browser);
if (FAILED(hr))
return NULL;

hr = web_browser->get_HWND(reinterpret_cast<long*>(&parent));
if (FAILED(hr)) {
web_browser->Release();
return NULL;
}

web_browser->Release();
#endif

#endif // BROWSER_xyz

FileDialog* dialog = NULL;

switch (mode) {
case FileDialog::SINGLE_FILE:
case FileDialog::MULTIPLE_FILES:
dialog = new FileDialogWin32(parent, FileDialog::MULTIPLE_FILES == mode);
break;

default:
dialog = NULL;
break;
}

return dialog;
}

#elif defined(OS_MACOSX)

static FileDialog* NewFileDialogCarbon(const FileDialog::Mode mode) {
FileDialog* dialog = NULL;

switch (mode) {
case FileDialog::SINGLE_FILE:
case FileDialog::MULTIPLE_FILES:
dialog = new FileDialogCarbon(FileDialog::MULTIPLE_FILES == mode);
break;

default:
dialog = NULL;
break;
}

return dialog;
}

#endif // PLATFORM_xyz

FileDialog* NewFileDialog(const FileDialog::Mode mode,
const ModuleImplBaseClass& module) {
#if defined(LINUX) && !defined(OS_MACOSX)
return NewFileDialogGtk(mode);
#elif defined(WIN32)
return NewFileDialogWin32(mode, module);
#elif defined(OS_MACOSX)
return NewFileDialogCarbon(mode);
#else
return NULL;
#endif // PLATFORM_xyz
}

FileDialog::FileDialog() {
}

FileDialog::~FileDialog() {
}
Show details Hide details

Change log

r2106 by gears.daemon on Jun 25, 2008   Diff
[Author: bpm]

Add single-file option to
desktop.getLocalFiles().

PRESUBMIT=passed
R=nigeltao,cprince
CC=gears-eng@googlegroups.com
DELTA=52  (25 added, 2 deleted, 25
changed)
OCL=7516720
SCL=7537377
Go to: 
Project members, sign in to write a code review

Older revisions

r1936 by gears.daemon on Jun 11, 2008   Diff
[Author: fry]

make blob support official!

PRESUBMIT=passed
...
r1125 by gears.daemon on Mar 06, 2008   Diff
[Author: steveblock]

Adss file picker for WinCE.
Also updates cab_updater to use new
BrowserHelperObject::GetBrowserWindow
...
r1013 by gears.daemon on Feb 21, 2008   Diff
[Author: cdevries]

 Carbon based file picker
implementation for Mac OS.
 It currently uses callbacks
...
All revisions of this file

File info

Size: 4633 bytes, 163 lines