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

Unified Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/search/instant_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0219145650463ff67f9d373d34a46b8651194d1f..30fcdece566195f9322ee3de3a82ef2297748bae 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"
@@ -26,17 +23,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;
@@ -47,8 +39,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.
@@ -69,13 +60,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() {
@@ -234,15 +218,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,
@@ -289,10 +264,6 @@ void BrowserInstantController::ModelChanged(
content::RecordAction(UserMetricsAction("InstantExtended.ShowNTP"));
}
- // If mode is now |NTP|, send theme-related information to Instant.
- if (new_mode.is_ntp())
- UpdateThemeInfo();
-
instant_.SearchModeChanged(old_state.mode, new_mode);
}
@@ -300,96 +271,6 @@ void BrowserInstantController::ModelChanged(
instant_.InstantSupportChanged(new_state.instant_support);
}
-////////////////////////////////////////////////////////////////////////////////
-// 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));
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/search/instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698