| 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/browser/extensions/extension_web_ui.h" | 5 #include "chrome/browser/extensions/extension_web_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" | 12 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 14 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "chrome/common/extensions/extension_icon_set.h" | 24 #include "chrome/common/extensions/extension_icon_set.h" |
| 25 #include "chrome/common/extensions/extension_resource.h" | 25 #include "chrome/common/extensions/extension_resource.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 28 #include "content/common/page_transition_types.h" | 28 #include "content/public/common/page_transition_types.h" |
| 29 #include "content/public/common/bindings_policy.h" | 29 #include "content/public/common/bindings_policy.h" |
| 30 #include "net/base/file_stream.h" | 30 #include "net/base/file_stream.h" |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
| 32 #include "ui/gfx/codec/png_codec.h" | 32 #include "ui/gfx/codec/png_codec.h" |
| 33 #include "ui/gfx/favicon_size.h" | 33 #include "ui/gfx/favicon_size.h" |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // De-dupes the items in |list|. Assumes the values are strings. | 37 // De-dupes the items in |list|. Assumes the values are strings. |
| 38 void CleanUpDuplicates(ListValue* list) { | 38 void CleanUpDuplicates(ListValue* list) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Hack: A few things we specialize just for the bookmark manager. | 160 // Hack: A few things we specialize just for the bookmark manager. |
| 161 if (extension->id() == extension_misc::kBookmarkManagerId) { | 161 if (extension->id() == extension_misc::kBookmarkManagerId) { |
| 162 TabContentsWrapper* tab = | 162 TabContentsWrapper* tab = |
| 163 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); | 163 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); |
| 164 DCHECK(tab); | 164 DCHECK(tab); |
| 165 extension_bookmark_manager_event_router_.reset( | 165 extension_bookmark_manager_event_router_.reset( |
| 166 new ExtensionBookmarkManagerEventRouter(profile, tab)); | 166 new ExtensionBookmarkManagerEventRouter(profile, tab)); |
| 167 | 167 |
| 168 link_transition_type_ = PageTransition::AUTO_BOOKMARK; | 168 link_transition_type_ = content::PAGE_TRANSITION_AUTO_BOOKMARK; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 ExtensionWebUI::~ExtensionWebUI() {} | 172 ExtensionWebUI::~ExtensionWebUI() {} |
| 173 | 173 |
| 174 ExtensionBookmarkManagerEventRouter* | 174 ExtensionBookmarkManagerEventRouter* |
| 175 ExtensionWebUI::extension_bookmark_manager_event_router() { | 175 ExtensionWebUI::extension_bookmark_manager_event_router() { |
| 176 return extension_bookmark_manager_event_router_.get(); | 176 return extension_bookmark_manager_event_router_.get(); |
| 177 } | 177 } |
| 178 | 178 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 Profile::FromBrowserContext(tab->browser_context()); | 344 Profile::FromBrowserContext(tab->browser_context()); |
| 345 if (tab_profile != profile) | 345 if (tab_profile != profile) |
| 346 continue; | 346 continue; |
| 347 | 347 |
| 348 GURL url = tab->GetURL(); | 348 GURL url = tab->GetURL(); |
| 349 if (!url.SchemeIs(chrome::kChromeUIScheme) || url.host() != page) | 349 if (!url.SchemeIs(chrome::kChromeUIScheme) || url.host() != page) |
| 350 continue; | 350 continue; |
| 351 | 351 |
| 352 // Don't use Reload() since |url| isn't the same as the internal URL | 352 // Don't use Reload() since |url| isn't the same as the internal URL |
| 353 // that NavigationController has. | 353 // that NavigationController has. |
| 354 tab->controller().LoadURL(url, url, PageTransition::RELOAD, | 354 tab->controller().LoadURL(url, url, content::PAGE_TRANSITION_RELOAD, |
| 355 std::string()); | 355 std::string()); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 // static | 360 // static |
| 361 void ExtensionWebUI::UnregisterChromeURLOverride(const std::string& page, | 361 void ExtensionWebUI::UnregisterChromeURLOverride(const std::string& page, |
| 362 Profile* profile, Value* override) { | 362 Profile* profile, Value* override) { |
| 363 if (!override) | 363 if (!override) |
| 364 return; | 364 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 // static | 402 // static |
| 403 void ExtensionWebUI::GetFaviconForURL(Profile* profile, | 403 void ExtensionWebUI::GetFaviconForURL(Profile* profile, |
| 404 FaviconService::GetFaviconRequest* request, const GURL& page_url) { | 404 FaviconService::GetFaviconRequest* request, const GURL& page_url) { |
| 405 // tracker deletes itself when done. | 405 // tracker deletes itself when done. |
| 406 ExtensionWebUIImageLoadingTracker* tracker = | 406 ExtensionWebUIImageLoadingTracker* tracker = |
| 407 new ExtensionWebUIImageLoadingTracker(profile, request, page_url); | 407 new ExtensionWebUIImageLoadingTracker(profile, request, page_url); |
| 408 tracker->Init(); | 408 tracker->Init(); |
| 409 } | 409 } |
| OLD | NEW |