| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/extension_helper.h" | 5 #include "chrome/renderer/extensions/extension_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/json/json_value_serializer.h" | 10 #include "base/json/json_value_serializer.h" |
| 9 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 11 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/chrome_view_types.h" | 15 #include "chrome/common/chrome_view_types.h" |
| 14 #include "chrome/common/extensions/extension_messages.h" | 16 #include "chrome/common/extensions/extension_messages.h" |
| 15 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 101 } |
| 100 | 102 |
| 101 if (!pending_app_info_->manifest_url.is_valid()) { | 103 if (!pending_app_info_->manifest_url.is_valid()) { |
| 102 *error = ASCIIToUTF16("Web application definition not found or invalid."); | 104 *error = ASCIIToUTF16("Web application definition not found or invalid."); |
| 103 return false; | 105 return false; |
| 104 } | 106 } |
| 105 | 107 |
| 106 app_definition_fetcher_.reset(new ResourceFetcher( | 108 app_definition_fetcher_.reset(new ResourceFetcher( |
| 107 pending_app_info_->manifest_url, render_view()->GetWebView()->mainFrame(), | 109 pending_app_info_->manifest_url, render_view()->GetWebView()->mainFrame(), |
| 108 WebURLRequest::TargetIsSubresource, | 110 WebURLRequest::TargetIsSubresource, |
| 109 NewCallback(this, &ExtensionHelper::DidDownloadApplicationDefinition))); | 111 base::Bind(&ExtensionHelper::DidDownloadApplicationDefinition, |
| 112 base::Unretained(this)))); |
| 110 return true; | 113 return true; |
| 111 } | 114 } |
| 112 | 115 |
| 113 void ExtensionHelper::InlineWebstoreInstall( | 116 void ExtensionHelper::InlineWebstoreInstall( |
| 114 int install_id, std::string webstore_item_id, GURL requestor_url) { | 117 int install_id, std::string webstore_item_id, GURL requestor_url) { |
| 115 Send(new ExtensionHostMsg_InlineWebstoreInstall( | 118 Send(new ExtensionHostMsg_InlineWebstoreInstall( |
| 116 routing_id(), install_id, webstore_item_id, requestor_url)); | 119 routing_id(), install_id, webstore_item_id, requestor_url)); |
| 117 } | 120 } |
| 118 | 121 |
| 119 void ExtensionHelper::OnInlineWebstoreInstallResponse( | 122 void ExtensionHelper::OnInlineWebstoreInstallResponse( |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 pending_app_icon_requests_ = | 305 pending_app_icon_requests_ = |
| 303 static_cast<int>(pending_app_info_->icons.size()); | 306 static_cast<int>(pending_app_info_->icons.size()); |
| 304 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { | 307 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { |
| 305 app_icon_fetchers_.push_back(linked_ptr<ImageResourceFetcher>( | 308 app_icon_fetchers_.push_back(linked_ptr<ImageResourceFetcher>( |
| 306 new ImageResourceFetcher( | 309 new ImageResourceFetcher( |
| 307 pending_app_info_->icons[i].url, | 310 pending_app_info_->icons[i].url, |
| 308 render_view()->GetWebView()->mainFrame(), | 311 render_view()->GetWebView()->mainFrame(), |
| 309 static_cast<int>(i), | 312 static_cast<int>(i), |
| 310 pending_app_info_->icons[i].width, | 313 pending_app_info_->icons[i].width, |
| 311 WebURLRequest::TargetIsFavicon, | 314 WebURLRequest::TargetIsFavicon, |
| 312 NewCallback( | 315 base::Bind( |
| 313 this, &ExtensionHelper::DidDownloadApplicationIcon)))); | 316 &ExtensionHelper::DidDownloadApplicationIcon, |
| 317 base::Unretained(this))))); |
| 314 } | 318 } |
| 315 } else { | 319 } else { |
| 316 Send(new ExtensionHostMsg_InstallApplication(routing_id(), *app_info)); | 320 Send(new ExtensionHostMsg_InstallApplication(routing_id(), *app_info)); |
| 317 } | 321 } |
| 318 } | 322 } |
| 319 | 323 |
| 320 void ExtensionHelper::DidDownloadApplicationIcon(ImageResourceFetcher* fetcher, | 324 void ExtensionHelper::DidDownloadApplicationIcon(ImageResourceFetcher* fetcher, |
| 321 const SkBitmap& image) { | 325 const SkBitmap& image) { |
| 322 pending_app_info_->icons[fetcher->id()].data = image; | 326 pending_app_info_->icons[fetcher->id()].data = image; |
| 323 | 327 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 routing_id(), *pending_app_info_)); | 370 routing_id(), *pending_app_info_)); |
| 367 pending_app_info_.reset(NULL); | 371 pending_app_info_.reset(NULL); |
| 368 } | 372 } |
| 369 | 373 |
| 370 void ExtensionHelper::AddErrorToRootConsole(const string16& message) { | 374 void ExtensionHelper::AddErrorToRootConsole(const string16& message) { |
| 371 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 375 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 372 render_view()->GetWebView()->mainFrame()->addMessageToConsole( | 376 render_view()->GetWebView()->mainFrame()->addMessageToConsole( |
| 373 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 377 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
| 374 } | 378 } |
| 375 } | 379 } |
| OLD | NEW |