OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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/default_plugin/plugin_impl_gtk.h" | |
6 | |
7 #include <X11/Xdefs.h> | |
8 #include <gtk/gtk.h> | |
9 | |
10 #include "base/file_util.h" | |
11 #include "base/path_service.h" | |
12 #include "base/string_util.h" | |
13 #include "chrome/common/chrome_plugin_messages.h" | |
14 #include "chrome/default_plugin/plugin_main.h" | |
15 #include "content/common/child_thread.h" | |
16 #include "content/public/common/content_constants.h" | |
17 #include "googleurl/src/gurl.h" | |
18 #include "grit/webkit_strings.h" | |
19 #include "unicode/locid.h" | |
20 #include "webkit/plugins/npapi/default_plugin_shared.h" | |
21 | |
22 // TODO(thakis): Most methods in this class are stubbed out an need to be | |
23 // implemented. | |
24 | |
25 PluginInstallerImpl::PluginInstallerImpl(int16 mode) | |
26 : instance_(NULL), | |
27 plugin_install_stream_(NULL), | |
28 plugin_installer_state_(PluginInstallerStateUndefined), | |
29 container_(NULL) { | |
30 } | |
31 | |
32 PluginInstallerImpl::~PluginInstallerImpl() { | |
33 if (container_) | |
34 gtk_widget_destroy(container_); | |
35 } | |
36 | |
37 bool PluginInstallerImpl::Initialize(void* module_handle, NPP instance, | |
38 NPMIMEType mime_type, int16 argc, | |
39 char* argn[], char* argv[]) { | |
40 DVLOG(1) << __FUNCTION__ << " MIME Type : " << mime_type; | |
41 DCHECK(instance != NULL); | |
42 | |
43 if (mime_type == NULL || strlen(mime_type) == 0) { | |
44 DLOG(WARNING) << __FUNCTION__ << " Invalid parameters passed in"; | |
45 NOTREACHED(); | |
46 return false; | |
47 } | |
48 | |
49 instance_ = instance; | |
50 mime_type_ = mime_type; | |
51 | |
52 PluginInstallerBase::SetRoutingIds(argc, argn, argv); | |
53 return true; | |
54 } | |
55 | |
56 bool PluginInstallerImpl::NPP_SetWindow(NPWindow* window_info) { | |
57 if (container_) | |
58 gtk_widget_destroy(container_); | |
59 container_ = gtk_plug_new(reinterpret_cast<XID>(window_info->window)); | |
60 | |
61 // Add label. | |
62 GtkWidget* box = gtk_vbox_new(FALSE, 0); | |
63 GtkWidget* label = gtk_label_new("Missing Plug-in"); | |
64 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); | |
65 gtk_container_add(GTK_CONTAINER(container_), box); | |
66 | |
67 gtk_widget_show_all(container_); | |
68 | |
69 return true; | |
70 } | |
71 | |
72 void PluginInstallerImpl::Shutdown() { | |
73 } | |
74 | |
75 void PluginInstallerImpl::NewStream(NPStream* stream) { | |
76 plugin_install_stream_ = stream; | |
77 } | |
78 | |
79 void PluginInstallerImpl::DestroyStream(NPStream* stream, NPError reason) { | |
80 if (stream == plugin_install_stream_) | |
81 plugin_install_stream_ = NULL; | |
82 } | |
83 | |
84 bool PluginInstallerImpl::WriteReady(NPStream* stream) { | |
85 bool ready_to_accept_data = false; | |
86 return ready_to_accept_data; | |
87 } | |
88 | |
89 int32 PluginInstallerImpl::Write(NPStream* stream, int32 offset, | |
90 int32 buffer_length, void* buffer) { | |
91 return true; | |
92 } | |
93 | |
94 void PluginInstallerImpl::ClearDisplay() { | |
95 } | |
96 | |
97 void PluginInstallerImpl::RefreshDisplay() { | |
98 } | |
99 | |
100 bool PluginInstallerImpl::CreateToolTip() { | |
101 return true; | |
102 } | |
103 | |
104 void PluginInstallerImpl::UpdateToolTip() { | |
105 } | |
106 | |
107 void PluginInstallerImpl::DisplayAvailablePluginStatus() { | |
108 } | |
109 | |
110 void PluginInstallerImpl::DisplayStatus(int message_resource_id) { | |
111 } | |
112 | |
113 void PluginInstallerImpl::DisplayPluginDownloadFailedStatus() { | |
114 } | |
115 | |
116 void PluginInstallerImpl::URLNotify(const char* url, NPReason reason) { | |
117 } | |
118 | |
119 int16 PluginInstallerImpl::NPP_HandleEvent(void* event) { | |
120 return 0; | |
121 } | |
122 | |
123 std::wstring PluginInstallerImpl::ReplaceStringForPossibleEmptyReplacement( | |
124 int message_id_with_placeholders, | |
125 int messsage_id_without_placeholders, | |
126 const std::wstring& replacement_string) { | |
127 return L""; | |
128 } | |
129 | |
130 void PluginInstallerImpl::DownloadPlugin() { | |
131 } | |
132 | |
133 void PluginInstallerImpl::DownloadCancelled() { | |
134 DisplayAvailablePluginStatus(); | |
135 } | |
136 | |
137 void PluginInstallerImpl::ShowInstallDialog() { | |
138 } | |
139 | |
140 void PluginInstallerImpl::NotifyPluginStatus(int status) { | |
141 ChildThread::current()->Send( | |
142 new ChromePluginProcessHostMsg_MissingPluginStatus( | |
143 status, | |
144 renderer_process_id(), | |
145 render_view_id(), | |
146 0)); | |
147 } | |
OLD | NEW |