| OLD | NEW |
| 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/instant_ui.h" | 5 #include "chrome/browser/ui/webui/instant_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/prefs/pref_service.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 9 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 12 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 14 #include "content/public/browser/web_ui.h" | 12 #include "content/public/browser/web_ui.h" |
| 15 #include "content/public/browser/web_ui_controller.h" | |
| 16 #include "content/public/browser/web_ui_message_handler.h" | 13 #include "content/public/browser/web_ui_message_handler.h" |
| 17 #include "grit/browser_resources.h" | 14 #include "grit/browser_resources.h" |
| 18 | 15 |
| 19 namespace { | 16 namespace { |
| 20 | 17 |
| 21 ChromeWebUIDataSource* CreateInstantHTMLSource() { | 18 ChromeWebUIDataSource* CreateInstantHTMLSource() { |
| 22 ChromeWebUIDataSource* source = | 19 ChromeWebUIDataSource* source = |
| 23 new ChromeWebUIDataSource(chrome::kChromeUIInstantHost); | 20 new ChromeWebUIDataSource(chrome::kChromeUIInstantHost); |
| 24 | 21 |
| 25 source->set_json_path("strings.js"); | 22 source->set_json_path("strings.js"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 virtual void RegisterMessages() OVERRIDE; | 40 virtual void RegisterMessages() OVERRIDE; |
| 44 | 41 |
| 45 static int slow_animation_scale_factor() { | 42 static int slow_animation_scale_factor() { |
| 46 return slow_animation_scale_factor_; | 43 return slow_animation_scale_factor_; |
| 47 } | 44 } |
| 48 | 45 |
| 49 private: | 46 private: |
| 50 void GetPreferenceValue(const base::ListValue* args); | 47 void GetPreferenceValue(const base::ListValue* args); |
| 51 void SetPreferenceValue(const base::ListValue* args); | 48 void SetPreferenceValue(const base::ListValue* args); |
| 52 | 49 |
| 53 // Slows down instant animations by a time factor. | 50 // Slows down Instant animations by a time factor. |
| 54 static int slow_animation_scale_factor_; | 51 static int slow_animation_scale_factor_; |
| 55 | 52 |
| 56 DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler); | 53 DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler); |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 // static | 56 // static |
| 60 int InstantUIMessageHandler::slow_animation_scale_factor_ = 1; | 57 int InstantUIMessageHandler::slow_animation_scale_factor_ = 1; |
| 61 | 58 |
| 62 InstantUIMessageHandler::InstantUIMessageHandler() {} | 59 InstantUIMessageHandler::InstantUIMessageHandler() {} |
| 63 | 60 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 #else | 105 #else |
| 109 NOTIMPLEMENTED(); | 106 NOTIMPLEMENTED(); |
| 110 #endif | 107 #endif |
| 111 } | 108 } |
| 112 | 109 |
| 113 } // namespace | 110 } // namespace |
| 114 | 111 |
| 115 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
| 116 // InstantUI | 113 // InstantUI |
| 117 | 114 |
| 118 InstantUI::InstantUI(content::WebUI* web_ui) | 115 InstantUI::InstantUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 119 : WebUIController(web_ui) { | |
| 120 web_ui->AddMessageHandler(new InstantUIMessageHandler()); | 116 web_ui->AddMessageHandler(new InstantUIMessageHandler()); |
| 121 | 117 |
| 122 // Set up the chrome://instant/ source. | 118 // Set up the chrome://instant/ source. |
| 123 Profile* profile = Profile::FromWebUI(web_ui); | 119 Profile* profile = Profile::FromWebUI(web_ui); |
| 124 ChromeURLDataManager::AddDataSource(profile, CreateInstantHTMLSource()); | 120 ChromeURLDataManager::AddDataSource(profile, CreateInstantHTMLSource()); |
| 125 } | 121 } |
| 126 | 122 |
| 127 // static | 123 // static |
| 128 int InstantUI::GetSlowAnimationScaleFactor() { | 124 int InstantUI::GetSlowAnimationScaleFactor() { |
| 129 return InstantUIMessageHandler::slow_animation_scale_factor(); | 125 return InstantUIMessageHandler::slow_animation_scale_factor(); |
| 130 } | 126 } |
| OLD | NEW |