Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_actions_api.cc

Issue 10837215: exhibit 1: explicit null checks Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/extensions/api/extension_action/extension_actions_api.h " 5 #include "chrome/browser/extensions/api/extension_action/extension_actions_api.h "
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (!base::Base64Decode(str, &raw_str)) 66 if (!base::Base64Decode(str, &raw_str))
67 return false; 67 return false;
68 IPC::Message bitmap_pickle(raw_str.data(), raw_str.size()); 68 IPC::Message bitmap_pickle(raw_str.data(), raw_str.size());
69 PickleIterator iter(bitmap_pickle); 69 PickleIterator iter(bitmap_pickle);
70 return IPC::ReadParam(&bitmap_pickle, &iter, bitmap); 70 return IPC::ReadParam(&bitmap_pickle, &iter, bitmap);
71 } 71 }
72 72
73 // Conversion function for reading/writing to storage. 73 // Conversion function for reading/writing to storage.
74 std::string ImageToString(const gfx::Image& image) { 74 std::string ImageToString(const gfx::Image& image) {
75 IPC::Message bitmap_pickle; 75 IPC::Message bitmap_pickle;
76 IPC::WriteParam(&bitmap_pickle, image.AsBitmap()); 76 IPC::WriteParam(&bitmap_pickle,
77 image.IsEmpty() ? SkBitmap() : *image.ToSkBitmap());
77 std::string raw_str(static_cast<const char*>(bitmap_pickle.data()), 78 std::string raw_str(static_cast<const char*>(bitmap_pickle.data()),
78 bitmap_pickle.size()); 79 bitmap_pickle.size());
79 std::string base64_str; 80 std::string base64_str;
80 if (!base::Base64Encode(raw_str, &base64_str)) 81 if (!base::Base64Encode(raw_str, &base64_str))
81 return std::string(); 82 return std::string();
82 return base64_str; 83 return base64_str;
83 } 84 }
84 85
85 // Set |action|'s default values to those specified in |dict|. 86 // Set |action|'s default values to those specified in |dict|.
86 void SetDefaultsFromValue(const base::DictionaryValue* dict, 87 void SetDefaultsFromValue(const base::DictionaryValue* dict,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 510 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
510 ListValue* list = new ListValue(); 511 ListValue* list = new ListValue();
511 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 512 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
512 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 513 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
513 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 514 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
514 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 515 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
515 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 516 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
516 SetResult(list); 517 SetResult(list);
517 return true; 518 return true;
518 } 519 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698