Programmatically set default homepage (or default page)

7,734 views
Skip to first unread message

Ivan Gondoprastowo

unread,
Jan 3, 2014, 5:01:49 AM1/3/14
to chromium...@chromium.org
Hi there,

I am working on a task where I need to point the browser to a specific page (chrome://apps) when user opens the application so user can launch the default installed apps right away. 

I run into a problem that I can't really set the browser to point to (chrome://apps), my new tab page is the one with omnibar and 8 most recently visited pages. It would be great if I can get the new one (like current version of google chrome), which I found is already in the source code under NTP4. My question is is there anyway I can programmatically set the default homepage/ basically whenever user opens a new tab, it will only point to chrome://apps? or is there anyway I can switch my default start page to new version of new tab page?

I am running on a mac, where master_preferences isn't working so great. (I can't find master_preferences under specified path).

Ivan

Gabriel Charette

unread,
Jan 5, 2014, 2:08:25 PM1/5/14
to Ivan Gondoprastowo, Chromium-discuss

I was simply pointing out that GPO is an option, I don't actually know enough to tell you what's wrong there (beyond comparing it with the public help docs myself which I'm not more qualified than you to do).

Perhaps someone else knows?

Cheers,
Gab

On Jan 5, 2014 3:30 AM, "Ivan Gondoprastowo" <laurent...@gmail.com> wrote:
Hi Gab,

I’ve tried changing the policy_templates.json and rebuild my project, problem is the policy is not applying and it doesn’t appear in the chrome://policy

Did I miss any step in the process?

I’m running on a mac,

This is an example of modification of the json file I did:
'policies': [
        {
          'name': 'HomepageLocation',
          'type': 'string',
          'schema': { 'type': 'string' },
          'supported_on': ['chrome.*:8-', 'chrome_os:11-'],
          'features': {
            'can_be_recommended': True,
            'dynamic_refresh': True,
            'per_profile': True,
          },
          'future': 'chrome://apps', <<I want the homepage to be apps page
          'example_value': 'http://chromium.org',
          'id': 1,
          'caption': '''Configure the home page URL''',
          'desc': '''Configures the default home page URL in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing it.

          The home page is the page opened by the Home button. The pages that open on startup are controlled by the RestoreOnStartup policies.

          The home page type can either be set to a URL you specify here or set to the New Tab Page. If you select the New Tab Page, then this policy does not take effect.

          If you enable this setting, users cannot change their home page URL in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>, but they can still can choose the New Tab Page as their home page.

          Leaving this policy not set will allow the user to choose his home page on his own if HomepageIsNewTabPage is not set too.''',
          'label': '''Home page URL''',
        },
        {
          'name': 'HomepageIsNewTabPage',
          'type': 'main',
          'schema': { 'type': 'boolean' },
          'supported_on': ['chrome.*:8-', 'chrome_os:11-'],
          'features': {
            'can_be_recommended': True,
            'dynamic_refresh': True,
            'per_profile': True,
          },
          'future': False,
          'example_value': True,
          'id': 2,
          'caption': '''Use New Tab Page as homepage''',
          'desc': '''Configures the type of the default home page in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing home page preferences. The home page can either be set to a URL you specify or set to the New Tab Page.

          If you enable this setting, the New Tab Page is always used for the home page, and the home page URL location is ignored.

          If you disable this setting, the user's homepage will never be the New Tab Page, unless its URL is set to 'chrome://newtab'.

          If you enable or disable this setting, users cannot change their homepage type in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.

          Leaving this policy not set will allow the user to choose whether the new tab page is his home page on his own.''',
        },
      ],
    },


Looking forward to your help,

Ivan

On 4 Jan, 2014, at 12:10 am, Gabriel Charette <g...@google.com> wrote:

Is GPO (Group Policy) an option for you? If so the Chrome homepage can be controlled for all users via GPO.

Cheers,
Gab

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss
 

Bartosz Fabianowski

unread,
Jan 7, 2014, 5:07:06 AM1/7/14
to g...@chromium.org, Ivan Gondoprastowo, Chromium-discuss
Modifying policy_templates.json is the wrong path. This is a generated
file that documents the available policies.

You have several options:
* If you want to change the start-up page, you can use policy (via GPO
on Windows or its equivalent on Mac/Linux).
* If you want to change the new-tab page, you can write or download an
extension that does that.
>> *Ivan Gondoprastowo* <http://www.linkedin.com/in/ivangondoprastowo>(吴一帆)

Bartosz Fabianowski

unread,
Jan 7, 2014, 5:23:37 AM1/7/14
to g...@chromium.org, Ivan Gondoprastowo, Chromium-discuss
Hit send too fast... actually, policy_templates.json is not a generated
file but a source of other generated files. Still, modifying it will not
help you. It just defines policies, not their default values.

Joao da Silva

unread,
Jan 9, 2014, 4:26:57 AM1/9/14
to laurent...@gmail.com, Chromium-discuss
 Hi Ivan,

 you can use MCX preferences to configure Chrome policies on the Mac. Here's a quick start guide:


 To open "chrome://apps" on startup you'll need to set RestoreOnStartup [1] to "4", and RestoreOnStartupURLs [2] to "chrome://apps".

 You can either do this using the Workgroup Manager (see the quick start guide), or from the command line using the plist file attached:

# dscl -u USER /Local/Default -mcximport /Computers/local_computer com.google.Chrome.plist
# sudo mcxrefresh -n USER

(replace USER with an administrator's username on the 1st command. The 2nd command is optional, and just propagates the changes to the USER account)

 Note that Chromium has a different bundle ID; replace "com.google.Chrome" with "org.chromium.Chromium" in the plist file if you want to manage Chromium instead.

 You should then see these policies set in chrome://policy. Let me know if something doesn't work for you.

- Joao




--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss
 

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

com.google.Chrome.plist

Juan Carlos Gutiérrez Barquero

unread,
Mar 10, 2015, 12:43:04 PM3/10/15
to chromium...@chromium.org, laurent...@gmail.com, joaod...@chromium.org
Hello,

My company would like to do something similar, but instead of using an external management tool, we would like to compile a customised version of Chromium and then distribute it. Is it possible to change the homepage of chromium from within the source code?

Tudor Cotop

unread,
Jul 8, 2017, 8:36:03 AM7/8/17
to Chromium-discuss, laurent...@gmail.com, joaod...@chromium.org
Hey,

I am trying to do the same thing, and I was wondering if you found a solution for this...

Thanks

Juan Carlos Gutiérrez Barquero

unread,
Jul 10, 2017, 12:59:56 PM7/10/17
to Chromium-discuss, laurent...@gmail.com, joaod...@chromium.org
Yes the solution I found was modifying the file: 
src/chrome/browser/ui/startup/startup_browser_creator_impl.cc

, specifically the method:
StartupBrowserCreatorImpl :: AddStartupURLs

, this method is the one that is responsible for deciding which URL will load start. More info at: http://blog.jgutix.com/2015/04/personalizando-chrome.html

Pankaj Goyal

unread,
Jan 23, 2019, 5:10:46 PM1/23/19
to Chromium-discuss, laurent...@gmail.com, joaod...@chromium.org
Seems like the AddStartupURLs method is no more. Any other way to set the homepage?
Reply all
Reply to author
Forward
0 new messages