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

Side by Side Diff: chrome/browser/ui/webui/ntp/favicon_webui_handler.cc

Issue 10918065: Introduce structures to reduce the number of arguments in the FaviconService methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the auxiliary structure for non-URL cases. Created 8 years, 3 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
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/ui/webui/ntp/favicon_webui_handler.h" 5 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.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/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 scoped_ptr<StringValue> color( 104 scoped_ptr<StringValue> color(
105 SkColorToCss(history::kPrepopulatedPages[i].color)); 105 SkColorToCss(history::kPrepopulatedPages[i].color));
106 web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor", 106 web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor",
107 dom_id_value, *color); 107 dom_id_value, *color);
108 return; 108 return;
109 } 109 }
110 } 110 }
111 111
112 dom_id_map_[id_] = dom_id; 112 dom_id_map_[id_] = dom_id;
113 FaviconService::Handle handle = favicon_service->GetRawFaviconForURL( 113 FaviconService::Handle handle = favicon_service->GetRawFaviconForURL(
114 Profile::FromWebUI(web_ui()), 114 FaviconService::FaviconForURLParams(
115 url, 115 Profile::FromWebUI(web_ui()),
116 history::FAVICON, 116 url,
117 gfx::kFaviconSize, 117 history::FAVICON,
118 gfx::kFaviconSize,
119 &consumer_),
118 ui::SCALE_FACTOR_100P, 120 ui::SCALE_FACTOR_100P,
119 &consumer_,
120 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, 121 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable,
121 base::Unretained(this))); 122 base::Unretained(this)));
122 consumer_.SetClientData(favicon_service, handle, id_++); 123 consumer_.SetClientData(favicon_service, handle, id_++);
123 } 124 }
124 125
125 void FaviconWebUIHandler::OnFaviconDataAvailable( 126 void FaviconWebUIHandler::OnFaviconDataAvailable(
126 FaviconService::Handle request_handle, 127 FaviconService::Handle request_handle,
127 const history::FaviconBitmapResult& bitmap_result) { 128 const history::FaviconBitmapResult& bitmap_result) {
128 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 129 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
129 Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS); 130 Profile::FromWebUI(web_ui()), Profile::EXPLICIT_ACCESS);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 std::vector<unsigned char> bits; 162 std::vector<unsigned char> bits;
162 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) 163 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits))
163 return; 164 return;
164 scoped_refptr<base::RefCountedStaticMemory> bits_mem( 165 scoped_refptr<base::RefCountedStaticMemory> bits_mem(
165 new base::RefCountedStaticMemory(&bits.front(), bits.size())); 166 new base::RefCountedStaticMemory(&bits.front(), bits.size()));
166 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem)); 167 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem));
167 StringValue id(extension_id); 168 StringValue id(extension_id);
168 web_ui()->CallJavascriptFunction( 169 web_ui()->CallJavascriptFunction(
169 "ntp.setFaviconDominantColor", id, *color_value); 170 "ntp.setFaviconDominantColor", id, *color_value);
170 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698