| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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/renderer/extensions/chrome_extension_helper.h" | |
| 6 | |
| 7 #include "base/strings/string16.h" | |
| 8 #include "chrome/common/extensions/chrome_extension_messages.h" | |
| 9 #include "chrome/renderer/web_apps.h" | |
| 10 #include "content/public/renderer/render_view.h" | |
| 11 #include "ipc/ipc_message_macros.h" | |
| 12 #include "third_party/WebKit/public/web/WebView.h" | |
| 13 #include "url/gurl.h" | |
| 14 #include "url/url_constants.h" | |
| 15 | |
| 16 namespace extensions { | |
| 17 | |
| 18 ChromeExtensionHelper::ChromeExtensionHelper(content::RenderView* render_view) | |
| 19 : content::RenderViewObserver(render_view), | |
| 20 content::RenderViewObserverTracker<ChromeExtensionHelper>(render_view) { | |
| 21 } | |
| 22 | |
| 23 ChromeExtensionHelper::~ChromeExtensionHelper() { | |
| 24 } | |
| 25 | |
| 26 bool ChromeExtensionHelper::OnMessageReceived( | |
| 27 const IPC::Message& message) { | |
| 28 bool handled = true; | |
| 29 IPC_BEGIN_MESSAGE_MAP(ChromeExtensionHelper, message) | |
| 30 IPC_MESSAGE_HANDLER(ChromeExtensionMsg_GetApplicationInfo, | |
| 31 OnGetApplicationInfo) | |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 33 IPC_END_MESSAGE_MAP() | |
| 34 return handled; | |
| 35 } | |
| 36 | |
| 37 void ChromeExtensionHelper::OnGetApplicationInfo() { | |
| 38 WebApplicationInfo app_info; | |
| 39 base::string16 error; | |
| 40 web_apps::ParseWebAppFromWebDocument( | |
| 41 render_view()->GetWebView()->mainFrame(), &app_info, &error); | |
| 42 | |
| 43 // Prune out any data URLs in the set of icons. The browser process expects | |
| 44 // any icon with a data URL to have originated from a favicon. We don't want | |
| 45 // to decode arbitrary data URLs in the browser process. See | |
| 46 // http://b/issue?id=1162972 | |
| 47 for (size_t i = 0; i < app_info.icons.size(); ++i) { | |
| 48 if (app_info.icons[i].url.SchemeIs(url::kDataScheme)) { | |
| 49 app_info.icons.erase(app_info.icons.begin() + i); | |
| 50 --i; | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 Send( | |
| 55 new ChromeExtensionHostMsg_DidGetApplicationInfo(routing_id(), app_info)); | |
| 56 } | |
| 57 | |
| 58 } // namespace extensions | |
| OLD | NEW |