| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // some alternative way to transmit the icon data to the browser process. | 500 // some alternative way to transmit the icon data to the browser process. |
| 501 // | 501 // |
| 502 // See also: bug 63729. | 502 // See also: bug 63729. |
| 503 const size_t kMaxIconSize = 1024 * 128; | 503 const size_t kMaxIconSize = 1024 * 128; |
| 504 size_t actual_icon_size = 0; | 504 size_t actual_icon_size = 0; |
| 505 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { | 505 for (size_t i = 0; i < pending_app_info_->icons.size(); ++i) { |
| 506 size_t current_size = pending_app_info_->icons[i].data.getSize(); | 506 size_t current_size = pending_app_info_->icons[i].data.getSize(); |
| 507 if (current_size > kMaxIconSize - actual_icon_size) { | 507 if (current_size > kMaxIconSize - actual_icon_size) { |
| 508 AddMessageToRootConsole( | 508 AddMessageToRootConsole( |
| 509 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 509 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 510 ASCIIToUTF16("Icons are too large. " | 510 "Icons are too large. Maximum total size for app icons is 128 KB."); |
| 511 "Maximum total size for app icons is 128 KB.")); | |
| 512 return; | 511 return; |
| 513 } | 512 } |
| 514 actual_icon_size += current_size; | 513 actual_icon_size += current_size; |
| 515 } | 514 } |
| 516 | 515 |
| 517 Send(new ExtensionHostMsg_InstallApplication( | 516 Send(new ExtensionHostMsg_InstallApplication( |
| 518 routing_id(), *pending_app_info_)); | 517 routing_id(), *pending_app_info_)); |
| 519 pending_app_info_.reset(NULL); | 518 pending_app_info_.reset(NULL); |
| 520 } | 519 } |
| 521 | 520 |
| 522 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, | 521 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, |
| 522 const std::string& message) { |
| 523 AddMessageToRootConsole(level, ASCIIToUTF16(message)); |
| 524 } |
| 525 |
| 526 void ExtensionHelper::AddMessageToRootConsole(ConsoleMessageLevel level, |
| 523 const string16& message) { | 527 const string16& message) { |
| 524 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 528 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 525 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; | 529 WebConsoleMessage::Level target_level = WebConsoleMessage::LevelLog; |
| 526 switch (level) { | 530 switch (level) { |
| 527 case content::CONSOLE_MESSAGE_LEVEL_DEBUG: | 531 case content::CONSOLE_MESSAGE_LEVEL_DEBUG: |
| 528 target_level = WebConsoleMessage::LevelDebug; | 532 target_level = WebConsoleMessage::LevelDebug; |
| 529 break; | 533 break; |
| 530 case content::CONSOLE_MESSAGE_LEVEL_LOG: | 534 case content::CONSOLE_MESSAGE_LEVEL_LOG: |
| 531 target_level = WebConsoleMessage::LevelLog; | 535 target_level = WebConsoleMessage::LevelLog; |
| 532 break; | 536 break; |
| 533 case content::CONSOLE_MESSAGE_LEVEL_WARNING: | 537 case content::CONSOLE_MESSAGE_LEVEL_WARNING: |
| 534 target_level = WebConsoleMessage::LevelWarning; | 538 target_level = WebConsoleMessage::LevelWarning; |
| 535 break; | 539 break; |
| 536 case content::CONSOLE_MESSAGE_LEVEL_ERROR: | 540 case content::CONSOLE_MESSAGE_LEVEL_ERROR: |
| 537 target_level = WebConsoleMessage::LevelError; | 541 target_level = WebConsoleMessage::LevelError; |
| 538 break; | 542 break; |
| 539 } | 543 } |
| 540 render_view()->GetWebView()->mainFrame()->addMessageToConsole( | 544 render_view()->GetWebView()->mainFrame()->addMessageToConsole( |
| 541 WebConsoleMessage(target_level, message)); | 545 WebConsoleMessage(target_level, message)); |
| 542 } | 546 } |
| 543 } | 547 } |
| 544 | 548 |
| 545 } // namespace extensions | 549 } // namespace extensions |
| OLD | NEW |