Index: chrome/browser/ui/browser_instant_controller.cc |
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc |
index 008753e789bf6608b7df751c357af2c50355cbad..e21ef4c93ef2a638bb9a2c50710160e4b95c00bf 100644 |
--- a/chrome/browser/ui/browser_instant_controller.cc |
+++ b/chrome/browser/ui/browser_instant_controller.cc |
@@ -15,9 +15,6 @@ |
#include "chrome/browser/search_engines/template_url.h" |
#include "chrome/browser/search_engines/template_url_service.h" |
#include "chrome/browser/search_engines/template_url_service_factory.h" |
-#include "chrome/browser/themes/theme_properties.h" |
-#include "chrome/browser/themes/theme_service.h" |
-#include "chrome/browser/themes/theme_service_factory.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/omnibox/location_bar.h" |
@@ -25,17 +22,12 @@ |
#include "chrome/browser/ui/search/search_tab_helper.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
-#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/common/url_constants.h" |
#include "components/user_prefs/pref_registry_syncable.h" |
-#include "content/public/browser/notification_service.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents.h" |
-#include "grit/theme_resources.h" |
-#include "ui/gfx/color_utils.h" |
-#include "ui/gfx/sys_color_change_listener.h" |
using content::UserMetricsAction; |
@@ -46,8 +38,7 @@ BrowserInstantController::BrowserInstantController(Browser* browser) |
: browser_(browser), |
instant_(this, |
chrome::IsInstantExtendedAPIEnabled()), |
- instant_unload_handler_(browser), |
- initialized_theme_info_(false) { |
+ instant_unload_handler_(browser) { |
// TODO(sreeram): Perhaps this can be removed, if field trial info is |
// available before we need to register the pref. |
@@ -68,13 +59,6 @@ BrowserInstantController::BrowserInstantController(Browser* browser) |
base::Unretained(this))); |
ResetInstant(std::string()); |
browser_->search_model()->AddObserver(this); |
- |
-#if defined(ENABLE_THEMES) |
- // Listen for theme installation. |
- registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
- content::Source<ThemeService>( |
- ThemeServiceFactory::GetForProfile(profile()))); |
-#endif // defined(ENABLE_THEMES) |
} |
BrowserInstantController::~BrowserInstantController() { |
@@ -233,15 +217,6 @@ void BrowserInstantController::TabDeactivated(content::WebContents* contents) { |
instant_.TabDeactivated(contents); |
} |
-void BrowserInstantController::UpdateThemeInfo() { |
- // Update theme background info. |
- // Initialize |theme_info| if necessary. |
- if (!initialized_theme_info_) |
- OnThemeChanged(ThemeServiceFactory::GetForProfile(profile())); |
- else |
- OnThemeChanged(NULL); |
-} |
- |
void BrowserInstantController::OpenURL( |
const GURL& url, |
content::PageTransition transition, |
@@ -292,101 +267,11 @@ void BrowserInstantController::ModelChanged( |
// If mode is now |NTP|, send theme-related information to Instant. |
if (new_mode.is_ntp()) |
- UpdateThemeInfo(); |
+ instant_.UpdateThemeInfo(); |
samarth
2013/06/19 00:14:36
Is this really necessary? Shouldn't the page be ge
kmadhusu
2013/06/19 02:27:24
You are right. It is not required. Removed.
|
instant_.SearchModeChanged(old_state.mode, new_mode); |
} |
-//////////////////////////////////////////////////////////////////////////////// |
-// BrowserInstantController, content::NotificationObserver implementation: |
- |
-void BrowserInstantController::Observe( |
- int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
-#if defined(ENABLE_THEMES) |
- DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
- OnThemeChanged(content::Source<ThemeService>(source).ptr()); |
-#endif // defined(ENABLE_THEMES) |
-} |
- |
-void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { |
- if (theme_service) { // Get theme information from theme service. |
- theme_info_ = ThemeBackgroundInfo(); |
- |
- // Set theme background color. |
- SkColor background_color = |
- theme_service->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); |
- if (gfx::IsInvertedColorScheme()) |
- background_color = color_utils::InvertColor(background_color); |
- theme_info_.color_r = SkColorGetR(background_color); |
- theme_info_.color_g = SkColorGetG(background_color); |
- theme_info_.color_b = SkColorGetB(background_color); |
- theme_info_.color_a = SkColorGetA(background_color); |
- |
- if (theme_service->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { |
- // Set theme id for theme background image url. |
- theme_info_.theme_id = theme_service->GetThemeID(); |
- |
- // Set theme background image horizontal alignment. |
- int alignment = 0; |
- theme_service->GetDisplayProperty( |
- ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment); |
- if (alignment & ThemeProperties::ALIGN_LEFT) { |
- theme_info_.image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_LEFT; |
- } else if (alignment & ThemeProperties::ALIGN_RIGHT) { |
- theme_info_.image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_RIGHT; |
- } else { // ALIGN_CENTER |
- theme_info_.image_horizontal_alignment = |
- THEME_BKGRND_IMAGE_ALIGN_CENTER; |
- } |
- |
- // Set theme background image vertical alignment. |
- if (alignment & ThemeProperties::ALIGN_TOP) |
- theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; |
- else if (alignment & ThemeProperties::ALIGN_BOTTOM) |
- theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; |
- else // ALIGN_CENTER |
- theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; |
- |
- // Set theme background image tiling. |
- int tiling = 0; |
- theme_service->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_TILING, |
- &tiling); |
- switch (tiling) { |
- case ThemeProperties::NO_REPEAT: |
- theme_info_.image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; |
- break; |
- case ThemeProperties::REPEAT_X: |
- theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; |
- break; |
- case ThemeProperties::REPEAT_Y: |
- theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; |
- break; |
- case ThemeProperties::REPEAT: |
- theme_info_.image_tiling = THEME_BKGRND_IMAGE_REPEAT; |
- break; |
- } |
- |
- // Set theme background image height. |
- gfx::ImageSkia* image = theme_service->GetImageSkiaNamed( |
- IDR_THEME_NTP_BACKGROUND); |
- DCHECK(image); |
- theme_info_.image_height = image->height(); |
- |
- theme_info_.has_attribution = |
- theme_service->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION); |
- } |
- |
- initialized_theme_info_ = true; |
- } |
- |
- DCHECK(initialized_theme_info_); |
- |
- if (browser_->search_model()->mode().is_ntp()) |
- instant_.ThemeChanged(theme_info_); |
-} |
- |
void BrowserInstantController::OnDefaultSearchProviderChanged( |
const std::string& pref_name) { |
DCHECK_EQ(pref_name, std::string(prefs::kDefaultSearchProviderID)); |